insideapp-oss / sonar-flutter

SonarQube plugin for Flutter / Dart
Other
449 stars 83 forks source link

mutli module analyze report in analyzer.mode=MANUAL has no effect #182

Closed jiechic closed 7 months ago

jiechic commented 1 year ago

sonar-project.properties

sonar.modules=old_utils,okki_flutter,okki_flutter_example,okki_login

old_utils.sonar.projectBaseDir=packages/old-utils

okki_flutter.sonar.projectBaseDir=packages/okki-flutter okki_flutter_example.sonar.projectBaseDir=packages/okki-flutter/example

okki_login.sonar.projectBaseDir=packages/okki-login

sonar.dart.analyzer.mode=MANUAL sonar.dart.analyzer.report.mode=MACHINE sonar.dart.analyzer.report.path=analysis-results.txt

log

15:52:27.423 INFO: Indexing files of module 'okki_flutter'
15:52:27.423 INFO:   Base dir: /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter
15:52:27.424 DEBUG:   Source paths: lib, pubspec.yaml
15:52:27.424 DEBUG:   Test paths: test
15:52:27.427 DEBUG: File '/Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/okki_flutter.reflectable.dart' is excluded by the scm ignore settings.
15:52:27.427 DEBUG: File '/Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/gen/res/colors.gen.dart' is excluded by the scm ignore settings.
15:52:27.428 DEBUG: File '/Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/gen/res/assets.gen.dart' is excluded by the scm ignore settings.
15:52:27.429 DEBUG: File '/Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/gen/l10n/okki_flutter_localizations_en.dart' is excluded by the scm ignore settings.
15:52:27.429 DEBUG: File '/Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/gen/l10n/okki_flutter_localizations_zh.dart' is excluded by the scm ignore settings.
15:52:27.430 DEBUG: File '/Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/gen/l10n/okki_flutter_localizations.dart' is excluded by the scm ignore settings.
15:52:27.432 DEBUG: 'packages/okki-flutter/lib/di.dart' indexed with language 'dart'
15:52:27.437 DEBUG: File '/Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/di.module.dart' is excluded by the scm ignore settings.
15:52:27.437 DEBUG: 'packages/okki-flutter/lib/okki_flutter.dart' indexed with language 'dart'

15:52:29.952 DEBUG: Analyzer configured for mode: MANUAL
15:52:29.952 DEBUG: Analyzer configured for output mode: MACHINE
15:52:29.952 INFO: Analysing report from analysis-results.txt
15:52:29.953 INFO: Recording 7 issues
15:52:29.953 DEBUG: Recording issue for /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/okki_flutter.dart
15:52:29.953 WARN: File not included in SonarQube /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/okki_flutter.dart
15:52:29.954 DEBUG: Recording issue for /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/ARepository.dart
15:52:29.955 WARN: File not included in SonarQube /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/ARepository.dart
15:52:29.955 DEBUG: Recording issue for /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/ARepository.dart
15:52:29.955 WARN: File not included in SonarQube /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/ARepository.dart
15:52:29.955 DEBUG: Recording issue for /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/module/whatsapp_business/page/conversation_list_page.dart
15:52:29.955 DEBUG: Recording issue for /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/module/whatsapp_business/widget/audio_message.dart
15:52:29.955 DEBUG: Recording issue for /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/module/whatsapp_business_template/page/template_preview_page.dart
15:52:29.955 DEBUG: Recording issue for /Users/jiechic/WorkSpace/Projects/okmm/packages/okki-flutter/lib/src/utils/vcard_error_utils.dart
15:52:29.955 INFO: Sensor Dart analysis sensor [flutter] (done) | time=7ms
15:52:29.955 INFO: Sensor Flutter unit tests [flutter]
image

Questions

1、okki-flutter/lib/okki_flutter.dart was indexed with language 'dart' but Analysing result show 'File not included in SonarQube' 2、In addition to the file does not exist, there are 3 issues, but can not be found on sonar

jiechic commented 1 year ago

it's report sonar result on gitlab PR

zippy1978 commented 1 year ago

Hi @jiechic,

Could you try using your_module.sonar.sources and your_module.sonar.tests instead of your_module.sonar.projectBaseDir? I suspect files are not indexed properly during the analysis.

jiechic commented 1 year ago

it's use the same setting with main project setting, in the pr code , i can see new code image

jiechic commented 1 year ago

i test info for setting your_module.sonar.tests it's also no effect image image image

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity.

jiechic commented 1 year ago

have any update?

zippy1978 commented 1 year ago

Hi @jiechic,

Could you show the content of your manually generated analysis-results.txt ?

Ppito commented 11 months ago

Hello @jiechic,

beware, there is 2 differents things you need to understand. Result on sonar-scanner and result on Sonarqube.

Unlike all other languages managed by sonar, this plugin does not display your customized results. You need to configure your own custom rules on analysis_options.yaml for sonar-scanner to find your MANUAL report. But you also need to configure the same rules on your custom Quality Rules on Sonarqube, so that it can analyze the report send by sonar-scanner and process the results.

At least that's how I understood it.

Personally, I have configured my 72 custom rules in Sonarqube.

But I agree, on one of my PHP project, sonnar-scanner analyzes my project and I can specify a custom report in addition which is well present on Sonarqube.

jiechic commented 11 months ago

analysis-results.txt

Hi @jiechic,

Could you show the content of your manually generated analysis-results.txt ?

I'm upload a new analysis-results.txt for issue

jiechic commented 11 months ago

Hello @jiechic,

beware, there is 2 differents things you need to understand. Result on sonar-scanner and result on Sonarqube.

