-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Lukasz Rajchel edited this page Feb 2, 2021
·
7 revisions
cls
$res = Invoke-RestMethod 'https://sonarcloud.io/api/rules/search?languages=cs&organization=sonarsource&ps=500&s=key'
$res.rules | ? { $_.key -notlike 'common-cs*' } | % {
$key = (($_.key -replace 'csharpsquid:', '') -replace 'roslyn.sonaranalyzer.security.cs:', '')
$name = '{0}:{1}' -f $key, (($_.name -replace '"', '') -replace ' ', ' ')
'public const string {0} = "{1}";' -f $key, $name
}
- Go to StyleCopAnalyzers Status page
- Run the following script and copy the extracted rules from the console (there may be some trash at the begining of each line - nothing that simple text replace couldn't handle).
jQuery('#renderedDiagnostics tr').each(function() {
var id = $(this).children('td:eq(1)').text().trim();
var name = $(this).children('td:eq(2)').text().trim();
console.log('public const string ' + id + ' = "' + id + ':' + name + '";');
});
- Install local SonarQube
- Install CodeCracker for C# and FxCop plugins.
- Go to Rules section, mark C# as Language and specific analyzer as Repository, expand the list until all rules are visible. Restart SonarQube if needed.
- jQueryfy the page.
- Run the following script and copy the extracted rules from the console (there may be some trash at the begining of each line - nothing that simple text replace couldn't handle).
jQuery('.coding-rule').each(function() {
var text = jQuery(this).find('a').text().replace(/"/g, '').replace(/ /g, ' ')
.replace(/ {...}/g, '{...}').trim();
var regex = /(CA\d+): (.*)/
if (regex.test(text)) {
var textMatch = text.match(regex);
var id = textMatch[1];
var name = textMatch[2];
console.log('public const string ' + id + ' = "' + id + ':' + name + '";');
}
});
This project has not been updated in couple of years. It's probably dead.