Python Flake8 output is ignored

I’m using SonarQube version 9.7.1 and sonar scanner version 4.7.0
I’ve configured the property sonar.python.flake8.reportPaths=output_flake.txt and generate flake8 output using

flake8 --output-file=output_flake8.txt ./

The output is ignored since I don’t have any difference in issues on SonarQube with or without it. output_flake.txt is correct and contains few errors.
In the output INFO I got

INFO: Sensor Import of Flake8 issues [python]
INFO: Sensor Import of Flake8 issues [python] (done) | time=1ms

I tried the same using pylint (and also bandit) and it works fine.

pylint --recursive=y --output-format=parseable:output_pylint ./

Hi,

Could you go to your project’s list of background tasks ([homepage] → Project Settings → Background Tasks) and check the scanner context ([task row] → [cog menu] → Show Scanner Context) to make sure that sonar.python.flake8.reportPaths is actually in the list of parameters the scanner received?

 
Ann

Yes sonar.python.flake8.reportPaths is in the list of parameters.

Project scanner properties:
  - sonar.host.url=http://sonarqube:9000
  - sonar.login=******
  - sonar.projectBaseDir=/usr/src
  - sonar.projectKey=xxx
  - sonar.python.bandit.reportPaths=output_bandit.json
  - sonar.python.flake8.reportPaths=output_flake.txt
  - sonar.python.version=3.8
  - sonar.scanner.app=ScannerCLI
  - sonar.scanner.appVersion=4.7.0.2747
  - sonar.sourceEncoding=UTF-8
  - sonar.working.directory=/usr/src/.scannerwork

Hi,

Can you add -Dsonar.log.level=DEBUG to your analysis command line & post the resulting analysis log?

 
Thx,
Ann

In the debug I got an errors in each line of flake output.

13:36:25.066 DEBUG: Cannot parse the line: e[1m./bitscrooge/bitscrooge_vo_service.pye[me[36m:e[m1e[36m:e[m1e[36m:e[m e[1me[31mF401e[m ‘typing.TypeVar’ imported but unused

There is any options I need to use to generate the output of flake8?

Hi,

Could you share what the corresponding line of the flake8 report looks like?

I guess this is about non-UTF-8 characters, but it’s difficult for me to tell if they’re in the file names or the files themselves.

 
Ann

Yes, it seems the problem is the default format of flake8.
I tried using pylint formatter and it is working fine.

flake8 --format=pylint --output-file=output_flake.txt ./

1 Like

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