Recognize and analyze python files without an extension?

Using SonarQube v8.9.1.44547

Trying to scan python projects where some python files do not have any file extension/.py suffix.

These are not recognized by the Python file detector and remain un-scanned.

Saw this stack overflow post from years ago that said there was no solution to identifying and scanning files without extensions: sonarqube - Sonar python files without .py suffix - Stack Overflow

Are there any new alternatives to get around this issue?

Maybe a new feature? (specifying files to be scanned as a specific language? python file detector could check for a python shebang to identify python files?)

That’s definitely not a standard case, however you can try to adjust a particular property to fit your project:**/*

The above configuration would configure all files inside src as python files.
Patterns are described here.

1 Like

Thanks Pierre-Yves, that works to help specify any file as a python file.

Our implementation now works by running a wrapper to find python files (using the Linux file utility) and passes it to sonar-scanner using the language patterns property.

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