Skip to content

Commit

Permalink
Merge pull request #1677 from guwirth/fix-quality-gate
Browse files Browse the repository at this point in the history
Fix quality gate isssues
  • Loading branch information
guwirth authored Jan 27, 2019
2 parents 43b1e0b + b98de0e commit f33d014
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public class ReservedNamesCheck extends SquidCheck<Grammar> implements CxxCharse
@Override
public void visitFile(AstNode astNode) {

try {
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset));
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(getContext().getFile()), charset))) {
String line;
int nr = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ public class UseCorrectIncludeCheck extends SquidCheck<Grammar> implements CxxCh

@Override
public void visitFile(AstNode astNode) {
try {
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset));

// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(getContext().getFile()), charset))) {
String line;
int nr = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ public void setCharset(Charset charset) {

@Override
public void visitFile(AstNode astNode) {
try {
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset));

// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(getContext().getFile()), charset))) {
String line;
int nr = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ public void setCharset(Charset charset) {

@Override
public void visitFile(AstNode astNode) {
try {
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset));

// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(getContext().getFile()), charset))) {
String line;
int nr = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ public void init() {

@Override
public void visitFile(AstNode astNode) {
try {
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset));

// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(getContext().getFile()), charset))) {

if (isRegularExpression) {
String fileContent = br.lines().collect(Collectors.joining(System.lineSeparator()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ public void setCharset(Charset charset) {

@Override
public void visitFile(AstNode fileNode) {
try {
if (!compare(invertFilePattern, matchFile())) {
return;
}
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset));
if (!compare(invertFilePattern, matchFile())) {
return;
}
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset))) {
final String fileContent = br.lines().collect(Collectors.joining(System.lineSeparator()));
Matcher matcher = pattern.matcher(fileContent);
if (compare(invertRegularExpression, matcher.find())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ public void setCharset(Charset charset) {
@Override
public void visitFile(AstNode fileNode) {
if (compare(invertFilePattern, matchFile())) {
try {
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(getContext().getFile()), charset));
// use onMalformedInput(CodingErrorAction.REPLACE) / onUnmappableCharacter(CodingErrorAction.REPLACE)
try (BufferedReader br = new BufferedReader(
new InputStreamReader(new FileInputStream(getContext().getFile()), charset))) {
String line;
int nr = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public static List<DrMemoryError> parse(File file, String charset) {
public static List<String> getElements(File file, String charset) {

List<String> list = new ArrayList<>();
try (InputStream input = java.nio.file.Files.newInputStream(file.toPath())) {
BufferedReader br = new BufferedReader(new InputStreamReader(input, charset));
try (BufferedReader br = new BufferedReader(
new InputStreamReader(java.nio.file.Files.newInputStream(file.toPath()), charset))) {
StringBuilder sb = new StringBuilder(4096);
String line;
int cnt = 0;
Expand All @@ -109,14 +109,12 @@ public static List<String> getElements(File file, String charset) {
sb.append('\n');
}
}
cnt++;
++cnt;
}

if (sb.length() > 0) {
list.add(sb.toString());
}

br.close();
} catch (IOException e) {
String msg = new StringBuilder(512).append("Cannot feed the data into sonar, details: '")
.append(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public void parseVCppLine(String line, String projectPath, String compilationFil
*/
public void parseVCppLog(File buildLog, String baseDir, String charsetName) {
boolean detectedPlatform = false;
try (InputStream input = java.nio.file.Files.newInputStream(buildLog.toPath())) {
BufferedReader br = new BufferedReader(new InputStreamReader(input, charsetName));
try (BufferedReader br = new BufferedReader(
new InputStreamReader(java.nio.file.Files.newInputStream(buildLog.toPath()), charsetName))) {
String line;
if (LOG.isDebugEnabled()) {
LOG.debug("build log parser baseDir='{}'", baseDir);
Expand Down Expand Up @@ -179,7 +179,6 @@ public void parseVCppLog(File buildLog, String baseDir, String charsetName) {
}
}
}
br.close();
} catch (IOException ex) {
LOG.error("Cannot parse build log", ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,23 @@ public class CxxConfigurationModel extends AbstractConfigurationModel {

private final MapSettings settings = new MapSettings();

ConfigurationProperty charsetProperty = new ConfigurationProperty("Charset", CHARSET_PROPERTY_KEY,
private final ConfigurationProperty charsetProperty = new ConfigurationProperty("Charset", CHARSET_PROPERTY_KEY,
getPropertyOrDefaultValue(CHARSET_PROPERTY_KEY, "UTF-8"),
Validators.charsetValidator());

ConfigurationProperty errorRecoveryEnabled = new ConfigurationProperty("Error Recovery", ERROR_RECOVERY_PROPERTY_KEY,
private final ConfigurationProperty errorRecoveryEnabled = new ConfigurationProperty("Error Recovery", ERROR_RECOVERY_PROPERTY_KEY,
getPropertyOrDefaultValue(ERROR_RECOVERY_PROPERTY_KEY, "false"),
Validators.booleanValidator());

ConfigurationProperty defines = new ConfigurationProperty("Defines", DEFINES_PROPERTY_KEY
private final ConfigurationProperty defines = new ConfigurationProperty("Defines", DEFINES_PROPERTY_KEY
+ " (use \\n\\ as separator)",
getPropertyOrDefaultValue(DEFINES_PROPERTY_KEY, ""));

ConfigurationProperty includeDirectories = new ConfigurationProperty("Include Directories",
private final ConfigurationProperty includeDirectories = new ConfigurationProperty("Include Directories",
INCLUDE_DIRECTORIES_PROPERTY_KEY + " (use , as separator)",
getPropertyOrDefaultValue(INCLUDE_DIRECTORIES_PROPERTY_KEY, ""));

ConfigurationProperty forceIncludes = new ConfigurationProperty("Force Includes", FORCE_INCLUDES_PROPERTY_KEY
private final ConfigurationProperty forceIncludes = new ConfigurationProperty("Force Includes", FORCE_INCLUDES_PROPERTY_KEY
+ " (use , as separator)",
getPropertyOrDefaultValue(FORCE_INCLUDES_PROPERTY_KEY, ""));

Expand Down

0 comments on commit f33d014

Please sign in to comment.