Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Here is the compatibility matrix of the plugin:
| 3.1.1 | 4.1.2 | 7.9 -> 9.9 | Fortran |
| 3.1.2 | 5.1.0 | 7.9 -> 9.9 | Fortran |
| 5.1.0 | 5.1.0 | 7.9 -> 9.9 | Fortran |
| 5.2.0 | 5.1.0 | 25.1.0 -> 25.9.0 | Fortran |

*Notice: Since 5.X this plugins will follow I-Code versionning. There is no breaking changes between 3.X and 5.X*

Expand All @@ -50,8 +51,8 @@ If embedded version of i-Code does not match your need, you can set the executio
- `sonar.icode.path`: Define i-Code CNES executable path to auto-launch it on analysis. Default: `${HOME}/icode-cnes/icode.exe`.

#### Other plugin's properties
- `sonar.icode.f77.file.suffixes`: List of suffixes for F77 files to analyze. Default: `.f,.f77,.for,.fpp,.ftn,.F,.F77,.FOR,.FPP,.FTN`.
- `sonar.icode.f90.file.suffixes`: List of suffixes for F90 files to analyze. Default: `.f90,.F90`.
- `sonar.f77.file.suffixes`: List of suffixes for F77 files to analyze. Default: `.f,.f77,.for,.fpp,.ftn,.F,.F77,.FOR,.FPP,.FTN`.
- `sonar.f90.file.suffixes`: List of suffixes for F90 files to analyze. Default: `.f90,.F90`.
- `sonar.icode.reports.path`: Path to the i-Code reports. Multiple path can be provided. Default: `result.res`.

### Features
Expand Down
2 changes: 1 addition & 1 deletion it/Dockerfile-auditor
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ COPY --from=builder /opt/sonar-scanner /opt/sonar-scanner


RUN apk update --no-cache && \
apk add --update --no-cache -q curl gcc jq libffi-dev musl-dev openssl-dev python3 py3-requests shellcheck
apk add --update --no-cache -q curl gcc jq libffi-dev musl-dev openssl-dev python3 py3-requests

RUN set -eux && \
addgroup --gid 1000 scanner-cli && \
Expand Down
29 changes: 9 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>23</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<surefire.version>3.5.3</surefire.version>
<!-- Matrice: https://github.com/SonarSource/sonar-plugin-api -->
<sonar.plugin.api.version>9.14.0.375</sonar.plugin.api.version>
<sonar.version>9.9.0.65466</sonar.version>
<sonar.plugin.api.version>11.0.0.2664</sonar.plugin.api.version>
<sonar.version>25.1.0.102122</sonar.version>
<sonar.pluginKey>icode</sonar.pluginKey>
<sonar.pluginClass>fr.cnes.sonar.plugins.icode.ICodePlugin</sonar.pluginClass>
<sonar.pluginUrl>https://github.com/cnescatlab/sonar-icode-cnes-plugin</sonar.pluginUrl>
Expand All @@ -75,15 +75,11 @@

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/cnescatlab/i-CodeCNES</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>github</id>
<url>https://maven.pkg.github.com/cnescatlab/i-CodeCNES</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

Expand All @@ -104,13 +100,6 @@
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
</dependency>
<!-- unit tests -->
<!-- <dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-testing-harness</artifactId>
<version>${sonar.version}</version>
<scope>test</scope>
</dependency> -->
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-plugin-api-impl</artifactId>
Expand Down Expand Up @@ -257,4 +246,4 @@

</plugins>
</build>
</project>
</project>
157 changes: 88 additions & 69 deletions src/main/java/fr/cnes/sonar/plugins/icode/check/ICodeSensor.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*/
package fr.cnes.sonar.plugins.icode.languages;

import org.apache.commons.lang.StringUtils;
import org.sonar.api.config.Configuration;
import org.sonar.api.resources.AbstractLanguage;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.sonar.api.config.Configuration;
import org.sonar.api.resources.AbstractLanguage;

