Skip to content

Commit 12952f0

Browse files
Fix static issues with list of fortran rules
1 parent 728ca1e commit 12952f0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/java/fr/cnes/sonar/plugins/icode/rules/ICodeRulesDefinition.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public class ICodeRulesDefinition implements RulesDefinition {
7171
*/
7272
@Override
7373
public void define(final Context context) {
74-
this.f77Rules = createFortranRepository(context, FORTRAN77_LANGUAGE, FORTRAN77_REPOSITORY, PATH_TO_F77_RULES_XML);
75-
this.f90Rules = createFortranRepository(context, FORTRAN90_LANGUAGE, FORTRAN90_REPOSITORY, PATH_TO_F90_RULES_XML);
74+
createFortranRepository(context, FORTRAN77_LANGUAGE, FORTRAN77_REPOSITORY, PATH_TO_F77_RULES_XML);
75+
createFortranRepository(context, FORTRAN90_LANGUAGE, FORTRAN90_REPOSITORY, PATH_TO_F90_RULES_XML);
7676
}
7777

7878
/**
@@ -83,7 +83,7 @@ public void define(final Context context) {
8383
* @param repositoryName Key of the repository.
8484
* @param pathToRulesXml Path to the xml file containing the rules.
8585
*/
86-
protected List<NewRule> createFortranRepository(final Context context, final String language, final String repositoryName, final String pathToRulesXml) {
86+
protected void createFortranRepository(final Context context, final String language, final String repositoryName, final String pathToRulesXml) {
8787
// Create the repository
8888
NewRepository repository = context.createRepository(repositoryName, language)
8989
.setName(ICodePluginProperties.ICODE_NAME);
@@ -95,7 +95,11 @@ protected List<NewRule> createFortranRepository(final Context context, final Str
9595

9696
if (inputFile == null) {
9797
repository.done();
98-
return rules;
98+
if (language == FORTRAN77_LANGUAGE) {
99+
ICodeRulesDefinition.f77Rules = rules;
100+
} else {
101+
ICodeRulesDefinition.f90Rules = rules;
102+
}
99103
}
100104

101105
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
@@ -139,7 +143,11 @@ protected List<NewRule> createFortranRepository(final Context context, final Str
139143
} catch (Exception e) {
140144
LOGGER.error("Error while creating rules.", e);
141145
}
142-
return rules;
146+
if (language == FORTRAN77_LANGUAGE) {
147+
ICodeRulesDefinition.f77Rules = rules;
148+
} else {
149+
ICodeRulesDefinition.f90Rules = rules;
150+
}
143151
}
144152

145153
/**

0 commit comments

Comments
 (0)