stepstone-tech / sonar-coldfusion

SonarQube ColdFusion Analyzer
Apache License 2.0
24 stars 18 forks source link

Zero output for all metrics in SonarQube using CF plugin #7

Closed evgeniagusakova closed 7 years ago

evgeniagusakova commented 7 years ago

I'm trying to use cf plugin in the following way (all env. variables are set and valid): LANG=cf

      ${scannerHome}/bin/sonar-scanner \
        -X \
        -Dsonar.projectKey=${PROJECT_NAME} \
        -Dsonar.projectName=${PROJECT_NAME} \
        -Dsonar.projectDescription=${PROJECT_DESCRIPTION} \
        -Dsonar.branch=${BRANCH} \
        -Dsonar.projectVersion=1.0 \
        -Dsonar.language=${LANG} \
        -Dsonar.scm.disabled=true \
        -Dsonar.projectBaseDir=${SONAR_WORKDIR} \
        -Dsonar.sources=${SONAR_WORKDIR}

And got the following output:

18:37:57.355 INFO: Project root configuration file: NONE
18:37:57.381 INFO: SonarQube Scanner 2.8
18:37:57.381 INFO: Java 1.8.0_111 Oracle Corporation (64-bit)
18:37:57.381 INFO: Linux 3.13.0-100-generic amd64
18:37:57.589 DEBUG: keyStore is : 
18:37:57.589 DEBUG: keyStore type is : jks
18:37:57.589 DEBUG: keyStore provider is : 
18:37:57.589 DEBUG: init keystore
18:37:57.589 DEBUG: init keymanager of type SunX509
18:37:57.617 INFO: User cache: /var/lib/jenkins/.sonar/cache
18:37:57.617 DEBUG: Extract sonar-scanner-api-batch in temp...
18:37:57.633 DEBUG: Get bootstrap index...
18:37:57.633 DEBUG: Download: http://localhost:9000/batch_bootstrap/index
18:37:57.695 DEBUG: Get bootstrap completed
18:37:57.696 DEBUG: Create isolated classloader...
18:37:57.705 DEBUG: Start temp cleaning...
18:37:57.713 DEBUG: Temp cleaning done
18:37:57.713 DEBUG: Execution getVersion
18:37:57.729 DEBUG: Execution start
18:37:58.031 DEBUG: Publish global mode
18:37:58.192 INFO: Load global repositories
18:37:58.248 DEBUG: GET 200 http://localhost:9000/batch/global | time=52ms
18:37:58.314 INFO: Load global repositories (done) | time=123ms
18:37:58.332 INFO: User cache: /var/lib/jenkins/.sonar/cache
18:37:58.531 INFO: Load plugins index
18:37:58.535 DEBUG: GET 200 http://localhost:9000/deploy/plugins/index.txt | time=2ms
18:37:58.535 INFO: Load plugins index (done) | time=4ms
18:37:58.535 DEBUG: Load plugins
18:37:58.576 DEBUG: Load plugins (done) | time=41ms
18:37:58.590 DEBUG: API compatibility mode is enabled on plugin C# [csharp] (built with API lower than 5.2)
18:37:58.591 DEBUG: API compatibility mode is enabled on plugin Git [scmgit] (built with API lower than 5.2)
18:37:58.593 DEBUG: API compatibility mode is enabled on plugin SVN [scmsvn] (built with API lower than 5.2)
18:37:58.705 DEBUG: Plugins:
18:37:58.705 DEBUG:   * C# 5.3.1 (csharp)
18:37:58.705 DEBUG:   * Java 4.0 (java)
18:37:58.705 DEBUG:   * Git 1.2 (scmgit)
18:37:58.705 DEBUG:   * ColdFusion 1.0.0 (coldfusion)
18:37:58.706 DEBUG:   * SVN 1.3 (scmsvn)
18:37:58.706 DEBUG:   * JavaScript 2.14 (javascript)
18:37:58.726 DEBUG: Execution getVersion
18:37:58.726 INFO: SonarQube server 6.1
18:37:58.726 INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
18:37:58.727 DEBUG: Work directory: /var/lib/jenkins/workspace/xxxx_sonar/.sonar
18:37:58.727 DEBUG: Execution getVersion
18:37:58.727 DEBUG: Execution execute
18:37:59.121 INFO: Process project properties
18:37:59.125 DEBUG: Process project properties (done) | time=4ms
18:37:59.309 INFO: Load project repositories
18:37:59.350 DEBUG: GET 200 http://localhost:9000/batch/project.protobuf?key=PROJECT-web%3Amaster | time=40ms
18:37:59.481 INFO: Load project repositories (done) | time=172ms
18:37:59.551 DEBUG: Available languages:
18:37:59.552 DEBUG:   * C# => "cs"
18:37:59.552 DEBUG:   * Java => "java"
18:37:59.552 DEBUG:   * ColdFusion => "cf"
18:37:59.552 DEBUG:   * JavaScript => "js"
18:37:59.555 INFO: Load quality profiles
18:37:59.581 DEBUG: GET 200 http://localhost:9000/api/qualityprofiles/search.protobuf?projectKey=PROJECT-web%3Amaster | time=26ms
18:37:59.588 INFO: Load quality profiles (done) | time=34ms
18:37:59.594 INFO: Load active rules
18:37:59.609 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=cf-sonar-way-71591&p=1&ps=500 | time=15ms
18:37:59.650 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=cs-sonar-way-43387&p=1&ps=500 | time=16ms
18:37:59.670 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=java-sonar-way-90853&p=1&ps=500 | time=20ms
18:37:59.685 DEBUG: GET 200 http://localhost:9000/api/rules/search.protobuf?f=repo,name,severity,lang,internalKey,templateKey,params,actives&activation=true&qprofile=js-sonar-way-66261&p=1&ps=500 | time=14ms
18:37:59.689 INFO: Load active rules (done) | time=95ms
18:37:59.700 DEBUG: SCM Step is disabled by configuration
18:37:59.700 INFO: Publish mode
18:37:59.700 DEBUG: Start recursive analysis of project modules
18:37:59.701 INFO: -------------  Scan <PROJECT NAME> master
18:37:59.792 INFO: Language is forced to cf
18:37:59.794 INFO: Load server rules
18:37:59.858 DEBUG: GET 200 http://localhost:9000/api/rules/list.protobuf | time=64ms
18:37:59.873 INFO: Load server rules (done) | time=79ms
18:37:59.969 DEBUG: Initializers : 
18:37:59.969 INFO: Base dir: /var/lib/jenkins/workspace/xxxx_sonar
18:37:59.969 INFO: Working dir: /var/lib/jenkins/workspace/xxxx_sonar/.sonar
18:37:59.971 INFO: Source paths: .
18:37:59.971 INFO: Source encoding: UTF-8, default locale: en_US
18:37:59.971 INFO: Index files
18:37:59.980 DEBUG: Declared extensions of language C# were converted to sonar.lang.patterns.cs : **/*.cs
18:37:59.980 DEBUG: Declared extensions of language Java were converted to sonar.lang.patterns.java : **/*.java,**/*.jav
18:37:59.980 DEBUG: Declared extensions of language ColdFusion were converted to sonar.lang.patterns.cf : **/*.cfc,**/*.cfm
18:37:59.980 DEBUG: Declared extensions of language JavaScript were converted to sonar.lang.patterns.js : **/*.js
18:37:59.995 DEBUG: Language of file 'create_bsns_acc_from_pvt.cfm' is detected to be 'cf'
18:38:00.043 DEBUG: Language of file 'accntLimitations.cfm' is detected to be 'cf'
<SKIPPED SAME OUTPUT FOR OTHER FILES>
18:38:00.267 DEBUG: Language of file 'Application.cfc' is detected to be 'cf'
18:38:00.919 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/xxxx_sonar'cf'
detected to be 'cf'
18:38:02.100 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project

18:38:02.104 DEBUG: Sensors : Lines Sensor -> SCM Sensor -> XmlFileSensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
18:38:02.104 INFO: Sensor Lines Sensor
18:38:02.328 INFO: Sensor Lines Sensor (done) | time=224ms
18:38:02.328 INFO: Sensor SCM Sensor
18:38:02.328 INFO: SCM Publisher is disabled
18:38:02.328 INFO: Sensor SCM Sensor (done) | time=0ms
18:38:02.328 INFO: Sensor XmlFileSensor
18:38:02.333 INFO: Sensor XmlFileSensor (done) | time=5ms
18:38:02.334 INFO: Sensor Zero Coverage Sensor
18:38:02.476 INFO: Sensor Zero Coverage Sensor (done) | time=142ms
18:38:02.476 INFO: Sensor Code Colorizer Sensor
18:38:02.500 INFO: Sensor Code Colorizer Sensor (done) | time=24ms
18:38:02.500 INFO: Sensor CPD Block Indexer
18:38:02.500 INFO: DefaultCpdBlockIndexer is used for cf
18:38:02.500 DEBUG: No CpdMapping for language cf
18:38:02.500 INFO: Sensor CPD Block Indexer (done) | time=0ms
18:38:02.500 INFO: Calculating CPD for 0 files
18:38:02.505 INFO: CPD calculation finished
18:38:03.676 INFO: Analysis report generated in 1105ms, dir size=10 MB
18:38:04.582 INFO: Analysis reports compressed in 905ms, zip size=2 MB
18:38:04.582 INFO: Analysis report generated in /var/lib/jenkins/workspace/xxxx_sonar/.sonar/batch-report
18:38:04.582 DEBUG: Upload report
18:38:04.892 DEBUG: POST 200 http://localhost:9000/api/ce/submit?projectKey=PROJECT-web&projectName=PROJECT-web&projectBranch=master | time=309ms
18:38:04.893 INFO: Analysis report uploaded in 311ms
18:38:04.894 INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/PROJECT-web:master
18:38:04.894 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
18:38:04.894 INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AVghLxlEfhtlqBqZ6uEc
18:38:04.902 DEBUG: Report metadata written to /var/lib/jenkins/workspace/xxxx_sonar/.sonar/report-task.txt
18:38:04.902 DEBUG: Post-jobs : 
18:38:04.907 INFO: Task total time: 6.176 s
18:38:04.907 INFO: ------------------------------------------------------------------------
18:38:04.907 INFO: EXECUTION SUCCESS
18:38:04.907 INFO: ------------------------------------------------------------------------
18:38:04.907 INFO: Total time: 7.575s
18:38:05.003 INFO: Final Memory: 45M/258M
18:38:05.003 INFO: ------------------------------------------------------------------------
18:38:05.003 DEBUG: Execution getVersion
18:38:05.003 DEBUG: Execution stop

Sonar Server version: 6.1 Sonar Runner: 2.8

I checked same configuration with JAVA project (LANG=java) and for the first view it looks OK.

I do not sure is it really bug in plugin or misconfiguration, could you please advice?

screen shot 2016-11-01 at 10 45 02 pm
mpaluchowski commented 7 years ago

The metrics are correct in the sense, that the ColdFusion plugin doesn't (yet) show LOC nor Duplications. There's a plan to cover those via issue #1.

As for the Bugs, Vulnerabilities and Code Smells---these might be correct, depending on the actual code you were scanning. Perhaps there are no issues to report :)

Note that you shouldn't need to force a specific language for your project, because the analyzer will automatically detect the language of each file, based on its extension. In other words, you can skip the sonar.language property.

evgeniagusakova commented 7 years ago

Thank you for your replay!

Could you please provide my .cfm file with has bugs/issues in it, and I'll try to check settings with bugged file?

I test with:

cp /bin/ls /path/to/project/123.cfm

2. added file with random text, test.cfm - also not valid cfm file

And re-run Sonar.

Binary ls is not valid cfm file but:

17:45:01.047 DEBUG: Language of file '123.cfm' is detected to be 'cf'
17:45:01.047 WARN: Invalid character encountered in file /var/lib/jenkins/workspace/xxxx_sonar/123.cfm at line 1 for encoding US-ASCII. Please fix file content or configure the encoding to be used using property 'sonar.sourceEncoding'.

Still have 0 in all output metrics.

mpaluchowski commented 7 years ago

The plugin will find issues in ColdFusion code files. What I see you're trying to do is running the scan on /bin/ls which is a binary file that, obviously, the plugin will not be able to scan, hence no results.

You could find good files for testing in CFLint's test suite.