Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Is it possible to add "eco-conception" tag on existing built-in rules ? #161

Open
dedece35 opened this issue Oct 26, 2022 · 6 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@dedece35
Copy link
Collaborator

dedece35 commented Oct 26, 2022

Check if follows are possible programmatically within ecocode plugin :

  • add "eco-conception" tag to existing built-in rules. Why ? because some existing rules could be part of eco-conception subject. goal : avoid rewriting an existing rule.
  • change severity. why ? (if previous check is ok) because, for eco-conception, maybe a rule is more important than default severity.
@dedece35 dedece35 self-assigned this Oct 26, 2022
@dedece35 dedece35 added the enhancement New feature or request label Oct 26, 2022
@dedece35 dedece35 changed the title Possible to add "eco-cocneption" tag on existing rules ? Is it possible to add "eco-cocneption" tag on existing rules ? Oct 26, 2022
@dedece35 dedece35 changed the title Is it possible to add "eco-cocneption" tag on existing rules ? Is it possible to add "eco-cocneption" tag on existing built-in rules ? Oct 26, 2022
@dedece35 dedece35 changed the title Is it possible to add "eco-cocneption" tag on existing built-in rules ? Is it possible to add "eco-conception" tag on existing built-in rules ? Oct 26, 2022
@dedece35
Copy link
Collaborator Author

dedece35 commented Oct 26, 2022

check if possible to add tag ("eco-conception" for example) to an existing rule

check if possible to change severity of an existing rule

  • Sonar web site : yes possible. to do that : we have to create a new profile inherited from default "sonar way" profile and then on specific rule page, wh can change severity
  • Programmatically : TODO DDC

@Silicoman
Copy link
Contributor

Silicoman commented Nov 2, 2022

Hi,

it's actually what i'm doing on my sonarqube server.
I create new profile "green" for each language. It can be exported as xml file. Other team using other sonarqube can import this custom profile.
BUT , if if there is new rule on sonarqube (because you have done update sonarqube), you have to update the profile.

One solution, i was thinking to do a script using API to create from scratch the profile (and update it?).
Sonarsource uses scripts ps1 to solve this kind of issue.

Modify severity is another feature with low value. Not sure have to be done.

@dedece35
Copy link
Collaborator Author

dedece35 commented Nov 2, 2022

Hi @Silicoman ,
thank you for ideas.

indeed, in Sonarqube community forum (please see question link above), the SonarQube community manager gave us this answer also.
For me, this is not an optimized solution, because after plugin installation, we must execute a batch to initialize the environment. This is a possible solution but not the "top" solution for me. If the plugin do it automatically, it's better.

I agree with you regarding "severity modification" : maybe an other subject.
But, the purpose of this issue is to test possibles automatics actions that the plugin could do.
After that, we will discuss internally if we do them or not.

regards.

@dedece35
Copy link
Collaborator Author

dedece35 commented Nov 8, 2022

After discussion with Sonar source developers, here are their answers :

First answer (from SonarQube community manager) :
Hey there. Are you sure a custom plugin is the right way to go, rather than using the Web API (documentation linked in the footer of your instance).

Second answer (from SonarQube developer) :
Hi, this doesn’t seem to be achievable with current Plugin API. You can do what you want with the rules your plugin define but not with the rules other plugins define. The work-around would be to call SonarQube Web API from inside your plugin, to achieve what you want, but this doesn’t seem in general as a clean, good practice.

To conclude : the best practice is to use SonarQube API after installation of ecocode plugin.
To do this, we have to develop an installation process :

  • 1/ install plugin into SonarQube
  • 2/ call SonarQube Api to add ecoconception tag to all rules that we want (an internal list ?)

Question : do you have to create a new one profile (like @Silicoman example), or change default profile ?
According to me, creating a new profile isn't the best idea because one project could be only affected to only one profile and not several profiles. Thus, we can't at the same time and for one project, check several profiles (the personal profile and our ecoconeption profile)

@MP-Aubay
Copy link
Collaborator

MP-Aubay commented Nov 9, 2022

Hi @dedece35 ,

I think we should keep it simple at first, documenting the process to add ecoconception tag, and documenting how to add this tag in a new profile. That way users can create specific profile for ecocode or modify their custom profile.

An internal list all rules is a good idea, firstly based on performance rules on Sonar, and we could test it with ETSdiff when possible to keep good rules.

I am a bit frustrating too that we cannot automate the process, but a good documentation can do the job. And all users will not have the same configuration, with the same base rules set (depending on Sonar version).

@dedece35
Copy link
Collaborator Author

dedece35 commented Nov 9, 2022

@MP-Aubay

good idea, I agree with you to keep simple in the first time and describe the process in documentation with different use cases.
I will work to complete documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants