Skip to content

Commit

Permalink
Development: Always use braces for code blocks (#7315)
Browse files Browse the repository at this point in the history
  • Loading branch information
Strohgelaender authored Oct 7, 2023
1 parent f8658f6 commit c92c995
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 33 deletions.
1 change: 1 addition & 0 deletions checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
<property name="allowedAnnotations" value="Override,Test,ParameterizedTest,BeforeEach,AfterEach,BeforeAll,AfterAll"/>
</module>
<module name="ModifierOrder"/>
<module name="NeedBracesCheck"/>
</module>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public Set<TextBlock> splitSubmissionIntoBlocks(TextSubmission submission) {
final int startIndex = start + offset;
final int endIndex = startIndex + lineOrSentenceTrimed.length();
start = start + lineOrSentence.length() + LINE_SEPARATOR_LENGTH;
if (startIndex == endIndex || lineOrSentence.isBlank())
if (startIndex == endIndex || lineOrSentence.isBlank()) {
continue; // Do *not* define a text block for an empty line.
}

final TextBlock textBlock = new TextBlock().text(lineOrSentenceTrimed).startIndex(startIndex).endIndex(endIndex).submission(submission).automatic();
textBlock.computeId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ public final int hashCode() {

@Override
public final boolean equals(Object obj) {
if (this == obj)
if (this == obj) {
return true;
if (!(obj instanceof QuizExerciseCache))
}
if (!(obj instanceof QuizExerciseCache)) {
return false;
}
return Objects.equals(exerciseId, ((QuizExerciseCache) obj).exerciseId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ public void setCreatedDate(Instant createdDate) {

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ExamLiveEventDTO that = (ExamLiveEventDTO) o;
return Objects.equals(id, that.id) && Objects.equals(createdBy, that.createdBy) && Objects.equals(createdDate, that.createdDate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public void setText(String text) {

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
if (!super.equals(o))
}
if (!super.equals(o)) {
return false;
}
ExamWideAnnouncementEventDTO that = (ExamWideAnnouncementEventDTO) o;
return Objects.equals(text, that.text);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ public void setCourseWide(boolean courseWide) {

@Override
public boolean equals(Object o) {
if (this == o)
if (this == o) {
return true;
if (o == null || getClass() != o.getClass())
}
if (o == null || getClass() != o.getClass()) {
return false;
if (!super.equals(o))
}
if (!super.equals(o)) {
return false;
}
WorkingTimeUpdateEventDTO that = (WorkingTimeUpdateEventDTO) o;
return newWorkingTime == that.newWorkingTime && oldWorkingTime == that.oldWorkingTime && courseWide == that.courseWide;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,43 @@
<property name="fileExtensions" value="java, properties, xml"/>

<!-- Excludes all 'module-info.java' files -->
<!-- See https://checkstyle.org/config_filefilters.html -->
<!-- See https://checkstyle.org/filefilters/beforeexecutionexclusionfilefilter.html -->
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value="module\-info\.java$"/>
</module>

<!-- Allows to suppress checks for certain files -->
<!-- See https://checkstyle.sourceforge.io/config_filters.html#SuppressionFilter -->
<!-- See https://checkstyle.org/filters/suppressionfilter.html -->
<!-- <module name="SuppressionFilter"> -->
<!-- <property name="file" value="${config_loc}/checkstyle-suppressions.xml"/> -->
<!-- </module> -->

<!-- Checks that a package-info.java file exists for each package. -->
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
<!-- See https://checkstyle.org/checks/javadoc/javadocpackage.html -->
<!-- <module name="JavadocPackage"/> -->

<!-- Checks whether files end with a new line. -->
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
<!-- See https://checkstyle.org/checks/misc/newlineatendoffile.html -->
<module name="NewlineAtEndOfFile"/>

<!-- Checks that property files contain the same keys. -->
<!-- See https://checkstyle.org/config_misc.html#Translation -->
<!-- See https://checkstyle.org/checks/misc/translation.html -->
<module name="Translation"/>

<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<!-- See https://checkstyle.org/checks/sizes/index.html -->
<module name="FileLength"/>
<module name="LineLength">
<property name="fileExtensions" value="java"/>
<property name="max" value="120"/>
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
</module>
<module name="MethodLength"/>
<module name="ParameterNumber"/>

<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<!-- See https://checkstyle.org/checks/misc/index.html -->
<!-- See https://checkstyle.org/checks/regexp/index.html -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
Expand All @@ -65,7 +68,7 @@
</module>

<!-- Checks for Headers -->
<!-- See https://checkstyle.org/config_header.html -->
<!-- See https://checkstyle.org/checks/header/index.html -->
<!-- <module name="Header"> -->
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
<!-- <property name="fileExtensions" value="java"/> -->
Expand All @@ -74,7 +77,7 @@
<module name="TreeWalker">

<!-- Checks for Javadoc comments. -->
<!-- See https://checkstyle.org/config_javadoc.html -->
<!-- See https://checkstyle.org/checks/javadoc/index.html -->
<module name="InvalidJavadocPosition"/>
<module name="JavadocMethod"/>
<module name="JavadocType"/>
Expand All @@ -87,7 +90,7 @@
</module>

<!-- Checks for Naming Conventions. -->
<!-- See https://checkstyle.org/config_naming.html -->
<!-- See https://checkstyle.org/checks/naming/index.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
Expand All @@ -99,21 +102,17 @@
<module name="TypeName"/>

<!-- Checks for imports -->
<!-- See https://checkstyle.org/config_imports.html -->
<!-- See https://checkstyle.org/checks/imports/index.html -->
<!-- <module name="AvoidStarImport"/> -->
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="false"/>
</module>

<!-- Checks for Size Violations. -->
<!-- See https://checkstyle.org/config_sizes.html -->
<module name="MethodLength"/>
<module name="ParameterNumber"/>

<!-- Checks for whitespace -->
<!-- See https://checkstyle.org/config_whitespace.html -->
<!-- See https://checkstyle.org/checks/whitespace/index.html -->
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
Expand All @@ -126,20 +125,20 @@
<module name="WhitespaceAround"/>

<!-- Modifier Checks -->
<!-- See https://checkstyle.org/config_modifiers.html -->
<!-- See https://checkstyle.org/checks/modifier/index.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<!-- Checks for blocks. You know, those {}'s -->
<!-- See https://checkstyle.org/config_blocks.html -->
<!-- See https://checkstyle.org/checks/blocks/index.html -->
<module name="AvoidNestedBlocks"/>
<module name="EmptyBlock"/>
<!-- <module name="LeftCurly"/> -->
<module name="NeedBraces"/>
<!-- <module name="RightCurly"/> -->

<!-- Checks for common coding problems -->
<!-- See https://checkstyle.org/config_coding.html -->
<!-- See https://checkstyle.org/checks/coding/index.html -->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<module name="HiddenField">
Expand All @@ -156,15 +155,15 @@
<module name="SimplifyBooleanReturn"/>

<!-- Checks for class design -->
<!-- See https://checkstyle.org/config_design.html -->
<!-- See https://checkstyle.org/checks/design/index.html -->
<!--<module name="DesignForExtension"/> -->
<module name="FinalClass"/>
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<module name="VisibilityModifier"/>

<!-- Miscellaneous other checks. -->
<!-- See https://checkstyle.org/config_misc.html -->
<!-- See https://checkstyle.org/checks/misc/index.html -->
<module name="ArrayTypeStyle"/>
<!-- <module name="FinalParameters"/> -->
<!-- <module name="TodoComment"/> -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ static void detectMavenHome() {
String m2Home = System.getenv("M2_HOME");
String mavenHome = System.getProperty("maven.home");

if (m2Home != null || mavenHome != null)
if (m2Home != null || mavenHome != null) {
return;
}

try {
String mvnExecutable = Os.isFamily(Os.FAMILY_WINDOWS) ? "mvn.cmd" : "mvn";
Expand Down

0 comments on commit c92c995

Please sign in to comment.