-
Notifications
You must be signed in to change notification settings - Fork 27
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
WSO2 Code Specific Plugin #18
Open
areebniyas
wants to merge
14
commits into
wso2:sonar-custom-rules
Choose a base branch
from
areebniyas:sonar-custom-rules
base: sonar-custom-rules
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
WSO2 Code Specific Plugin #18
areebniyas
wants to merge
14
commits into
wso2:sonar-custom-rules
from
areebniyas:sonar-custom-rules
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sonar-plugin/org.wso2.code.quality.sonar.plugin/dependency-reduced-pom.xml
Outdated
Show resolved
Hide resolved
...lugin/src/main/resources/org/wso2/rules/descriptions/ClassLevelVariablesInServicesCheck.html
Outdated
Show resolved
Hide resolved
.../org.wso2.code.quality.sonar.plugin/src/test/sonar/rules/test/files/VariableLengthCheck.java
Outdated
Show resolved
Hide resolved
senthalan
reviewed
Jan 20, 2023
...code/quality/sonar/plugin/custom/check/authenticator/ClassLevelVariablesInServicesCheck.java
Outdated
Show resolved
Hide resolved
sonar-plugin/plugin/src/main/java/org/wso2/code/quality/sonar/plugin/RulesList.java
Outdated
Show resolved
Hide resolved
sonar-plugin/plugin/src/main/java/org/wso2/code/quality/sonar/plugin/RulesList.java
Outdated
Show resolved
Hide resolved
.../java/org/wso2/code/quality/sonar/plugin/custom/check/variable/classname/ClassNameCheck.java
Outdated
Show resolved
Hide resolved
sonar-plugin/plugin/src/main/java/org/wso2/code/quality/sonar/plugin/util/PluginConstants.java
Show resolved
Hide resolved
sonar-plugin/plugin/src/test/java/org/wso2/code/quality/sonar/plugin/RulesPluginTest.java
Show resolved
Hide resolved
sonar-plugin/plugin/src/test/java/org/wso2/code/quality/sonar/plugin/RulesPluginTest.java
Outdated
Show resolved
Hide resolved
.../org/wso2/code/quality/sonar/plugin/custom/check/ClassLevelVariablesInServicesCheckTest.java
Show resolved
Hide resolved
areebniyas
commented
Feb 1, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
asha15
reviewed
Feb 22, 2023
Co-authored-by: Asha Sulaiman <[email protected]>
Co-authored-by: Asha Sulaiman <[email protected]>
Co-authored-by: Asha Sulaiman <[email protected]>
Co-authored-by: Asha Sulaiman <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose
In WSO2, we have a set of coding best practices and security best practices which are not common in Java. So using default or basic static analysis tools such as find bugs and check style will not be able to analyze and identify these types of bugs.
Goals
The goal is to help offload the PR review process for the leads.
Approach
With a custom sonar plugin, we will be able to write custom rules that can be used to detect common WSO2 specific violations and security guidelines. Developers can easily integrate Sonar into their workflow and ensure that their code adheres to WSO2’s coding standards before a code review session.
This PR includes a custom sonar plugin that includes various custom rules:
Class Level Variables in Services - Custom check to see if class level variables exist in specific services and make sure the variables declared in specific services are static and final.
Tenant Flow - Custom check to make sure TenantFlow() invocations are inside try/finally blocks. It covers all the cases from checking if endTenantFlow() is called in the finally block only and startTenantFlow() is in a try block and it is the first line in a try block.
License Header - Custom check to see if Inc. exists in license header. Since we recently became LLC, this check will identity the use of WSO2 Inc anywhere in the codebase.
Class Name - Custom check to see if class names contain the word 'Class' or 'Enum'.
Variable Length - Custom check to see if variable name length exceeds 1.