/**
* Declared language i-Code as the parent language for Fortran 77, Fortran 90.
*/
Expand All @@ -37,8 +37,8 @@ public abstract class ICodeLanguage extends AbstractLanguage {
* i-Code extension for i-Code specific properties, Metrics and Rules.
*
* @param configuration Inject SonarQube configuration into this extension.
* @param key Key of the language to set.
* @param name Name of the language to set.
* @param key Key of the language to set.
* @param name Name of the language to set.
*/
public ICodeLanguage(final Configuration configuration, final String key, final String name) {
super(key, name);
Expand Down Expand Up @@ -75,20 +75,20 @@ public String[] getFileSuffixes() {

/**
* Delete all empty string values into a input String array.
*
*
* @param stringArray Input String array.
*
* @return Output String array without empty string values.
*/
public static String[] filterEmptyStrings(final String[] stringArray) {
List<String> nonEmptyStrings = new ArrayList<>();
for (final String string : stringArray) {
if (StringUtils.isNotBlank(string.trim())) {
nonEmptyStrings.add(string.trim());
}
}
return nonEmptyStrings.toArray(new String[nonEmptyStrings.size()]);
}
public static String[] filterEmptyStrings(final String[] stringArray) {
List<String> nonEmptyStrings = new ArrayList<>();
for (final String string : stringArray) {
if (StringUtils.isNotBlank(string.trim())) {
nonEmptyStrings.add(string.trim());
}
}
return nonEmptyStrings.toArray(new String[nonEmptyStrings.size()]);
}

/**
* Assert obj is the same object as this.
Expand All @@ -98,7 +98,7 @@ public static String[] filterEmptyStrings(final String[] stringArray) {
*/
@Override
public boolean equals(final Object obj) {
return obj==this;
return super.equals(obj);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@
*/
package fr.cnes.sonar.plugins.icode.languages;

import fr.cnes.sonar.plugins.icode.rules.ICodeRulesDefinition;
import fr.cnes.sonar.plugins.icode.rules.RulesRepository;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.server.profile.BuiltInQualityProfilesDefinition;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
import org.sonar.api.server.rule.RulesDefinition.NewRule;

import java.util.List;
import fr.cnes.sonar.plugins.icode.rules.ICodeRulesDefinition;
import fr.cnes.sonar.plugins.icode.rules.RulesRepository;

/**
* Built-in quality profile format since SonarQube 9.9
*/
public final class ICodeQualityProfiles implements BuiltInQualityProfilesDefinition {

/** Logger for this class. **/
private static final Logger LOGGER = Loggers.get(ICodeQualityProfiles.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ICodeQualityProfiles.class);

/** Display name for the built-in quality profile. **/
private static final String I_CODE_RULES_PROFILE_NAME = "Sonar way";
Expand All @@ -54,12 +54,13 @@ public void define(final Context context) {
/**
* Create a built in quality profile for a specific language.
*
* @param context SonarQube context in which create the profile.
* @param context SonarQube context in which create the profile.
* @param repository Rules' repository.
* @param language Language key of the associated profile.
* @param rules Rules to activate.
* @param language Language key of the associated profile.
* @param rules Rules to activate.
*/
private void createBuiltInProfile(final Context context, final String repository, final String languageKey, final List<NewRule> rules) {
private void createBuiltInProfile(final Context context, final String repository, final String languageKey,
final List<NewRule> rules) {
// Create a builder for the rules' repository.
NewBuiltInQualityProfile profile = context.createBuiltInQualityProfile(I_CODE_RULES_PROFILE_NAME, languageKey);

Expand All @@ -70,6 +71,7 @@ private void createBuiltInProfile(final Context context, final String repository
}
profile.setDefault(true);
profile.done();
LOGGER.info(String.format("%s rules are activated for the repository %s.", profile.activeRules().size(), repository));
LOGGER.info(String.format("%s rules are activated for the repository %s.", profile.activeRules().size(),
repository));
}
}
Loading
Loading