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

[EC67] rule improvment : "++i" statement is not so bad #4

Open
dedece35 opened this issue Jan 8, 2024 · 1 comment · May be fixed by #42
Open

[EC67] rule improvment : "++i" statement is not so bad #4

dedece35 opened this issue Jan 8, 2024 · 1 comment · May be fixed by #42
Labels
🗃️ rule rule improvment or rule development or bug 🚀 enhancement New feature or request

Comments

@dedece35
Copy link
Member

dedece35 commented Jan 8, 2024

Describe the bug
The rule wants us to change "i++" to "++i" statement.
But often "i++" has a really functionnal usage like screenshot below.

Expected behavior
improve actual behaviour to detect if "i++" statement is used alone or not (example : in a concatenation string).
if alone, ok raise the issue. if not, don't raise issue because we don't know if "i++" has a functionnal usage or not.

Screenshots
i++

Software Versions

  • SonarQube Version: 10.3
  • Plugin Version: java plugin 1.4.3
@dedece35 dedece35 changed the title [EC67] Rule improvment : ++i is often really good [EC67] rule improvment : "++i" statement is not so bad Jan 8, 2024
@diyfr
Copy link

diyfr commented Jan 29, 2024

in c the only case where a temporary variable is created is during combined use
In this case, no temporary variable :
for (int i=0; i< 10; i++) or for (int i=0; i< 10; ++i)
the increment is an isolated operation
It's same in

while(myValue){
// Your code here, change myValue

//increment
i++;
}

@dedece35 dedece35 added 🗃️ rule rule improvment or rule development or bug 🚀 enhancement New feature or request labels May 20, 2024
pataluc referenced this issue in max-208/ecoCode-java May 29, 2024
In some cases, postfix increment may be intentional.

Closes #4
pataluc referenced this issue in max-208/ecoCode-java May 29, 2024
In some cases, postfix increment may be intentional.

Closes #4
pataluc referenced this issue in max-208/ecoCode-java May 29, 2024
In some cases, postfix increment may be intentional.

Closes #4
pataluc referenced this issue in max-208/ecoCode-java May 29, 2024
In some cases, postfix increment may be intentional.

Closes #4
hocinehacherouf added a commit to hocinehacherouf/ecoCode-java that referenced this issue May 29, 2024
Ignore rule EC67 when i++ is located within a binary expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🗃️ rule rule improvment or rule development or bug 🚀 enhancement New feature or request
Projects
None yet
2 participants