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

[S90-JAVA] Avoid use of static in interface #183

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

ggeoffroy68
Copy link

No description provided.

@ggeoffroy68
Copy link
Author

Bad usage:
 

    public interface Color {
        public static final int RED = 0xff0000;// Noncompliant
        public static final int BLACK = 0x000000;// Noncompliant
        public static final int WHITE = 0xffffff;// Noncompliant
    }

Good usage:

    public enum Color {
        RED,// Compliant
        BLACK,// Compliant
        WHITE;// Compliant
    }

@ggeoffroy68 ggeoffroy68 self-assigned this Dec 3, 2022
@sonarcloud
Copy link

sonarcloud bot commented Dec 3, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 4 Code Smells

83.3% 83.3% Coverage
0.0% 0.0% Duplication

@dedece35
Copy link
Collaborator

dedece35 commented Dec 3, 2022

Hello @ggeoffroy68,
I have questions about this new rule.
I agree with you public static final keywords are useless. For example, we can have an interface with variables like int RED = 0xff0000;.
But why is it a "green" rule ?
And why enum usage is better that an interface with variables ? maybe one enum is better of one interface + 3 variables ?
Do you have a scientific paper about this subject ?

thank you.

@dedece35
Copy link
Collaborator

dedece35 commented Dec 5, 2022

Hi @ggeoffroy68 ,
we are migrating this repo to a new one : please see green-code-initiative/ecoCode#7

@dedece35 dedece35 added rule this is a problem on a rule migrated_to_new_standrad_repo if is migrated to new standard repo labels Dec 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
migrated_to_new_standrad_repo if is migrated to new standard repo plugin:java rule this is a problem on a rule
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

2 participants