Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: 📝 "++i" statement is not so bad #317

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- [#4](https://github.com/green-code-initiative/ecoCode-java/issues/4) Improvement: "++i" statement is not so bad
- [#318](https://github.com/green-code-initiative/ecoCode/issues/318) Implement the rule EC523 for React Native

### Deleted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,26 @@ i++ // Noncompliant
```java
++i
```

## Exception
In some cases, it may be intentional to allow the use of `i++`, even if it is probably not far from a code smell.
Examples:

```java
void bar(int value) {
// ...
}

int foo() {
int i = 0;
bar(i++);
return i;
}
```
or
```java
private int i = 0;
int foo() {
return this.i++;
}
```
Loading