Unlike all other languages managed by sonar, this plugin does not display your customized results. You need to configure your own custom rules on analysis_options.yaml for sonar-scanner to find your MANUAL report. But you also need to configure the same rules on your custom Quality Rules on Sonarqube, so that it can analyze the report send by sonar-scanner and process the results.

At least that's how I understood it.

Personally, I have configured my 72 custom rules in Sonarqube.

But I agree, on one of my PHP project, sonnar-scanner analyzes my project and I can specify a custom report in addition which is well present on Sonarqube.

ths for answer i have a project is android it has custom rules use android lints but sonar havn't these lint ,then it also show lint result on pr result page。

image

image

Ppito commented 11 months ago

Okay, well, I don't know if that helps. In my case, I don't you MACHINE report mode, I using the LEGACY mode. And I run the Analyzer with the following command: dart analyze > analyzer_report.txt I do not analyze with flutter because the order of the message in the line result is not the same than dart. And this plugin can only read the dart order in LEGACY mode and not flutter. (Of course you need to have your own analysis_options.yaml, with flutter rules).

# Project identification
sonar.projectName=program
sonar.projectKey=program
sonar.projectVersion=1.0
sonar.qualitygate.wait=true
sonar.language=dart

# Encoding of the source code. Default is default system encoding.
sonar.sourceEncoding=UTF-8

# Source code location.
# Path is relative to the sonar-project.properties file. Defaults to .
# Use commas to specify more than one file/folder.
# It is good practice to add pubspec.yaml to the sources as the analyzer
# may produce warnings for this file as well.

sonar.modules=app,package1,package2,package3,package4

## app
app.sonar.projectBaseDir=app/program
app.sonar.sources=lib,pubspec.yaml,pubspec_overrides.yaml,analysis_options.yaml
app.sonar.exclusions=**/*.g.dart
app.sonar.tests=test
app.sonar.flutter.tests.reportPath=test-results/app-flutter-test-results.json
app.sonar.flutter.coverage.reportPath=coverage/lcov.info
app.sonar.dart.analyzer.mode=MANUAL
app.sonar.dart.analyzer.report.mode=LEGACY
app.sonar.dart.analyzer.report.path=analyzer_report.txt

# package1
package1.sonar.projectBaseDir=packages/package1
package1.sonar.sources=lib,pubspec.yaml,pubspec_overrides.yaml,analysis_options.yaml
package1.sonar.exclusions=**/*.g.dart
package1.sonar.tests=test
package1.sonar.flutter.tests.reportPath=test-results/package1-dart-test-results.json
package1.sonar.flutter.coverage.reportPath=coverage/lcov.info
package1.sonar.dart.analyzer.options.override=false
package1.sonar.dart.analyzer.mode=MANUAL
package1.sonar.dart.analyzer.report.mode=LEGACY
package1.sonar.dart.analyzer.report.path=analyzer_report.txt

# package2
package2.sonar.projectBaseDir=packages/package2
package2.sonar.sources=lib,pubspec.yaml,pubspec_overrides.yaml,analysis_options.yaml
package2.sonar.exclusions=**/*.g.dart
package2.sonar.tests=test
package2.sonar.flutter.tests.reportPath=test-results/package2-flutter-test-results.json
package2.sonar.flutter.coverage.reportPath=coverage/lcov.info
package2.sonar.dart.analyzer.options.override=false
package2.sonar.dart.analyzer.mode=MANUAL
package2.sonar.dart.analyzer.report.mode=LEGACY
package2.sonar.dart.analyzer.report.path=analyzer_report.txt

# package3
package3.sonar.projectBaseDir=packages/package3
package3.sonar.sources=lib,pubspec.yaml,pubspec_overrides.yaml,analysis_options.yaml
package3.sonar.exclusions=**/*.g.dart
package3.sonar.dart.analyzer.options.override=false
package3.sonar.dart.analyzer.mode=MANUAL
package3.sonar.dart.analyzer.report.mode=LEGACY
package3.sonar.dart.analyzer.report.path=analyzer_report.txt

# package4
package4.sonar.projectBaseDir=packages/package4
package4.sonar.sources=lib,pubspec.yaml,pubspec_overrides.yaml,analysis_options.yaml
package4.sonar.exclusions=**/*.g.dart
package4.sonar.tests=test
package4.sonar.flutter.tests.reportPath=test-results/package4-flutter-test-results.json
package4.sonar.dart.analyzer.options.override=false
package4.sonar.flutter.coverage.reportPath=coverage/lcov.info
package4.sonar.dart.analyzer.mode=MANUAL
package4.sonar.dart.analyzer.report.mode=LEGACY
package4.sonar.dart.analyzer.report.path=analyzer_report.txt

#sonar.dart.analyzer.options.override=false

# Analyzer mode
# Can be:
# - DETECT (attempt to detect automatically) - default
# - MANUAL (an existing report needs to be provided)
# - FLUTTER (flutter analyze)
# - DART (dart analyze)
# - DARTANALYZER (dartanalyzer)
#sonar.dart.analyzer.mode=MANUAL

# Allows reuse of an existing analyzer report when mode is MANUAL
# sonar.dart.analyzer.report.path=

# Analyzer report output mode
# Can be:
# - DETECT (attempt to detect automatically, requires Dart SDK on the PATH) - default
# - MACHINE (a new machine readable output that is available for Dart 2.12+)
# - LEGACY (attempts to parse human readable output from dart/flutter) - default
# sonar.dart.analyzer.report.mode=

This is my sonar configuration, the main application and 4 packages (everything is managed with melos).

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 90 days with no activity.

github-actions[bot] commented 7 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.