Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with sonar.language property #46

Closed
BalajiVM opened this issue Feb 4, 2016 · 11 comments
Closed

Issue with sonar.language property #46

BalajiVM opened this issue Feb 4, 2016 · 11 comments

Comments

@BalajiVM
Copy link

BalajiVM commented Feb 4, 2016

Multi-language is not supporting with this package and web language is not recognizing. Please help us by providing the solution for this.

12:18:44.722 INFO - Language is forced to null
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 12.288s
Final Memory: 18M/543M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must install a plugin that supports the language 'null'
ERROR:
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Warning: The following error occured while trying to upload to sonar: Error Used --force, continuing.

@mdasberg
Copy link
Owner

mdasberg commented Feb 4, 2016

Hi,

You can specify the language by adding the option 'language' like this:

 karmaSonar: {
    options: {
       language: 'put the language here'
   },
   yourTarget: {}
}

Or use the sonar default language by excluding it like this:

 karmaSonar: {
    options: {
       excludedProperties: ['sonar.language']
   },
   yourTarget: {}
}

To see with which parameters sonar would have run you can use:

karmaSonar: {
    options: {
       dryRun: true
   },
   yourTarget: {}
}

@BalajiVM
Copy link
Author

BalajiVM commented Feb 4, 2016

Hi mdasberg,

This is my configuration

karmaSonar: {
options: {
defaultOutputDir: '.tmp/sonar/custom_options/',
sourceEncoding: 'UTF-8',
instance: {
hostUrl : 'sonar URL',
login: 'user1',
password: 'test',
jdbcUrl : 'JDBC URL',
jdbcUsername: 'sonarrunner',
jdbcPassword: 'sonarrunner'
}
},
sonar: {
project: {
key: 'sonar:grunt-sonar-runner:myp:0.1',
name: 'UI_SONAR_TEST',
version: '0.1'
},
paths: [{
cwd: '.',
src: 'app',
test: 'test',
reports: {
unit:'build//result.xml',
coverage: 'build/reports/coverage/
/lcov.info'
}
}],
exclusions: []
}
}

my requirement is to analyse the js,css and html file in a single run
if i dont mention any language it is analysing only js files (default) and if i use "null" as a language its not recognising any language and it threw an error as mentioned earlier.
its not recognising any languages other than js, even if i mention web/css as a language

I tried all the above mentioned options ,with no success.
Let me know if i need to do any other configuration changes.

@BalajiVM
Copy link
Author

BalajiVM commented Feb 4, 2016

Hi mdasberg,

This is my configuration

karmaSonar: {
options: {
defaultOutputDir: '.tmp/sonar/custom_options/',
sourceEncoding: 'UTF-8',
instance: {
hostUrl : 'sonar URL',
login: 'user1',
password: 'test',

jdbcUrl : 'JDBC URL',
jdbcUsername: 'sonarrunner',
jdbcPassword: 'sonarrunner'
}
},
sonar: {
project: {
key: 'sonar:grunt-sonar-runner:myp:0.1',
name: 'UI_SONAR_TEST',
version: '0.1'
},
paths: [{
cwd: '.',
src: 'app',
test: 'test',
reports: {
unit:'build/
/result.xml', coverage: 'build/reports/coverage//lcov.info'
}
}],
exclusions: []
}
}

my requirement is to analyse the js,css and html file in a single run
if i dont mention any language it is analysing only js files (default) and
if i use "null" as a language its not recognising any language and it threw
an error as mentioned earlier.
its not recognising any languages other than js, even if i mention web/css
as a language

I tried all the above mentioned options ,with no success.
Let me know if i need to do any other configuration changes.

On Thu, Feb 4, 2016 at 6:17 PM, Mischa Dasberg [email protected]
wrote:

Hi,

You can specify the language by adding the option 'language' like this:

karmaSonar: {
options: {
language: 'put the language here'
},
yourTarget: {}
}

Or use the sonar default language by excluding it like this:

karmaSonar: {
options: {
excludedProperties: ['sonar.language']
},
yourTarget: {}
}

To see with which parameters sonar would have run you can use:

karmaSonar: {
options: {
dryRun: true
},
yourTarget: {}
}


Reply to this email directly or view it on GitHub
#46 (comment)
.

With Regards,

Balaji.V

+91 - 9700221565 / 8792995420

@mdasberg
Copy link
Owner

mdasberg commented Feb 4, 2016

When providing null as language, it should fail, as there is no plugin installed with identifier for language null.

When I run with the following configuration:

karmaSonar: {
   options: {
       language: 'web'
       }
      ...
}        

I get the following output:

14:41:12.394 INFO  - -------------  Scan Grunt-karma-sonar plugin master
14:41:12.399 INFO  - Load module settings
14:41:12.527 INFO  - Language is forced to web
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 3.194s
Final Memory: 19M/623M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: You must install a plugin that supports the language 'web'

Which is what I expect, as I don't have a plugin installed in my sonar instance to handle language 'web'
In order to get this to work I need to install the plugin.

What is the output when you use language: 'web'?

@BalajiVM
Copy link
Author

BalajiVM commented Feb 4, 2016

I use"null" as mentioned in the documentation,
options.language
Type: String Default: 'js'
Should be the sonar.property language (Starting with SonarQube 4.2, multi-language projects are supported. To enable this, set the value to null)
Note: "null" is recognizing well in other package grunt-sonar-runner.

We are using sonarqube 4.5.6

If i place web as a language, it is not recognizing any file formats.

Output:

