-
Notifications
You must be signed in to change notification settings - Fork 10
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
[suricate] update sonar project metrics and new project coverage #45
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<div class="grid-stack-item-content-inner"> | ||
<a href="{{sonarConfigUrl}}/portfolio?id={{SURI_PROJECT_KEY}}" target="_blank"> | ||
<div class="fullwidget"> | ||
<div class="grid-stack-item-content-inner"> | ||
<h1 class="title">{{SURI_TITLE}}</h1> | ||
<ul> | ||
{{#results}} | ||
<li> | ||
<span class="label">{{title}}</span> | ||
<span class="value">{{value}}</span> | ||
</li> | ||
{{/results}} | ||
</ul> | ||
<i class="fa fa-heartbeat icon-background"></i> | ||
</div> | ||
</div> | ||
</a> | ||
</div> | ||
<div class="sonarqube"></div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
name: Metrics | ||
description: Display the selected Sonar metrics of a new code in an application | ||
technicalName: sonar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technical name should be more precise (and unique), something like |
||
delay: 500 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the image of the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
widgetParams: | ||
- | ||
name: 'SURI_TITLE' | ||
description: 'Widget title' | ||
type: TEXT | ||
usageExample: 'My title' | ||
required: true | ||
- | ||
name: 'SURI_PROJECT_KEY' | ||
description: 'Project key' | ||
type: TEXT | ||
usageExample: 'com.project.key:ProjectName' | ||
required: true | ||
- | ||
name: 'SURI_METRICS' | ||
description: 'Metrics to display' | ||
type: MULTIPLE | ||
possibleValuesMap: | ||
- | ||
jsKey: 'new_line_coverage' | ||
value: 'Lines of code' | ||
- | ||
jsKey: 'new_lines_to_cover' | ||
value: 'Lines to Cover' | ||
- | ||
jsKey: 'new_uncovered_lines' | ||
value: 'Uncovered Lines' | ||
- | ||
jsKey: 'new_coverage' | ||
value: 'Coverage on New Code(%)' | ||
- | ||
jsKey: 'new_conditions_to_cover' | ||
value: 'Conditions to Cover' | ||
- | ||
jsKey: 'new_uncovered_conditions' | ||
value: 'Unconver conditions' | ||
required: true | ||
- | ||
name: 'SURI_BRANCH' | ||
description: 'Branch name, if user provides both branch and pull request, the branch takes precedence.' | ||
type: TEXT | ||
usageExample: 'My branch' | ||
required: false | ||
- | ||
name: 'SURI_PULL_REQUEST' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation should be fixed (I know it is not fixed in every widget) |
||
description: 'Merge/Pull Request Number' | ||
type: TEXT | ||
usageExample: '111' | ||
required: false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2012-2021 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
function run() { | ||
var data = {}; | ||
var branch = (SURI_BRANCH != null ? "branch=" | ||
+ SURI_BRANCH + "&" : (SURI_PULL_REQUEST != null ? "pullRequest=" + SURI_PULL_REQUEST + "&" : "")); | ||
data.results = []; | ||
|
||
// added to remove the trailing slash from the URL if present | ||
data.sonarConfigUrl = (WIDGET_CONFIG_SONAR_URL) ? WIDGET_CONFIG_SONAR_URL.replace(/\/+$/, '') : WIDGET_CONFIG_SONAR_URL; | ||
|
||
var response = JSON.parse( | ||
Packages.get(data.sonarConfigUrl + "/api/measures/component?" + branch | ||
+"component=" + SURI_PROJECT_KEY + "&additionalFields=metrics&metricKeys=" + SURI_METRICS, | ||
"Authorization", "Basic " + Packages.btoa(WIDGET_CONFIG_SONAR_TOKEN + ":"))); | ||
|
||
|
||
if (response && response.component && response.component.measures && response.component.measures.length > 0) { | ||
response.component.measures.forEach(function(measure) { | ||
data.results.push({ | ||
title: response.metrics.filter(function(metric) { | ||
if (metric.key == measure.metric) { | ||
return metric; | ||
} | ||
})[0].name, | ||
value:measure.period.value, | ||
|
||
}); | ||
}); | ||
|
||
} | ||
|
||
return JSON.stringify(data); | ||
} |
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New widget is only related to coverage, right? If yes, update the description so it specifies it only display Sonar coverage metrics