You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: IA_description.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,12 +52,12 @@ Each unit test class checking rule implementation class has the same template of
52
52
- usage of "CheckVerifier.verifyNoIssues" to check there is no issues raised
53
53
- each call to "CheckVerifier" needs a test resource file : this one is the resource code file for the simulated analysis
54
54
55
-
each test resource file is in the "test/resources/checks" directory (or sub-directories).
55
+
each test resource file is in the "src/test/files" directory (or sub-directories).
56
56
each test resource file contains compliuant code or / and non compliant code.
57
-
If there is no compliant code on which Sonarqube analysis should raise an issue, the line with the issue has a comment at the end of the line with the following template :
58
-
"# Noncompliant {{ERROR_MESSAGE_TO_DISPLAY}}"
57
+
If there is non compliant code on which Sonarqube analysis should raise an issue, the line with the issue has a comment at the end of the line with the following template :
58
+
"// Noncompliant {{ERROR_MESSAGE_TO_DISPLAY}}"
59
59
- the "ERROR_MESSAGE_TO_DISPLAY" in the previous template is replaced by the real error message.
60
-
- this comment give the information to "CheckVerifier", the simulation tool, that an error is expected at this line
60
+
- this comment gives the information to "CheckVerifier", the simulation tool, that an error is expected at this line
Copy file name to clipboardExpand all lines: IA_rule.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,20 +13,20 @@ Use the TDD (Test-Driven Development) methodology to implement a rule in an effi
13
13
- Non-compliant code
14
14
- Code with elements that should not be analyzed
15
15
- Location of test resource files:
16
-
- Files for unit tests: in "test/resources/checks" or subdirectories
16
+
- Files for unit tests: in "src/test/files" or subdirectories
17
17
- Files for integration tests: in "src/it/test-projects" or subdirectories
18
18
- Create the rule implementation class in the package "org.greencodeinitiative.creedengo.java.checks"
19
19
- Add the "Rule" annotation with the correct rule id (the rule is previously defined in another maven component named "creedengo-rules-specifications")
20
20
- Extend the "IssuableSubscriptionVisitor" class
21
-
-Implement the "initialize" method which will be used to declare the AST node types to analyze in depth but leave it empty for now
21
+
-Override the "nodesToVisit", "visitNode" and (optionally) "leaveNode" methods, which will be used respectively to declare the AST node types to analyze in depth and to implement the analysis logic, but leave their bodies empty for now
22
22
- Create the rule unit test class in the package "org.greencodeinitiative.creedengo.java.checks"
23
23
- Verify that unit tests fail with non-compliant test resources
24
24
25
25
## STEP 2: Implement the rule + unit test validation
26
26
- Implement the rule in the implementation class created in step 1
27
-
- Implement the "initialize" method to declare the AST node types to analyze in depth
27
+
- Implement the "nodesToVisit" method to declare the AST node types to analyze in depth and implement the "visitNode" and, if needed, "leaveNode" methods to perform the analysis on those nodes
28
28
- Implement private methods to analyze in depth the declared AST nodes and raise issues if needed
29
-
- Verify that unit tests pass with both compliant and non-compliant test resources
29
+
- Verify that unit tests pass with both compliant and non-compliant test resources, and call them from "visitNode"/"leaveNode"
30
30
31
31
## STEP 3: Implement integration tests
32
32
- Add a test method in the integration class "GCIRulesIT" for the implemented rule using the same pattern as other existing test methods
Copy file name to clipboardExpand all lines: src/it/test-projects/creedengo-java-plugin-test-project/src/main/java/org/greencodeinitiative/creedengo/java/checks/FreeResourcesOfAutoCloseableInterface.java
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ public void foo2() throws IOException {
37
37
}
38
38
39
39
/**
40
-
* The first methods adds a "try" in the stack used to follow if the code is in a try
40
+
* The first method adds a "try" in the stack used to follow if the code is in a try
protectedstaticfinalStringMESSAGE_RULE = "try-with-resources Statement needs to be implemented for any object that implements the AutoClosable interface.";
59
+
protectedstaticfinalStringMESSAGE_RULE = "try-with-resources Statement needs to be implemented for any object that implements the AutoCloseable interface.";
0 commit comments