13:55:37.328 INFO - 0 files indexed
13:55:38.952 INFO - Base dir: /appl/JenkinsWS/workspace/MyProduct/buildtestUI/.tmp/sonar/custom_options
13:55:38.953 INFO - Working dir: /appl/JenkinsWS/workspace/MyProduct/buildtestUI/.tmp/sonar/custom_options/.sonar
13:55:38.953 INFO - Source paths: src
13:55:38.953 INFO - Test paths: test
13:55:38.954 INFO - Source encoding: UTF-8, default locale: en_GB
13:55:38.954 INFO - Index files
13:55:38.955 INFO - Excluded sources:
13:55:38.956 INFO -
13:55:39.184 INFO - 0 files indexed

@mdasberg
Copy link
Owner

mdasberg commented Feb 4, 2016

can you try the exclude option?

 karmaSonar: {
    options: {
       excludedProperties: ['sonar.language']
   },
   yourTarget: {}
}

I found the issue, will create a new release

@mdasberg
Copy link
Owner

mdasberg commented Feb 4, 2016

@BalajiVM try [email protected]

@BalajiVM
Copy link
Author

BalajiVM commented Feb 5, 2016

Hi mdasberg,

If i assign "null" to language, it is indexing the all the files but it is not doing any analysis. Even though i assign "null', it is analyzing only js files and loading only js profile from sonarqube.

if assign "web" to language, it is not indexing the files and i am getting following output

04:15:34.744 INFO - Load module settings
04:15:35.617 INFO - Language is forced to web
04:15:35.633 INFO - Loading rules...
04:15:36.750 INFO - Loading rules done: 1117 ms
04:15:36.832 INFO - Configure Maven plugins
04:15:37.053 INFO - Compare to previous analysis (2016-02-05)
04:15:37.070 INFO - Compare over 30 days (2016-01-06, analysis of 2016-02-04 11:16:05.703)
04:15:37.073 INFO - No quality gate is configured.
04:15:37.632 WARN - Accessing the filesystem before the Sensor phase is deprecated and will not be supported in the future. Please update your plugin.
04:15:37.632 INFO - Index files
04:15:37.666 INFO - Excluded sources:
04:15:37.667 INFO -
04:15:38.366 INFO - 0 files indexed
04:15:38.367 WARN - Accessing the filesystem before the Sensor phase is deprecated and will not be supported in the future. Please update your plugin.
04:15:38.368 INFO - Index files
04:15:38.369 INFO - Excluded sources:
04:15:38.370 INFO -
04:15:38.508 INFO - 0 files indexed
04:15:40.160 INFO - Base dir: /appl/JenkinsWS/workspace/MyProduct/buildtestUI/.tmp/sonar/custom_options
04:15:40.160 INFO - Working dir: /appl/JenkinsWS/workspace/MyProduct/buildtestUI/.tmp/sonar/custom_options/.sonar
04:15:40.161 INFO - Source paths: src
04:15:40.161 INFO - Test paths: test
04:15:40.161 INFO - Source encoding: UTF-8, default locale: en_GB
04:15:40.162 INFO - Index files
04:15:40.162 INFO - Excluded sources:
04:15:40.162 INFO -
04:15:40.389 INFO - 0 files indexed
04:15:40.391 INFO - Quality profile for web: Sonar way

@BalajiVM
Copy link
Author

BalajiVM commented Feb 5, 2016

Hi mdasberg,

Now it is working after a code modification in sonar.js file

copy: function (callback) {
grunt.verbose.writeln('Copying files to working directory [' + sonarOptions.defaultOutputDir + ']');
var sourceGlobs = [],
testGlobs = [];

                        data.paths.forEach(function (p) {
                            var cwd = p.cwd ? p.cwd : '.';
                            **sourceGlobs.push({cwd: cwd + path.sep + p.src, src: '**/*.*'});**
                            //sourceGlobs.push({cwd: cwd + path.sep + p.src, src: '**/*.js'});  **-----> REPLACE .js with .* then it will recognize all the formats**
                            testGlobs.push({cwd: cwd + path.sep + p.test, src: '**/*.js'});
                            testGlobs.push({cwd: cwd + path.sep + p.test, src: '**/*.feature'});
                        });

and

one more modification is as below

files.forEach(function (file) {
var destinationDirectory = defaultOutputDir + path.sep + targetDir;
var fileDirectory = path.dirname(file);
if (fileDirectory !== '.') {
destinationDirectory = destinationDirectory + path.sep + fileDirectory;
}
fs.mkdirpSync(destinationDirectory);
var source = path.resolve(g.cwd, file);
var extension = path.extname(file);
var destination;
if (targetDir === 'test') {
var base = path.basename(file, extension);
if(extension === '.js') {
destination = destinationDirectory + path.sep + path.basename(base.replace(/./g, '') + extension);
} **else if(extension === '.css') {
destination = destinationDirectory + path.sep + path.basename(base.replace(/./g, '
') + extension);
} else if(extension === '.html') {
destination = destinationDirectory + path.sep + path.basename(base.replace(/./g, '
') + extension);**_
} else if(extension === '.feature') {
destination = destinationDirectory + path.sep + path.basename(base.concat(extension).replace(/./g, '_') + '.js');
}
} else {
destination = destinationDirectory + path.sep + path.basename(file);
}

            fs.copySync(source, destination, {replace: true});
        });

@mdasberg
Copy link
Owner

you want to include css and html files from the test dir?

@mdasberg
Copy link
Owner

mdasberg commented Mar 2, 2016

@BalajiVM should be fixed in version 0.2.22

@mdasberg mdasberg closed this as completed Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants