-
Notifications
You must be signed in to change notification settings - Fork 79
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
Clean code attributes and better descriptions complying with Sonar Coding rule guidelines #349
base: main
Are you sure you want to change the base?
Clean code attributes and better descriptions complying with Sonar Coding rule guidelines #349
Conversation
Hi @pbaumard , thank you for this PR ... very interesting but a lot of modifications. Furthermore, your build is not ok on github action ... please make a correction for it.
please check it in your local machine. Last question : why is your PR in Draft mode ? Do you still want to work on it ? |
This PR is now ready for review. |
@dedece35 Any chance to get this PR reviewed? It would then be necessary to update all plugins. |
hello ... thank you for the work ... review in progress ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this huge work!
I did a quick tour on HTML/JavaScript rules changes, it seems good overall 👍
But I'm wondering if this PR isn't too large... it's really huge and I can't see myself going through all the changes without spending half a day on it..
---- | ||
|
||
=== Compliant solution | ||
|
||
We recommend using the following formats: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this section is now in "Compliant solution"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The section change was reverted.
"compatibleLanguages": [ | ||
"JAVASCRIPT", | ||
"TYPESCRIPT" | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be an empty line at the end of the file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the spotless plugin to check newlines for all json files. This is just a matter of consistency.
@@ -11,25 +11,33 @@ However, even without autoplay, segments of video or audio files might still dow | |||
This leads to unnecessary data usage, especially if users don't commence playback. | |||
To mitigate this, it's crucial to prevent browsers from preloading any content by configuring the appropriate settings. | |||
|
|||
Video: | |||
== How to fix it in video |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both section names are wrong here, we do not provide a video to explain how to fix the problem
== How to fix it in video | |
== How to fix a video element |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those section titles were changed in latests commits.
@@ -63,6 +69,11 @@ Location.requestPermissionsAsync(); // Compliant | |||
|
|||
== Resources | |||
|
|||
=== Best practises | |||
|
|||
- https://github.com/cnumr/best-practices-mobile[Mobile-specific Best Practices] by https://collectif.greenit.fr/index_en.html[CNumR] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a more precise source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same source as the java version of EC523. Do you have a better source?
HI @zippy1978 and @olegoaer, |
@@ -1,11 +1,16 @@ | |||
{ | |||
"title": "Sobriety: Thrifty Geolocation (minTime)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you delete the title ? maybe refactor it like done in another updates of this PR, no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The title seems useless since it is redefined in the JSON of all EC523 subdirectories, so this title would always be overriden, right?
"tags": [ | ||
"sobriety", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you delete "sobriety" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first I thought sobriety was too close to existing eco-design or performance tags. I later changed my mind to include all tags from https://github.com/cnumr/best-practices-mobile
sobriety tag removal was reverted in latests commits.
"tags": [ | ||
"sobriety", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you delete "sobriety" tag on several updates ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above reply in #349 (comment)
|
||
SWITCH statement solution + refactor solution | ||
With a `switch`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, please add the explanation like done in python and PHP files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in latest commits.
|
||
== Resources | ||
|
||
Reference/Validation is unknown. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move above link to here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in latest commits.
|
||
SWITCH statement solution + refactor solution | ||
With a `switch`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here, please add the explanation like done in python and PHP files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in latest commits.
@@ -1,5 +1,5 @@ | |||
{ | |||
"title": "Do not call a function when declaring a for-type loop", | |||
"title": "Functions should not be called when declaring a for-type loop", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update title description to be clearer : please, replace “when declaring a for-loop type” by “inside a for-loop condition”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in latest commit.
"compatibleLanguages": [ | ||
"JAVASCRIPT", | ||
"TYPESCRIPT" | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -94,13 +94,56 @@ | |||
</issueManagement> | |||
|
|||
<properties> | |||
<java.version>11</java.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all these pom.xml modifications must be in the ecocode-rules-specifications pom.x instead and the current parent pom.xml
all other plugins work with java 17. why do you put java 11 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
POM changes have been moved to ecocode-rules-specifications.
Some of the configuration, including java 11 is coming from
https://github.com/green-code-initiative/ecoCode-java/blob/main/pom.xml
Java version could be changed.
@@ -0,0 +1,263 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok to create a new Test class to check all files and all rules. but I think we can do it simplier, maybe.
I will run your test class and give my feedback soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dedece35 Did you have time to review the test class?
@@ -3,15 +3,10 @@ | |||
"type": "CODE_SMELL", | |||
"status": "ready", | |||
"remediation": { | |||
"func": "Constant\/Issue", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you test your modification in a local SonarQube to check if the description is well displayed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those func attribute changes were reverted.
@dedece35 Any progress on the review? I don't see any point waiting for me. |
@dedece35 It seems all the PR builds are failing because of a "401 Unauthorized" error on the Sonar server:
Note that PRs are also failing for the same reason on other repositories, e.g. on creedengo-java: |
pom.xml
Outdated
@@ -1,470 +1,594 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<modelVersion>4.0.0</modelVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, but why do you want to modify XML formatting ? we use default XML formatting from IntelliJ : tabulation = 4 spaces
pom.xml
Outdated
<scm> | ||
<connection>scm:git:https://github.com/green-code-initiative/creedengo-rules-specifications</connection> | ||
<developerConnection>scm:git:https://github.com/green-code-initiative/creedengo-rules-specifications</developerConnection> | ||
<tag>HEAD</tag> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you want these minor modifications ?
pom.xml
Outdated
--> | ||
<revision>current-SNAPSHOT</revision> | ||
<properties> | ||
<!-- Default version when disabling Maven `maven-git-versioning-extension` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not ... but if you do these kind of modifications, we will have a lot of modifications ... I remain doubtful about these modifications.
for me, it's more readable with old comment mode.
pom.xml
Outdated
<executions> | ||
<execution> | ||
<id>convert-to-html</id> | ||
<goals> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you want to change the order ?
pom.xml
Outdated
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.7.1</version> | ||
<configuration> | ||
<appendAssemblyId>true</appendAssemblyId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this move ?
pom.xml
Outdated
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
</project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, but pom.xml modifications are too important and disparate ...
for me, first, please make minimum modifications (adding dependencies test for example)
and secondly (in another PR, formating modifications ... on which we will discuss about veracity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This project was not using any Java code previously so there will be anyway many changes in the POM.
The formatting changes related to Spotless sortPom are very small compared to changes related to the introduction of Java code.
@@ -1,5 +1,5 @@ | |||
{ | |||
"title": "Avoid Spring repository call in loop or stream operations", | |||
"title": "Spring repository should not be called in loop or stream operations", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in my point of view, I prefer a turn of phrase without negation, thus, I prefer "avoid" than "should not be" ... but I can ask for the point of view of core team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From Sonar Coding rule guidelines:
The title of the rule should match the pattern "X should [ not ] Y" for most rules. Note that the "should [ not ]" pattern is too strong for Finding rules, which are about observations on the code. Finding titles should be neutral, such as "Track x".
And as a developer I like the "X should [ not ] Y" pattern, because the expected fix is clear.
With "Avoid X" pattern sometimes it is not clear whether the code is avoiding X and it should not or the opposite, that is the code is using X and it should avoid it.
Hi @pbaumard , as @utarwyn, sorry, but for me also, this PR is so huge ... Sorry, to say it, but for me, I can't accept this PR with all these modifications ... mainly because there too important modifications on many files and I have so many questions / review feedbacks. What do you think about it @utarwyn , @olegoaer , @glalloue, @zippy1978 , @Djoums ? |
I agree this PR should not be commited as is. As I can see there's a mix of issues :
I'd split this PR by files and/or by change types (titles, tags, layout, etc). |
The many files change are mainly just a consequence of the testing added which make the JSON complying with Sonar Coding rule guidelines. It would be quite artificial to limit the tests to a subset of files. And it would be also artificial to create many PRs all modifying many files just adre
Title wording style is coming from Sonar Coding rule guidelines
Formatting changes have been reverted and are addressed in #366
The many files change are mainly just a consequence of the testing added which make the JSON complying with Sonar Coding rule guidelines. It would be quite artificial to limit the tests a a subset of files.
Title wording style is coming from Sonar Coding rule guidelines
Layout split is done in #366 Splitting by file is hard since the tests are applied to all files. If this is split by change type, the number of files in PRs will not change. A split would require even more work and would not limit the amount of review required. If there is one area you think should be excluded from this PR, I could try to split it. This PR is really just a test-driven PR applying the Sonar Coding rule guidelines. |
Ensures the Sonar Coding rule guidelines for rule specifications are followed with tests. This should avoid most of the comments made by Sonar reviewers, e.g. in ecocode plugin request or ecocode js plugin request:
It will improve the user experience when using Creedengo plugins. All the differences from the standard Sonar rules are still stricking me when I use the rules: the wrong Clean Code attributes, the weird rule titles format, non standard sections in descriptions, etc.
This may give a bad first impression to many Creedengo users and may discourage the use of Creedengo plugins.
SonarQube is a code quality solution so its users typically care a lot about consistency.
To be honest I am quite suprised that Sonar does not ensure that the Community plugins comply with the Sonar Coding rule guidelines. Maybe plugins will have to comply in the future.