-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest to not use conditional logic
- Loading branch information
1 parent
4632089
commit 59dc03f
Showing
5 changed files
with
49 additions
and
1 deletion.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/analyzer/exercises/leap/AvoidConditionalLogic.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package analyzer.exercises.leap; | ||
|
||
import analyzer.Comment; | ||
import analyzer.CommentType; | ||
|
||
/** | ||
* @see <a href="https://github.com/exercism/website-copy/blob/main/analyzer-comments/java/leap/avoid_conditional_logic.md">Markdown Template</a> | ||
*/ | ||
class AvoidConditionalLogic extends Comment { | ||
@Override | ||
public String getKey() { | ||
return "java.leap.avoid_conditional_logic"; | ||
} | ||
|
||
@Override | ||
public CommentType getType() { | ||
return CommentType.ACTIONABLE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/test/resources/analyzer/exercises/leap/UsesIfStatements.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Leap { | ||
boolean isLeapYear(int year) { | ||
if (year % 400 == 0) return true; | ||
if (year % 100 == 0) return false; | ||
if (year % 4 == 0) return true; | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Leap { | ||
boolean isLeapYear(int year) { | ||
return (year % 400 == 0) ? true : (year % 100 == 0) ? false : (year % 4 == 0) ? true : false; | ||
} | ||
} |