-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CHANGE(pmd): @W-17310830@: Update pmd-wrapper to run rules by languag…
…e forcefully
- Loading branch information
1 parent
ced5efe
commit 70ba652
Showing
12 changed files
with
370 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...engine/pmd-cpd-wrappers/src/main/java/com/salesforce/sfca/pmdwrapper/PmdRunInputData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.salesforce.sfca.pmdwrapper; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class PmdRunInputData { | ||
public String ruleSetInputFile; | ||
public Map<String, LanguageSpecificRunData> runDataPerLanguage; | ||
|
||
public static class LanguageSpecificRunData { | ||
public List<String> filesToScan; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...md-engine/pmd-cpd-wrappers/src/main/java/com/salesforce/sfca/shared/ProgressReporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.salesforce.sfca.shared; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
// This class helps us track the overall progress of all language runs | ||
public class ProgressReporter { | ||
private Map<String, Float> progressPerLanguage = new HashMap<>(); | ||
private float lastReportedProgress = 0.0f; | ||
|
||
public void initialize(List<String> languages) { | ||
progressPerLanguage = new HashMap<>(); | ||
languages.forEach(l -> this.updateProgressForLanguage(l, 0.0f)); | ||
} | ||
|
||
public void updateProgressForLanguage(String language, float percComplete) { | ||
progressPerLanguage.put(language, percComplete); | ||
} | ||
|
||
public void reportOverallProgress() { | ||
float currentProgress = this.calculateOverallPercentage(); | ||
// The progress goes very fast, so we make sure to only report progress if there has been a significant enough increase (at least 1%) | ||
if (currentProgress >= lastReportedProgress + 1) { | ||
System.out.println("[Progress]" + currentProgress); | ||
lastReportedProgress = currentProgress; | ||
} | ||
} | ||
|
||
private float calculateOverallPercentage() { | ||
float sum = 0.0f; | ||
for (float progress : progressPerLanguage.values()) { | ||
sum += progress; | ||
} | ||
return sum / progressPerLanguage.size(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.