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

WSO2 Code Specific Plugin #18

Open
wants to merge 14 commits into
base: sonar-custom-rules
Choose a base branch
from

Conversation

areebniyas
Copy link
Contributor

@areebniyas areebniyas commented Jan 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants