Skip to content

Commit

Permalink
Add scalastyle dtos (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
random1223 authored Aug 29, 2024
1 parent b8d99c9 commit d573719
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.springframework.stereotype.Service;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -48,8 +50,8 @@ public List<CodeAnalysisResultDto> analyzeCode(AnalyzerConfigurationDetailDto ru

String errorOutput = runtimeExecResult.getErrorOutput();
String successOutput = runtimeExecResult.getSuccessOutput();

// List<CodeAnalysisIssueDto> codeAnalysisIssueDtoList = CppcheckResultConverter.convertResult(errorOutput);
String payload = Files.readString(Path.of(tmpConfigDownloadFolder.getAbsolutePath()));
List<CodeAnalysisIssueDto> codeAnalysisIssueDtoList = ScalastyleConverter.convertResult(payload);
// if(codeAnalysisIssueDtoList == null || codeAnalysisIssueDtoList.isEmpty()){
// return list;
// }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.codety.scanner.analyzer.scalastyle;

import io.codety.scanner.reporter.dto.CodeAnalysisIssueDto;

import java.util.ArrayList;
import java.util.List;

public class ScalastyleConverter {


public static List<CodeAnalysisIssueDto> convertResult(String payload) {
ArrayList<CodeAnalysisIssueDto> codeAnalysisIssueDtos = new ArrayList<>();



return codeAnalysisIssueDtos;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.codety.scanner.analyzer.scalastyle.dto;

import java.util.List;

public class ScalastyleCheckstyle {
private List<ScalastyleFile> file;
private double version;

public List<ScalastyleFile> getFile() {
return file;
}

public void setFile(List<ScalastyleFile> file) {
this.file = file;
}

public double getVersion() {
return version;
}

public void setVersion(double version) {
this.version = version;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package io.codety.scanner.analyzer.scalastyle.dto;

public class ScalastyleError {
private int line;
private String source;
private String severity;
private String message;
private int column;

public int getLine() {
return line;
}

public void setLine(int line) {
this.line = line;
}

public String getSource() {
return source;
}

public void setSource(String source) {
this.source = source;
}

public String getSeverity() {
return severity;
}

public void setSeverity(String severity) {
this.severity = severity;
}

public String getMessage() {
return message;
}

public void setMessage(String message) {
this.message = message;
}

public int getColumn() {
return column;
}

public void setColumn(int column) {
this.column = column;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.codety.scanner.analyzer.scalastyle.dto;

import java.util.List;

public class ScalastyleFile {
private List<ScalastyleError> error;
private String name;

public List<ScalastyleError> getError() {
return error;
}

public void setError(List<ScalastyleError> error) {
this.error = error;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
12 changes: 12 additions & 0 deletions analyzer-scalastyle/src/test/resources/output-example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="5.0">
<file name="/Users/user/git/codety-scanner/code-issue-examples/scala/emptyclass.scala">
<error line="1" source="org.scalastyle.file.HeaderMatchesChecker" severity="warning" message="Header does not match expected text"/>
<error source="org.scalastyle.file.NewLineAtEofChecker" severity="warning" message="File must end with newline character"/>
<error column="7" line="1" source="org.scalastyle.scalariform.EmptyClassChecker" severity="warning" message="Redundant braces after class definition"/>
</file>
<file name="/Users/user/git/codety-scanner/code-issue-examples/scala/test.scala">
<error line="1" source="org.scalastyle.file.HeaderMatchesChecker" severity="warning" message="Header does not match expected text"/>
<error source="org.scalastyle.file.NewLineAtEofChecker" severity="warning" message="File must end with newline character"/>
</file>
</checkstyle>

0 comments on commit d573719

Please sign in to comment.