8
8
import org .jboss .tools .intellij .windup .model .WindupConfiguration ;
9
9
import java .io .File ;
10
10
import java .io .FileNotFoundException ;
11
+ import java .net .URISyntaxException ;
11
12
import java .util .ArrayList ;
12
13
import java .util .List ;
13
14
import java .util .Map ;
14
-
15
+ import java . net . URI ;
15
16
public class RulesetParser {
16
17
17
18
public static List <Ruleset > parseRuleset (String resultFilePath ) {
@@ -47,14 +48,18 @@ public static List<Ruleset> parseRuleset(String resultFilePath) {
47
48
return null ;
48
49
}
49
50
50
- public static void parseRulesetForKantraConfig (WindupConfiguration configuration ){
51
+ public static void parseRulesetForKantraConfig (WindupConfiguration configuration ) {
51
52
if (configuration .getOptions () != null ){
52
53
String outputLocation = configuration .getRulesetResultLocation ();
53
54
configuration .setRulesets (parseRuleset (outputLocation ));
54
55
55
56
if (configuration .getSummary () != null ){
56
57
configuration .getSummary ().setRulesets (parseRuleset (outputLocation ));
57
- parseIncidents (configuration .getRulesets (), configuration );
58
+ try {
59
+ parseIncidents (configuration .getRulesets (), configuration );
60
+ } catch (URISyntaxException e ) {
61
+ throw new RuntimeException (e );
62
+ }
58
63
// System.out.println("size of the Incident: ");
59
64
// System.out.println(configuration.getSummary().getIssues().size());
60
65
}else {
@@ -66,7 +71,7 @@ public static void parseRulesetForKantraConfig (WindupConfiguration configuratio
66
71
67
72
}
68
73
69
- public static void parseIncidents (List <WindupConfiguration .Ruleset > rulesets , WindupConfiguration configuration ) {
74
+ public static void parseIncidents (List <WindupConfiguration .Ruleset > rulesets , WindupConfiguration configuration ) throws URISyntaxException {
70
75
if (rulesets != null ){
71
76
for (WindupConfiguration .Ruleset ruleset : rulesets ){
72
77
Map <String , Violation > violations = ruleset .getViolations ();
@@ -81,13 +86,12 @@ public static void parseIncidents (List<WindupConfiguration.Ruleset> rulesets, W
81
86
ArrayList <String > inputs = (ArrayList <String >) configuration .getOptions ().get ("input" );
82
87
String input = inputs .get (0 );
83
88
String filePath = incident .getUri ();;
89
+ URI uri = new URI (filePath );
84
90
incident .ruleId = entry .getKey ();
85
- //System.out.println("-----------filePath-------------: " + filePath);
86
- String absolutePath = filePath .substring (filePath .indexOf ("/opt/input/source" ) + "/opt/input/source" .length ());
87
- // System.out.println("------------------ Absolute path -------------: " + input + absolutePath);
88
- incident .file = input + absolutePath ;
89
- incident .setUri (input + absolutePath );
90
- // System.out.println("File path of the incidents: " + incident.file);
91
+ String absolutePath = new File (uri ).getAbsolutePath ();
92
+ incident .file = absolutePath ;
93
+ incident .setUri (absolutePath );
94
+ //System.out.println("File path of the incidents: " + incident.file);
91
95
incident .effort = String .valueOf (violation .getEffort ());
92
96
incident .links = violation .getLinks ();
93
97
incident .category = violation .getCategory ();
0 commit comments