Skip to content

Commit 1345a4d

Browse files
authored
squid: save metrics slow (#2520)
squid save slow Improve performance issue with squid save
1 parent 82350cd commit 1345a4d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/CxxSquidSensor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public static List<PropertyDefinition> properties() {
302302
public void describe(SensorDescriptor descriptor) {
303303
descriptor
304304
.name("CXX")
305-
.onlyOnLanguage("cxx")
305+
.onlyOnLanguage(CxxLanguage.KEY)
306306
.onlyOnFileType(InputFile.Type.MAIN)
307307
.onlyWhenConfiguration(conf -> !conf.getBoolean(SQUID_DISABLED_KEY).orElse(false));
308308
}
@@ -351,7 +351,7 @@ private String[] stripValue(String key, String regex) {
351351

352352
private CxxSquidConfiguration createConfiguration() {
353353
var squidConfig = new CxxSquidConfiguration(context.fileSystem().baseDir().getAbsolutePath(),
354-
context.fileSystem().encoding());
354+
context.fileSystem().encoding());
355355

356356
squidConfig.add(CxxSquidConfiguration.SONAR_PROJECT_PROPERTIES, CxxSquidConfiguration.ERROR_RECOVERY_ENABLED,
357357
context.config().get(ERROR_RECOVERY_KEY));
@@ -389,7 +389,7 @@ private CxxSquidConfiguration createConfiguration() {
389389
private Iterable<InputFile> getInputFiles(SensorContext context, CxxSquidConfiguration squidConfig) {
390390
Iterable<InputFile> inputFiles = context.fileSystem().inputFiles(
391391
context.fileSystem().predicates().and(
392-
context.fileSystem().predicates().hasLanguage("cxx"),
392+
context.fileSystem().predicates().hasLanguage(CxxLanguage.KEY),
393393
context.fileSystem().predicates().hasType(InputFile.Type.MAIN)
394394
)
395395
);
@@ -419,9 +419,9 @@ private void save(Collection<SourceCode> sourceCodeFiles) {
419419
for (var sourceCodeFile : sourceCodeFiles) {
420420
try {
421421
var sourceFile = (SourceFile) sourceCodeFile;
422-
var ioFile = new File(sourceFile.getKey());
423-
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().is(ioFile));
424-
422+
InputFile inputFile = context.fileSystem().inputFile(
423+
context.fileSystem().predicates().hasPath(sourceFile.getKey())
424+
);
425425
saveMeasures(inputFile, sourceFile);
426426
saveViolations(inputFile, sourceFile);
427427
saveFileLinesContext(inputFile, sourceFile);

0 commit comments

Comments
 (0)