Skip to content

Commit 1bf8476

Browse files
committed
Merge branch 'dev' of
https://github.com/CfrancCyrille/sonar-icode-cnes-plugin into dev # Conflicts: # src/main/js/components/MetricsSummaryTab/MetricsSummaryTab.js
2 parents e83fe80 + 24908a4 commit 1bf8476

File tree

68 files changed

+2830
-782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2830
-782
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ notifications:
2020

2121
addons:
2222
sonarcloud:
23-
organization: "AT-NicolasMetivier"
23+
organization: "lequal"
2424
token:
2525
secure: projettest # encrypted value of your token
2626
# Script to execute.
2727

2828
script:
29-
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=at-nicolasmetivier-github -Dsonar.login=d217f2a7b06684f932ec72bbc294e27e87d9c361
29+
- mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=lequal -Dsonar.login=181e22946e5e05302ceb4513dae3dcc9f7161f2f

CONTRIBUTING.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Contributing to sonar-icode-cnes-plugin
2+
3+
First off, thanks for taking the time to contribute!
4+
5+
The following is a set of guidelines for contributing to sonar-icode-cnes-plugin, which are hosted in the [Lequal Organization](https://github.com/lequal) on GitHub. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
6+
7+
#### Table Of Contents
8+
9+
[Code of Conduct](#code-of-conduct)
10+
11+
[How Can I Contribute?](#how-can-i-contribute)
12+
* [Reporting Bugs](#reporting-bugs)
13+
* [Suggesting Enhancements](#suggesting-enhancements)
14+
* [Pull Requests](#pull-requests)
15+
16+
[Git Commit Messages](#git-commit-messages)
17+
18+
## Code of Conduct
19+
20+
This project and everyone participating in it is governed by the [Lequal Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [[email protected]](mailto:[email protected]).
21+
22+
## How Can I Contribute?
23+
24+
### Reporting Bugs
25+
26+
Before creating bug reports, please check if the problem has already been reported.
27+
28+
#### How Do I Submit A (Good) Bug Report?
29+
30+
Bugs are tracked as [GitHub issues](https://guides.github.com/features/issues/). Provide information by filling [the template](ISSUE_TEMPLATE.md).
31+
32+
Explain the problem and include additional details to help maintainers reproduce the problem:
33+
34+
* **Use a clear and descriptive title** for the issue to identify the problem.
35+
* **Describe the exact steps which reproduce the problem** in as many details as possible. When listing steps, don't just say what you did, but explain how you did it.
36+
* **Provide specific examples to demonstrate the steps**. Include links to files or GitHub projects, which you use in those examples.
37+
* **Explain which behavior you expected and describe the behavior you observed** after following the steps and point out what exactly is the problem with that behavior.
38+
* **Include screenshots and animated GIFs** which show you following the described steps and clearly demonstrate the problem. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux.
39+
* **If you're reporting that the plugin crashed**, include a crash report with a stack trace from the operating system.
40+
41+
Provide more context by answering these questions:
42+
43+
* **Did the problem start happening recently** (e.g. after updating to a new version of the plugin or SonarQube) or was this always a problem?
44+
* If the problem started happening recently, **can you reproduce the problem in an older version?** What's the most recent version in which the problem doesn't happen? You can download older versions from [the releases page](https://github.com/lequal/sonar-icode-cnes-plugin/releases).
45+
* **Can you reliably reproduce the issue?** If not, provide details about how often the problem happens and under which conditions it normally happens.
46+
47+
Include details about your configuration and environment:
48+
49+
* **Which SonarQube version are you using?** You can get the exact version at the bottom of your SonarQube instance.
50+
51+
### Suggesting Enhancements
52+
53+
Before creating enhancement suggestions, please check if the problem has already been suggested.
54+
55+
#### How Do I Submit A (Good) Enhancement Suggestion?
56+
57+
Enhancement suggestions are tracked as [GitHub issues](https://guides.github.com/features/issues/). To submit en enhancement suggestion, create an issue and provide the following information:
58+
59+
* **Use a clear and descriptive title** for the issue to identify the suggestion.
60+
* **Provide a step-by-step description of the suggested enhancement** in as many details as possible.
61+
* **Provide specific examples to demonstrate the steps**. Include copy/pasteable snippets which you use in those examples, as [Markdown code blocks](https://help.github.com/articles/markdown-basics/#multiple-lines).
62+
* **Describe the current behavior** and **explain which behavior you expected to see instead** and why.
63+
* **Include screenshots and animated GIFs** which help you demonstrate the steps or point out the part of Atom which the suggestion is related to. You can use [this tool](https://www.cockos.com/licecap/) to record GIFs on macOS and Windows, and [this tool](https://github.com/colinkeenan/silentcast) or [this tool](https://github.com/GNOME/byzanz) on Linux.
64+
* **Explain why this enhancement would be useful**
65+
* **Specify which version you're using.**
66+
* **Specify the SonarQube version you're using.** The SonarQube version is mentionned at the bottom of the web page.
67+
68+
### Pull Requests
69+
70+
* Fill in [the required template](PULL_REQUEST_TEMPLATE.md)
71+
* Do not include issue numbers in the PR title
72+
* Include screenshots and animated GIFs in your pull request whenever possible.
73+
* Follow the Java styleguides.
74+
75+
## Git Commit Messages
76+
77+
* Use the present tense ("Add feature" not "Added feature")
78+
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
79+
* Limit the first line to 72 characters or less
80+
* Reference issues and pull requests liberally after the first line
81+
* When only changing documentation, include `[ci skip]` in the commit description

pom.xml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<slf4j.version>1.7.25</slf4j.version>
4747
<junit.version>4.12</junit.version>
4848
<project.key>icode</project.key>
49-
<sonar.sources>src/main/java,src/main/js</sonar.sources>
49+
<sonar.sources>src/main/java</sonar.sources>
5050
</properties>
5151

5252
<dependencies>
@@ -85,6 +85,19 @@
8585

8686
<build>
8787
<plugins>
88+
<plugin>
89+
<groupId>org.jacoco</groupId>
90+
<artifactId>jacoco-maven-plugin</artifactId>
91+
<version>0.7.6.201602180812</version>
92+
<executions>
93+
<execution>
94+
<id>prepare-agent</id>
95+
<goals>
96+
<goal>prepare-agent</goal>
97+
</goals>
98+
</execution>
99+
</executions>
100+
</plugin>
88101
<plugin>
89102
<groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
90103
<artifactId>sonar-packaging-maven-plugin</artifactId>

src/main/java/fr/cnes/sonarqube/plugins/icode/languages/ICodeLanguage.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,29 @@ private String[] filterEmptyStrings(String[] stringArray) {
7070
}
7171
return nonEmptyStrings.toArray(new String[nonEmptyStrings.size()]);
7272
}
73+
74+
@Override
75+
public int hashCode() {
76+
final int prime = 31;
77+
int result = super.hashCode();
78+
result = prime * result + ((settings == null) ? 0 : settings.hashCode());
79+
return result;
80+
}
81+
82+
@Override
83+
public boolean equals(Object obj) {
84+
if (this == obj)
85+
return true;
86+
if (!super.equals(obj))
87+
return false;
88+
if (getClass() != obj.getClass())
89+
return false;
90+
ICodeLanguage other = (ICodeLanguage) obj;
91+
if (settings == null) {
92+
if (other.settings != null)
93+
return false;
94+
} else if (!settings.equals(other.settings))
95+
return false;
96+
return true;
97+
}
7398
}

src/main/java/fr/cnes/sonarqube/plugins/icode/languages/ICodeQualityProfile.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@
2020

2121
import org.sonar.api.profiles.ProfileDefinition;
2222
import org.sonar.api.profiles.RulesProfile;
23-
import org.sonar.api.rules.Rule;
2423
import org.sonar.api.utils.ValidationMessages;
2524

2625
/**
2726
* Default Quality profile for the projects having files of language "icode"
2827
*/
2928
public final class ICodeQualityProfile extends ProfileDefinition {
30-
@Override
31-
public RulesProfile createProfile(ValidationMessages validation) {
32-
RulesProfile profile = RulesProfile.create("ICode Rules", ICodeLanguage.KEY);
29+
static final String I_CODE_RULES_PROFILE_NAME = "ICode Rules";
3330

34-
return profile;
31+
@Override
32+
public RulesProfile createProfile(ValidationMessages validation) {
33+
return RulesProfile.create(I_CODE_RULES_PROFILE_NAME, ICodeLanguage.KEY);
3534
}
3635
}

src/main/java/fr/cnes/sonarqube/plugins/icode/measures/ComputeModuleF77CyclomaticStatistics.java

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818
package fr.cnes.sonarqube.plugins.icode.measures;
1919

20-
//import static fr.cnes.sonarqube.plugins.icode.measures.ICodeMetrics.DBG;
2120
import static fr.cnes.sonarqube.plugins.icode.measures.ICodeMetricsF77Cyclomatic.F77_CYCLOMATIC;
2221
import static fr.cnes.sonarqube.plugins.icode.measures.ICodeMetricsF77Cyclomatic.F77_CYCLOMATIC_MEAN;
2322
import static fr.cnes.sonarqube.plugins.icode.measures.ICodeMetricsF77Cyclomatic.F77_CYCLOMATIC_MIN;
@@ -41,10 +40,10 @@ public class ComputeModuleF77CyclomaticStatistics implements MeasureComputer {
4140

4241
@Override
4342
public MeasureComputerDefinition define(MeasureComputerDefinitionContext defContext) {
44-
43+
String[] metricTab = new String[] {F77_CYCLOMATIC.key(),F77_CYCLOMATIC_MEAN.key(),F77_CYCLOMATIC_MIN.key(),F77_CYCLOMATIC_MAX.key()};
4544
return defContext.newDefinitionBuilder()
46-
.setInputMetrics(new String[] {F77_CYCLOMATIC.key(),F77_CYCLOMATIC_MEAN.key(),F77_CYCLOMATIC_MIN.key(),F77_CYCLOMATIC_MAX.key()})
47-
.setOutputMetrics(new String[] {F77_CYCLOMATIC.key(),F77_CYCLOMATIC_MEAN.key(),F77_CYCLOMATIC_MIN.key(),F77_CYCLOMATIC_MAX.key()})//,DBG.key()})
45+
.setInputMetrics(metricTab)
46+
.setOutputMetrics(metricTab)
4847
.build();
4948
}
5049

@@ -54,51 +53,53 @@ public void compute(MeasureComputerContext context) {
5453
// Create module measures
5554
if (context.getComponent().getType() != Component.Type.FILE) {
5655

57-
// // Search Cyclomatic measure for children files
58-
// childrenMeasures = context.getChildrenMeasures(F77_CYCLOMATIC.key());
59-
// if(childrenMeasures.iterator().hasNext()){
60-
// int sum = 0;
61-
// for (Measure child : childrenMeasures) {
62-
// sum += child.getIntValue();
63-
// }
64-
// context.addMeasure(F77_CYCLOMATIC.key(),sum);
65-
// }
66-
6756
// Search Cyclomatic mean measure for children files
6857
childrenMeasures = context.getChildrenMeasures(F77_CYCLOMATIC_MEAN.key());
69-
if(childrenMeasures.iterator().hasNext()){
70-
double sum = 0;
71-
int nbItem = 0;
72-
for (Measure child : childrenMeasures) {
73-
sum += child.getDoubleValue();
74-
nbItem++;
75-
}
76-
context.addMeasure(F77_CYCLOMATIC_MEAN.key(),(nbItem!=0)?sum/nbItem:sum);
77-
}
58+
computeMean(context, childrenMeasures);
7859

7960
// Search Cyclomatic minimum measure for children files
8061
childrenMeasures = context.getChildrenMeasures(F77_CYCLOMATIC_MIN.key());
81-
if(childrenMeasures.iterator().hasNext()){
82-
int min = 1000;
83-
for (Measure child : childrenMeasures){
84-
if(child.getIntValue() < min){
85-
min = child.getIntValue();
86-
}
87-
}
88-
context.addMeasure(F77_CYCLOMATIC_MIN.key(), min);
89-
}
62+
computeMin(context, childrenMeasures);
9063

9164
// Search Cyclomatic minimum measure for children files
9265
childrenMeasures = context.getChildrenMeasures(F77_CYCLOMATIC_MAX.key());
93-
if(childrenMeasures.iterator().hasNext()){
94-
int max = 0;
95-
for (Measure child : childrenMeasures){
96-
if(child.getIntValue() > max){
97-
max = child.getIntValue();
98-
}
66+
computeMax(context, childrenMeasures);
67+
}
68+
}
69+
70+
private void computeMax(MeasureComputerContext context, Iterable<Measure> childrenMeasures) {
71+
if(childrenMeasures.iterator().hasNext()){
72+
int max = 0;
73+
for (Measure child : childrenMeasures){
74+
if(child.getIntValue() > max){
75+
max = child.getIntValue();
9976
}
100-
context.addMeasure(F77_CYCLOMATIC_MAX.key(), max);
10177
}
78+
context.addMeasure(F77_CYCLOMATIC_MAX.key(), max);
79+
}
80+
}
81+
82+
private void computeMin(MeasureComputerContext context, Iterable<Measure> childrenMeasures) {
83+
if(childrenMeasures.iterator().hasNext()){
84+
int min = 1000;
85+
for (Measure child : childrenMeasures){
86+
if(child.getIntValue() < min){
87+
min = child.getIntValue();
88+
}
89+
}
90+
context.addMeasure(F77_CYCLOMATIC_MIN.key(), min);
91+
}
92+
}
93+
94+
private void computeMean(MeasureComputerContext context, Iterable<Measure> childrenMeasures) {
95+
if(childrenMeasures.iterator().hasNext()){
96+
double sum = 0;
97+
int nbItem = 0;
98+
for (Measure child : childrenMeasures) {
99+
sum += child.getDoubleValue();
100+
nbItem++;
101+
}
102+
context.addMeasure(F77_CYCLOMATIC_MEAN.key(),(nbItem!=0)?sum/nbItem:sum);
102103
}
103104
}
104105
}

0 commit comments

Comments
 (0)