Skip to content

Commit 2bc8d87

Browse files
authored
Merge pull request #317 from max-208/67-java
GCI67 S.T.E.P Challenge2025: docs: 📝 "++i" statement is not so bad
2 parents c02dcca + 01a21c5 commit 2bc8d87

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
- [GCI91](https://github.com/green-code-initiative/creedengo-rules-specifications/pull/410) Adapt rule GCI91 to java context in case of stream
1717
- [GCI69](https://github.com/green-code-initiative/creedengo-rules-specifications/pull/396) Calls to hasMoreElements() and nextElement() methods from java.util.Enumeration interface aren't flagged anymore when called in a for loop
1818
- Correction of various typos in rules documentations
19+
- [#44](https://github.com/green-code-initiative/creedengo-java/issues/44) Improvement: "++i" statement is not so bad
20+
1921

2022
### Deleted
2123

src/main/rules/GCI67/java/GCI67.asciidoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,28 @@ i++ // Noncompliant
1313
----
1414
++i
1515
----
16+
17+
## Exception
18+
In some cases, it may be intentional to allow the use of `i++`, even if it is probably not far from a code smell.
19+
Examples:
20+
21+
[source,java]
22+
----
23+
void bar(int value) {
24+
// ...
25+
}
26+
27+
int foo() {
28+
int i = 0;
29+
bar(i++);
30+
return i;
31+
}
32+
----
33+
or
34+
[source,java]
35+
----
36+
private int i = 0;
37+
int foo() {
38+
return this.i++;
39+
}
40+
---

0 commit comments

Comments
 (0)