Skip to content

Commit

Permalink
Merge pull request #1476 from guwirth/remove-scanOnlySpecifiedSources
Browse files Browse the repository at this point in the history
remove scanOnlySpecifiedSources
  • Loading branch information
guwirth authored May 11, 2018
2 parents 7b5d85d + 8366319 commit 23b3f89
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public class CxxSquidSensor implements Sensor {
public static final String C_FILES_PATTERNS_KEY = "cFilesPatterns";
public static final String MISSING_INCLUDE_WARN = "missingIncludeWarnings";
public static final String JSON_COMPILATION_DATABASE_KEY = "jsonCompilationDatabase";
public static final String SCAN_ONLY_SPECIFIED_SOURCES_KEY = "scanOnlySpecifiedSources";

public static final String CPD_IGNORE_LITERALS_KEY = "cpd.ignoreLiterals";
public static final String CPD_IGNORE_IDENTIFIERS_KEY = "cpd.ignoreIdentifiers";
Expand Down Expand Up @@ -145,23 +144,14 @@ public void execute(SensorContext context) {
AstScanner<Grammar> scanner = CxxAstScanner.create(this.language, cxxConf,
visitors.toArray(new SquidAstVisitor[visitors.size()]));

List<File> files;
if (cxxConf.isScanOnlySpecifiedSources()) {
files = cxxConf.getCompilationUnitSourceFiles();
} else {
Iterable<InputFile> inputFiles = context.fileSystem().inputFiles(context.fileSystem().predicates()
.and(context.fileSystem().predicates()
.hasLanguage(this.language.getKey()), context.fileSystem().predicates()
.hasType(InputFile.Type.MAIN)));

files = new ArrayList<>();
for (InputFile file : inputFiles) {
files.add(file.file()); //@todo: deprecated file.file()
}
}
Iterable<InputFile> inputFiles = context.fileSystem().inputFiles(context.fileSystem().predicates()
.and(context.fileSystem().predicates()
.hasLanguage(this.language.getKey()), context.fileSystem().predicates()
.hasType(InputFile.Type.MAIN)));

if (LOG.isDebugEnabled() && !files.isEmpty()) {
LOG.debug("All source files (Type.MAIN): {}", files);
List<File> files = new ArrayList<>();
for (InputFile file : inputFiles) {
files.add(new File(file.uri().getPath()));
}

scanner.scanFiles(files);
Expand All @@ -184,8 +174,6 @@ private CxxConfiguration createConfiguration(FileSystem fs, SensorContext contex
.orElse(Boolean.FALSE));
cxxConf.setJsonCompilationDatabaseFile(this.language.getStringOption(JSON_COMPILATION_DATABASE_KEY)
.orElse(null));
cxxConf.setScanOnlySpecifiedSources(this.language.getBooleanOption(SCAN_ONLY_SPECIFIED_SOURCES_KEY)
.orElse(Boolean.FALSE));

if (cxxConf.getJsonCompilationDatabaseFile() != null) {
try {
Expand Down
9 changes: 0 additions & 9 deletions cxx-squid/src/main/java/org/sonar/cxx/CxxConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class CxxConfiguration extends SquidConfiguration {
private List<String> cFilesPatterns = new ArrayList<>();
private boolean missingIncludeWarningsEnabled = true;
private String jsonCompilationDatabaseFile;
private boolean scanOnlySpecifiedSources;
private CxxCompilationUnitSettings globalCompilationUnitSettings;
private final Map<String, CxxCompilationUnitSettings> compilationUnitSettings = new HashMap<>();

Expand Down Expand Up @@ -226,14 +225,6 @@ public void setJsonCompilationDatabaseFile(String jsonCompilationDatabaseFile) {
this.jsonCompilationDatabaseFile = jsonCompilationDatabaseFile;
}

public boolean isScanOnlySpecifiedSources() {
return scanOnlySpecifiedSources;
}

public void setScanOnlySpecifiedSources(boolean scanOnlySpecifiedSources) {
this.scanOnlySpecifiedSources = scanOnlySpecifiedSources;
}

public CxxCompilationUnitSettings getGlobalCompilationUnitSettings() {
return globalCompilationUnitSettings;
}
Expand Down
10 changes: 0 additions & 10 deletions sonar-c-plugin/src/main/java/org/sonar/plugins/c/CPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public final class CPlugin implements Plugin {
public static final String C_FILES_PATTERNS_KEY = LANG_PROP_PREFIX + "cFilesPatterns";
public static final String MISSING_INCLUDE_WARN = LANG_PROP_PREFIX + "missingIncludeWarnings";
public static final String JSON_COMPILATION_DATABASE_KEY = LANG_PROP_PREFIX + "jsonCompilationDatabase";
public static final String SCAN_ONLY_SPECIFIED_SOURCES_KEY = LANG_PROP_PREFIX + "scanOnlySpecifiedSources";
public static final String CPD_IGNORE_LITERALS_KEY = LANG_PROP_PREFIX + "cpd.ignoreLiterals";
public static final String CPD_IGNORE_IDENTIFIERS_KEY = LANG_PROP_PREFIX + "cpd.ignoreIdentifiers";

Expand Down Expand Up @@ -170,15 +169,6 @@ private static List<PropertyDefinition> generalProperties() {
+ "and includes should be used for source files.")
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.index(9)
.build(),
PropertyDefinition.builder(CPlugin.SCAN_ONLY_SPECIFIED_SOURCES_KEY)
.defaultValue(Boolean.FALSE.toString())
.name("Scan only specified source files")
.description("Only scan source files defined in specification file. Eg. by JSON Compilation Database.")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.type(PropertyType.BOOLEAN)
.index(10)
.build()
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public void testGetExtensions() throws Exception {
Plugin.Context context = new Plugin.Context(runtime);
CPlugin plugin = new CPlugin();
plugin.define(context);
assertThat(context.getExtensions()).hasSize(68);
assertThat(context.getExtensions()).hasSize(67);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public final class CxxPlugin implements Plugin {
public static final String C_FILES_PATTERNS_KEY = LANG_PROP_PREFIX + "cFilesPatterns";
public static final String MISSING_INCLUDE_WARN = LANG_PROP_PREFIX + "missingIncludeWarnings";
public static final String JSON_COMPILATION_DATABASE_KEY = LANG_PROP_PREFIX + "jsonCompilationDatabase";
public static final String SCAN_ONLY_SPECIFIED_SOURCES_KEY = LANG_PROP_PREFIX + "scanOnlySpecifiedSources";
public static final String CPD_IGNORE_LITERALS_KEY = LANG_PROP_PREFIX + "cpd.ignoreLiterals";
public static final String CPD_IGNORE_IDENTIFIERS_KEY = LANG_PROP_PREFIX + "cpd.ignoreIdentifiers";

Expand Down Expand Up @@ -178,15 +177,6 @@ private static List<PropertyDefinition> generalProperties() {
+ "used for source files.")
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.index(9)
.build(),
PropertyDefinition.builder(CxxPlugin.SCAN_ONLY_SPECIFIED_SOURCES_KEY)
.defaultValue(Boolean.FALSE.toString())
.name("Scan only specified source files")
.description("Only scan source files defined in specification file. Eg. by JSON Compilation Database.")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.type(PropertyType.BOOLEAN)
.index(10)
.build()
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public void testGetExtensions() throws Exception {
Plugin.Context context = new Plugin.Context(runtime);
CxxPlugin plugin = new CxxPlugin();
plugin.define(context);
assertThat(context.getExtensions()).hasSize(72);
assertThat(context.getExtensions()).hasSize(71);
}
}

0 comments on commit 23b3f89

Please sign in to comment.