From b57b9f561af806363738da69e185060e0ae9ad79 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Wed, 20 Dec 2023 14:22:02 +0100 Subject: [PATCH] Fix sevntu violations * remove Guava Files class * allow MoreObjects again. It's not useful to enforce removing the toString() helper class and to reimplement all toString() methods, as that could lead to functional changes. --- config/checkstyle_sevntu_checks.xml | 2 +- .../core/config/CheckConfigurationWorkingCopy.java | 4 ++-- .../core/config/GlobalCheckConfigurationWorkingSet.java | 5 ++--- .../core/config/configtypes/RemoteConfigurationType.java | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/checkstyle_sevntu_checks.xml b/config/checkstyle_sevntu_checks.xml index 8d4586f31..1bb04c3c0 100644 --- a/config/checkstyle_sevntu_checks.xml +++ b/config/checkstyle_sevntu_checks.xml @@ -48,7 +48,7 @@ java.util.Vector, java.util.Stack,com.google.collect.Iterables, com.google.common.primitives.Ints,com.google.common.base.String, com.google.common.base.Function,com.google.common.base.Supplier, - com.google.common.base.Charsets,com.google.common.base.MoreObjects, + com.google.common.base.Charsets, com.google.common.base.Optional,com.google.common.base.Equivalence, com.google.common.base.Preconditions,com.google.common.base.Predicate, com.google.common.io.CharSource,com.google.common.annotations.Beta, diff --git a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/CheckConfigurationWorkingCopy.java b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/CheckConfigurationWorkingCopy.java index 984d02755..aaa427d02 100644 --- a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/CheckConfigurationWorkingCopy.java +++ b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/CheckConfigurationWorkingCopy.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -42,7 +43,6 @@ import org.xml.sax.InputSource; import com.google.common.io.Closeables; -import com.google.common.io.Files; import net.sf.eclipsecs.core.CheckstylePlugin; import net.sf.eclipsecs.core.Messages; @@ -264,7 +264,7 @@ public void setModules(List modules) throws CheckstylePluginException { // all went ok, write to the file File configFile = URIUtil.toFile(getResolvedConfigurationFileURL().toURI()); - Files.write(byteOut.toByteArray(), configFile); + Files.write(configFile.toPath(), byteOut.toByteArray()); // refresh the files if within the workspace // Bug 1251194 - Resource out of sync after performing changes to diff --git a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/GlobalCheckConfigurationWorkingSet.java b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/GlobalCheckConfigurationWorkingSet.java index dacc1d563..8398b60d8 100644 --- a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/GlobalCheckConfigurationWorkingSet.java +++ b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/GlobalCheckConfigurationWorkingSet.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -35,8 +36,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IPath; -import com.google.common.io.Files; - import net.sf.eclipsecs.core.CheckstylePlugin; import net.sf.eclipsecs.core.Messages; import net.sf.eclipsecs.core.config.configtypes.BuiltInConfigurationType; @@ -289,7 +288,7 @@ private void storeToPersistence() throws CheckstylePluginException { // write to the file after the document creation was successful // prevents corrupted files in case of error byte[] data = XMLUtil.toByteArray(doc); - Files.write(data, configFile); + Files.write(configFile.toPath(), data); } catch (IOException ex) { CheckstylePluginException.rethrow(ex, Messages.errorWritingConfigFile); } diff --git a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/configtypes/RemoteConfigurationType.java b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/configtypes/RemoteConfigurationType.java index 58311bbf6..c0e64825c 100644 --- a/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/configtypes/RemoteConfigurationType.java +++ b/net.sf.eclipsecs.core/src/net/sf/eclipsecs/core/config/configtypes/RemoteConfigurationType.java @@ -30,6 +30,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.UnknownHostException; +import java.nio.file.Files; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.Base64; @@ -44,7 +45,6 @@ import org.eclipse.osgi.util.NLS; import com.google.common.io.ByteStreams; -import com.google.common.io.Files; import com.puppycrawl.tools.checkstyle.PropertyResolver; import net.sf.eclipsecs.core.CheckstylePlugin; @@ -266,7 +266,7 @@ private void writeToCacheFile(ICheckConfiguration checkConfig, byte[] configFile File cacheFile = cacheFilePath.toFile(); try { - Files.write(configFileBytes, cacheFile); + Files.write(cacheFile.toPath(), configFileBytes); } catch (IOException ex) { CheckstyleLog.log(ex, NLS.bind(Messages.RemoteConfigurationType_msgRemoteCachingFailed, checkConfig.getName(), checkConfig.getLocation())); @@ -282,7 +282,7 @@ private void writeToCacheFile(ICheckConfiguration checkConfig, byte[] configFile File propsCacheFile = propsCacheFilePath.toFile(); try { - Files.write(bundleBytes, propsCacheFile); + Files.write(propsCacheFile.toPath(), bundleBytes); } catch (IOException ex) { // ignore this since there simply might be no properties file }