Skip to content

Commit

Permalink
Merge pull request #1647 from guwirth/remove-guava
Browse files Browse the repository at this point in the history
remove guava dependencies
  • Loading branch information
guwirth authored Jan 9, 2019
2 parents 2ff6f41 + 51b7dda commit 059646c
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 100 deletions.
2 changes: 0 additions & 2 deletions cxx-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@
<artifactId>cxx-squid</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.sonarsource.sslr</groupId>
<artifactId>sslr-testing-harness</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -61,7 +61,7 @@ public class ReservedNamesCheck extends SquidCheck<Grammar> implements CxxCharse
public void visitFile(AstNode astNode) {
List<String> lines;
try {
lines = Files.readLines(getContext().getFile(), charset);
lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.regex.Pattern;
import org.sonar.check.Priority;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class UseCorrectIncludeCheck extends SquidCheck<Grammar> implements CxxCh
public void visitFile(AstNode astNode) {
List<String> lines;
try {
lines = Files.readLines(getContext().getFile(), charset);
lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.file;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
Expand Down Expand Up @@ -69,7 +69,7 @@ public void setCharset(Charset charset) {
public void visitFile(AstNode astNode) {
List<String> lines;
try {
lines = Files.readLines(getContext().getFile(), charset);
lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.metrics;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
Expand Down Expand Up @@ -80,7 +80,7 @@ public void setCharset(Charset charset) {
public void visitFile(AstNode astNode) {
List<String> lines;
try {
lines = Files.readLines(getContext().getFile(), charset);
lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.regex;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -118,15 +118,15 @@ public void visitFile(AstNode astNode) {
if (isRegularExpression) {
String fileContent;
try {
fileContent = Files.toString(getContext().getFile(), charset);
fileContent = new String(Files.readAllBytes(getContext().getFile().toPath()), charset);
} catch (IOException e) {
throw new AnalysisException(e);
}
checkRegularExpression(fileContent);
} else {
List<String> lines;
try {
lines = Files.readLines(getContext().getFile(), charset);
lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.regex;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sonar.api.utils.PathUtils;
Expand Down Expand Up @@ -123,7 +123,7 @@ public void visitFile(AstNode fileNode) {
if (!compare(invertFilePattern, matchFile())) {
return;
}
final String fileContent = Files.toString(getContext().getFile(), charset);
final String fileContent = new String(Files.readAllBytes(getContext().getFile().toPath()), charset);
Matcher matcher = pattern.matcher(fileContent);
if (compare(invertRegularExpression, matcher.find())) {
getContext().createFileViolation(this, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.regex;

import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -123,7 +123,7 @@ public void visitFile(AstNode fileNode) {
if (compare(invertFilePattern, matchFile())) {
List<String> lines;
try {
lines = Files.readLines(getContext().getFile(), charset);
lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
Expand Down
9 changes: 7 additions & 2 deletions cxx-lint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-check-api</artifactId>
<version>5.4</version>
<version>${sonar.version}</version>
<type>jar</type>
</dependency>
<dependency>
Expand All @@ -57,6 +57,11 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
15 changes: 6 additions & 9 deletions cxx-sensors/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,16 @@
<artifactId>cxx-checks</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.sonarsource.sslr</groupId>
<artifactId>sslr-testing-harness</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonarsource.sonarqube</groupId>
<artifactId>sonar-testing-harness</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
Expand All @@ -57,10 +54,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand All @@ -72,9 +65,8 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.7</version>
<version>2.9.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.plist/dd-plist -->
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
Expand All @@ -85,5 +77,10 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
*/
package org.sonar.cxx.sensors.coverage;

import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -61,23 +61,23 @@ Collection<CoverageMeasure> getCoverageMeasures() {
}

Set<Integer> getCoveredLines() {
Set<Integer> coveredLines = Sets.newHashSet();
Set<Integer> coveredLines = new HashSet();
lineMeasures.forEach((key, value) -> {
if (value.getHits() != 0) {
coveredLines.add(value.getLine());
}
});
return ImmutableSet.copyOf(coveredLines);
return Collections.unmodifiableSet(coveredLines);
}

Set<Integer> getCoveredConditions() {
Set<Integer> coveredConditionLines = Sets.newHashSet();
Set<Integer> coveredConditionLines = new HashSet();
lineMeasures.forEach((key, value) -> {
if (value.getCoveredConditions() != 0) {
coveredConditionLines.add(value.getLine());
}
});
return ImmutableSet.copyOf(coveredConditionLines);
return Collections.unmodifiableSet(coveredConditionLines);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package org.sonar.cxx.sensors.squid;

import com.google.common.annotations.VisibleForTesting;
import com.sonar.sslr.api.Grammar;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -85,7 +84,6 @@ public RuleKey ruleKey(SquidAstVisitor<Grammar> check) {
return null;
}

@VisibleForTesting
public Set<Checks<SquidAstVisitor<Grammar>>> getChecks() {
return new HashSet<>(checksByRepository);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
*/
package org.sonar.cxx.sensors.utils;

import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -139,7 +137,7 @@ public static List<File> getReports(Configuration settings, final File moduleBas
* @return
*/
public static String[] splitProperty(String property) {
return Iterables.toArray(Splitter.on(',').split(property), String.class);
return property.split(",");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/
package org.sonar.cxx.sensors.visitors;

import com.google.common.collect.Sets;
import com.sonar.sslr.api.AstAndTokenVisitor;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.GenericTokenType;
Expand All @@ -28,6 +27,7 @@
import com.sonar.sslr.api.TokenType;
import com.sonar.sslr.api.Trivia;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
Expand Down Expand Up @@ -235,9 +235,9 @@ public void leaveFile(AstNode astNode) {
if (LOG.isDebugEnabled()) {
LOG.debug("CxxFileLinesVisitor: '{}'", inputFile.uri().getPath());
LOG.debug(" lines: '{}'", inputFile.lines());
LOG.debug(" executableLines: '{}'", Sets.newHashSet(executableLines));
LOG.debug(" linesOfCode: '{}'", Sets.newHashSet(linesOfCode));
LOG.debug(" linesOfComments: '{}'", Sets.newHashSet(linesOfComments));
LOG.debug(" executableLines: '{}'", new HashSet<>(executableLines));
LOG.debug(" linesOfCode: '{}'", new HashSet<>(linesOfCode));
LOG.debug(" linesOfComments: '{}'", new HashSet<>(linesOfComments));
}

linesOfCode = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
// SonarQube .NET Tests Library
// Copyright (C) 2014-2017 SonarSource SA
// mailto:info AT sonarsource DOT com
import com.google.common.base.Joiner;
import java.io.File;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -41,7 +40,7 @@ public class WildcardPatternFileProviderTest {
public ExpectedException thrown = ExpectedException.none();

private static String path(String... elements) {
return Joiner.on(File.separator).join(elements);
return String.join(File.separator, elements);
}

private static Set<File> listFiles(String pattern) {
Expand Down
Loading

0 comments on commit 059646c

Please sign in to comment.