I am fairly new to the Code Scanning process - but had success getting setup pretty quickly. I was hoping to get some results to review - and take the next steps from there.
Seems our test file is getting ignored and I can’t seem to find a solution.
Could be as simple as me running it after unzipping but I doubt that is the problem.
Hopefully its something simple you fine people can help with!
Only change from Default settings is adding the inclusion - which was part of the troubleshooting - same error before inclusion.
which versions are you using (SonarQube Server / Community Build, with Scanner, and no plugins or relevant extensions)
sonarqube-9.9.8.100196
how is SonarQube deployed: zip, - but unzipped to a folder to use and was able to run the server and connect by browser and even get to the point where the scanner scans successfully.
what are you trying to achieve - Scanning our simple python script.
what have you tried so far to achieve this -
Confirmed Python is in the list of languages in the Administrative and Project Settings.
Checked for exclusions for both the project and administrative settings. Both are clear, and I added the inclusion -
Scanned both the folder with only the 1 file in it - as well as the file itself. Tried its parent folder and it ignored all ~300 plus files that were in there - none of which are code though - so i expect those to get ignored other than our python file.
08:41:19.553 INFO Included sources: **/*.py
08:41:19.566 INFO 0 files indexed
08:41:19.567 INFO 1 file ignored because of inclusion/exclusion patterns
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
Assuming the scanner is executed from the project’s root directory (at least a parent directory to where your Python file is), I would expect it to be indexed!
colin@MAC-L0251 pytest % tree
.
└── test
└── test.py
2 directories, 1 file
colin@MAC-L0251 pytest % sonar-scanner \
-Dsonar.projectKey=test \
-Dsonar.sources=. \
-Dsonar.host.url=http://localhost:9000 \
-Dsonar.token=TOKEN \
-Dsonar.inclusions="**/*.py"
INFO: Scanner configuration file: /Users/colin/tools/sonar-scanner-5.0.1.3006/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 5.0.1.3006
INFO: Java 17.0.13 Homebrew (64-bit)
INFO: Mac OS X 15.2 aarch64
INFO: User cache: /Users/colin/.sonar/cache
INFO: Analyzing on SonarQube server 10.8.1.101195
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=38ms
INFO: Server id: D1F8575B-AZRBB7unRCJHzcxi_ZHz
INFO: Loading required plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=24ms
INFO: Load/download plugins
INFO: Load/download plugins (done) | time=32ms
INFO: Loaded core extensions: developer-scanner, sca, server-common
INFO: Process project properties
INFO: Process project properties (done) | time=3ms
INFO: Project key: test
INFO: Base dir: /Users/colin/source/pytest
INFO: Working dir: /Users/colin/source/pytest/.scannerwork
INFO: Load project settings for component key: 'test'
INFO: Load project settings for component key: 'test' (done) | time=18ms
INFO: Load project branches
INFO: Load project branches (done) | time=12ms
INFO: Load branch configuration
INFO: Load branch configuration (done) | time=0ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=41ms
WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings.
INFO: Load active rules
INFO: Load active rules (done) | time=1451ms
INFO: Load analysis cache
INFO: Load analysis cache (126 bytes) | time=13ms
INFO: Preprocessing files...
INFO: 1 language detected in 1 preprocessed file
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Loading plugins for detected languages
INFO: Load/download plugins
INFO: Load/download plugins (done) | time=19ms
INFO: Load project repositories
INFO: Load project repositories (done) | time=6ms
INFO: Indexing files...
INFO: Project configuration:
INFO: Included sources: **/*.py
INFO: 1 file indexed
INFO: Quality profile for py: Sonar way
INFO: ------------- Run sensors on module test
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=10ms
INFO: Sensor Python Sensor [python]
WARN: Your code is analyzed as compatible with all Python 3 versions by default. You can get a more precise analysis by setting the exact Python version in your configuration via the parameter "sonar.python.version"
INFO: Starting global symbols computation
INFO: 1 source file to be analyzed
INFO: 1/1 source file has been analyzed
INFO: Starting rules execution
INFO: 1 source file to be analyzed
Does anything look different here than what you see (besides the success, of course)
What is the name of your Python file (with extension)?
If you’re still stuck, try running sonar-scanner -X (for DEBUG level logs) and pasting the full logs here. It offers significantly more information about what files are actually being indexed and why.