Track lack of copyright in python files

we are using SonarQube 8.6 and the plugins checkstyle, findbugs and pmd.
The rule java:S1451 (Track lack of copyright and license headers) allows to check in java files for the existence of a copyright matching a configurable regex.
Similar rules are available for other languages like JavaScript, HTML, PHP, go, Ruby, … .
Unfortunately the rule doesn’t exist for python and we are wondering what is the best way to check for the existence of a proper copyright in a python file.
We were hoping for a rule template that allows to check that each file begins with a match for a given regular expression, but couldn’t find anything in that direction as well.

Thx in advance for any ideas
LG Sammy

Hi @Sammy ,

There is a backlog ticket for this rule implementation for Python but it not yet planned for release yet: SONARPY-272. You are welcome to vote up and watch that ticket for any notification as well as comment on the ticket to help support your case for pushing this ticket.

For now, you can try adding your own coding rule(s) (which involves creating a plugin) or import the Generic Issues Report, which will get you want you want. So if there’s a way to customize/add the license regex check to Pylint, Bandit, or Flake8, then you can import that report and get it into SonarQube to track.

If you have the interest and time, you can also submit a PR for adding this rule to the Sonar Python analyzer. Here’s the Java implementation for reference:


1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.