Skip to content

Commit 2fdba8f

Browse files
committed
Apply RSPEC-6112 over the whole repository
1 parent 4ee40fd commit 2fdba8f

File tree

214 files changed

+956
-983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+956
-983
lines changed

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleController.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public Bundle getBundle(String location) {
168168
@Override
169169
public ServiceReference<?>[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
170170
//Filters are based on class names
171-
String interfaceClassName = (null == clazz) ? filter : clazz;
171+
var interfaceClassName = (null == clazz) ? filter : clazz;
172172
return services.getReferences(interfaceClassName);
173173
}
174174

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ResourceAccessor.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ResourceAccessor {
6363
/** Resources are located in the JAR of the given class
6464
* @throws BundleException */
6565
ResourceAccessor(Class<?> clazz) throws BundleException {
66-
String bundleObjPath = clazz.getName();
66+
var bundleObjPath = clazz.getName();
6767
fatJarResourcePath = bundleObjPath.substring(0, bundleObjPath.lastIndexOf('.'));
6868
try {
6969
bundleFile = getBundlFile(clazz);
@@ -74,7 +74,7 @@ class ResourceAccessor {
7474

7575
private static BundleFile getBundlFile(Class<?> clazz) throws BundleException {
7676
URI objUri = getBundleUri(clazz);
77-
File jarOrDirectory = new File(objUri.getPath());
77+
var jarOrDirectory = new File(objUri.getPath());
7878
if (!(jarOrDirectory.exists() && jarOrDirectory.canRead())) {
7979
throw new BundleException(String.format("Path '%s' for '%s' is not accessible exist on local file system.", objUri, clazz.getName()), BundleException.READ_ERROR);
8080
}
@@ -87,7 +87,7 @@ private static BundleFile getBundlFile(Class<?> clazz) throws BundleException {
8787

8888
private static URI getBundleUri(Class<?> clazz) throws BundleException {
8989
try {
90-
URL objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
90+
var objUrl = clazz.getProtectionDomain().getCodeSource().getLocation();
9191
return objUrl.toURI();
9292
} catch (NullPointerException e) {
9393
//No bunlde should be used for RT classes lookup. See also org.eclipse.core.runtime.PerformanceStats.
@@ -101,10 +101,10 @@ private static URI getBundleUri(Class<?> clazz) throws BundleException {
101101

102102
/** Get the manifest name from the resources. */
103103
String getManifestName() throws BundleException {
104-
URL manifestUrl = getEntry(JarFile.MANIFEST_NAME);
104+
var manifestUrl = getEntry(JarFile.MANIFEST_NAME);
105105
if (null != manifestUrl) {
106106
try {
107-
Manifest manifest = new Manifest(manifestUrl.openStream());
107+
var manifest = new Manifest(manifestUrl.openStream());
108108
String headerValue = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
109109
if (null == headerValue) {
110110
throw new BundleException(String.format("Symbolic values not found in '%s'.", manifestUrl), BundleException.MANIFEST_ERROR);

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/osgi/ServiceCollection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void set(String key, String value) {
7676

7777
@Override
7878
public <S> void add(Class<S> interfaceClass, S service) throws ServiceException {
79-
String className = interfaceClass.getName();
79+
var className = interfaceClass.getName();
8080
if (null != className2Service.put(interfaceClass.getName(), new FrameworkServiceReference<S>(className, service))) {
8181
throw new ServiceException(
8282
String.format("Service '%s' is already registered.", interfaceClass.getName()), ServiceException.FACTORY_ERROR);

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/runtime/PluginRegistrar.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class PluginRegistrar {
3939
private static final String PLUGIN_PROPERTIES = "plugin.properties";
4040

4141
public static BundleException register(Bundle bundle) {
42-
PluginRegistrar registrar = new PluginRegistrar(bundle);
42+
var registrar = new PluginRegistrar(bundle);
4343
try {
4444
registrar.register();
4545
} catch (BundleException e) {

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/SingleSlf4JService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ public long getTime() {
459459

460460
@Override
461461
public String toString() {
462-
StringWriter result = new StringWriter();
462+
var result = new StringWriter();
463463
result.write(message);
464464
if (execption.isPresent()) {
465465
result.write('\n');

_ext/eclipse-base/src/main/java/com/diffplug/spotless/extra/eclipse/base/service/TemporaryLocation.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private TemporaryLocation(Location parent, URL defaultValue) {
4444

4545
private static URL createTemporaryDirectory() {
4646
try {
47-
Path location = Files.createTempDirectory(TEMP_PREFIX);
47+
var location = Files.createTempDirectory(TEMP_PREFIX);
4848
return location.toUri().toURL();
4949
} catch (IOException e) {
5050
throw new IOError(e);
@@ -120,7 +120,7 @@ public Location createLocation(Location parent, URL defaultValue, boolean readon
120120
@Override
121121
public URL getDataArea(String path) throws IOException {
122122
try {
123-
Path locationPath = Paths.get(location.toURI());
123+
var locationPath = Paths.get(location.toURI());
124124
return locationPath.resolve(path).toUri().toURL();
125125
} catch (URISyntaxException e) {
126126
throw new IOException("Location not correctly formatted.", e);
@@ -130,7 +130,7 @@ public URL getDataArea(String path) throws IOException {
130130
@Override
131131
public void close() throws Exception {
132132
try {
133-
Path path = Path.of(location.toURI());
133+
var path = Path.of(location.toURI());
134134
Files.walk(path)
135135
.sorted(Comparator.reverseOrder())
136136
.map(Path::toFile)

_ext/eclipse-base/src/test/java/com/diffplug/spotless/extra/eclipse/base/SpotlessEclipseFrameworkTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void println(String x) {
251251
@Override
252252
public void println(Object x) {
253253
if (x instanceof Exception) {
254-
Exception e = (Exception) x;
254+
var e = (Exception) x;
255255
if (TEST_EXCEPTION_MESSAGE == e.getMessage()) {
256256
messages.add(TEST_EXCEPTION_MESSAGE);
257257
}

_ext/eclipse-base/src/test/java/com/diffplug/spotless/extra/eclipse/base/osgi/BundleSetTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void testAddGet() throws BundleException {
4949

5050
@Test
5151
void testSameSymbolicName() throws BundleException {
52-
final String symbolicName = "sym.a";
52+
final var symbolicName = "sym.a";
5353
final long id1 = 12345;
5454
final long id2 = 23456;
5555
Bundle testBundle1 = new TestBundle(id1, symbolicName);
@@ -63,8 +63,8 @@ void testSameSymbolicName() throws BundleException {
6363

6464
@Test
6565
void testSameID() throws BundleException {
66-
final String symbolicName1 = "sym.a";
67-
final String symbolicName2 = "sym.b";
66+
final var symbolicName1 = "sym.a";
67+
final var symbolicName2 = "sym.b";
6868
final long id = 12345;
6969
Bundle testBundle1 = new TestBundle(id, symbolicName1);
7070
Bundle testBundle2 = new TestBundle(id, symbolicName2);

_ext/eclipse-base/src/test/java/com/diffplug/spotless/extra/eclipse/base/osgi/ServiceCollectionTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ void initialize() {
3939

4040
@Test
4141
void testAddGet() {
42-
Service1 service1 = new Service1();
43-
Service2 service2 = new Service2();
42+
var service1 = new Service1();
43+
var service2 = new Service2();
4444
instance.add(Interf1.class, service1);
4545
instance.add(Interf2a.class, service2);
4646
instance.add(Interf2b.class, service2);
@@ -51,8 +51,8 @@ void testAddGet() {
5151

5252
@Test
5353
void testMultipleServicesPerInterface() {
54-
Service1 serviceX = new Service1();
55-
Service1 serviceY = new Service1();
54+
var serviceX = new Service1();
55+
var serviceY = new Service1();
5656
instance.add(Interf1.class, serviceX);
5757
ServiceException e = assertThrows(ServiceException.class, () -> instance.add(Interf1.class, serviceY));
5858
assertThat(e.getMessage()).as("ServiceException does not contain interface class name.").contains(Interf1.class.getName());

_ext/eclipse-wtp/src/main/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseHtmlFormatterStepImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public void activatePlugins(SpotlessEclipsePluginConfig config) {
141141
* The HTML formatter only uses the DOCTYPE/SCHEMA for content model selection.
142142
* Hence no external URIs are required.
143143
*/
144-
boolean allowExternalURI = false;
144+
var allowExternalURI = false;
145145
EclipseXmlFormatterStepImpl.FrameworkConfig.activateXmlPlugins(config, allowExternalURI);
146146
config.add(new HTMLCorePlugin());
147147
}

_ext/eclipse-wtp/src/main/java/com/diffplug/spotless/extra/eclipse/wtp/html/StructuredDocumentProcessor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public StructuredDocumentProcessor(IStructuredDocument document, String type,
6363

6464
/** Applies processor on document, using a given formatter */
6565
public void apply(T formatter) {
66-
for (int currentRegionId = 0; currentRegionId < numberOfRegions; currentRegionId++) {
66+
for (var currentRegionId = 0; currentRegionId < numberOfRegions; currentRegionId++) {
6767
applyOnRegion(currentRegionId, formatter);
6868
}
6969
}
@@ -132,7 +132,7 @@ public int getLastLine() {
132132
}
133133

134134
private static int computeIndent(IStructuredDocument document, ITypedRegion region, String htmlIndent) {
135-
int indent = 0;
135+
var indent = 0;
136136
try {
137137
int lineNumber = document.getLineOfOffset(region.getOffset());
138138
document.getNumberOfLines();
@@ -180,7 +180,7 @@ protected void fixTagIndent(MultiTextEdit modifications, int offset, String inde
180180
int lineStart = document.getLineOffset(lineNumber);
181181
int lineEnd = document.getLineOffset(lineNumber + 1);
182182
String lineContent = document.get(lineStart, lineEnd - lineStart);
183-
StringBuilder currentIndent = new StringBuilder();
183+
var currentIndent = new StringBuilder();
184184
lineContent.chars().filter(c -> {
185185
if (c == ' ' || c == '\t') {
186186
currentIndent.append(c);

_ext/eclipse-wtp/src/main/java/com/diffplug/spotless/extra/eclipse/wtp/sse/PluginPreferences.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ public static void configureCatalog(final Properties properties, final ICatalog
9696
throw new IllegalArgumentException("Internal error: Catalog implementation '" + defaultCatalogInterface.getClass().getCanonicalName() + "' unsupported.");
9797
}
9898
Catalog defaultCatalog = (Catalog) defaultCatalogInterface;
99-
String catalogProperty = properties.getProperty(USER_CATALOG, "");
99+
var catalogProperty = properties.getProperty(USER_CATALOG, "");
100100
if (!catalogProperty.isEmpty()) {
101-
final File catalogFile = new File(catalogProperty);
101+
final var catalogFile = new File(catalogProperty);
102102
try {
103103
InputStream inputStream = new FileInputStream(catalogFile);
104104
String orgBase = defaultCatalog.getBase();
@@ -118,7 +118,7 @@ public static void configureCatalog(final Properties properties, final ICatalog
118118
public static void assertNoChanges(Plugin plugin, Properties properties) {
119119
Objects.requireNonNull(properties, "Property values are missing.");
120120
final String preferenceId = plugin.getBundle().getSymbolicName();
121-
Properties originalValues = CONFIG.get(preferenceId);
121+
var originalValues = CONFIG.get(preferenceId);
122122
if (null == originalValues) {
123123
throw new IllegalArgumentException("No configuration found for " + preferenceId);
124124
}

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseCssFormatterStepImplTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void initialize() throws Exception {
4141
* All formatter configuration is stored in
4242
* org.eclipse.core.runtime/.settings/org.eclipse.wst.css.core.prefs.
4343
*/
44-
Properties properties = new Properties();
44+
var properties = new Properties();
4545
properties.put(INDENTATION_SIZE, "3");
4646
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB
4747
properties.put(CLEANUP_CASE_SELECTOR, Integer.toString(UPPER)); //Done by cleanup

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseHtmlFormatterStepImplTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void initialize() throws Exception {
4040
* org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.core.prefs.
4141
* So a simple test of one configuration item change is considered sufficient.
4242
*/
43-
Properties properties = new Properties();
43+
var properties = new Properties();
4444
properties.put(CLEANUP_TAG_NAME_CASE, Integer.toString(HTMLCorePreferenceNames.UPPER)); //HTML config
4545
properties.put(FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, JavaScriptCore.INSERT); //JS config
4646
properties.put(QUOTE_ATTR_VALUES, "TRUE"); //CSS config
@@ -89,7 +89,7 @@ void formatCSS() throws Exception {
8989

9090
@Test
9191
void checkCleanupForNonUtf8() throws Exception {
92-
String osEncoding = System.getProperty("file.encoding");
92+
var osEncoding = System.getProperty("file.encoding");
9393
System.setProperty("file.encoding", "ISO-8859-1"); //Simulate a non UTF-8 OS
9494
String[] input = testData.input("utf-8.html");
9595
String output = formatter.format(input[0]);

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseJsFormatterStepImplTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void initialize() throws Exception {
5050
* All formatter configuration is stored in
5151
* org.eclipse.core.runtime/.settings/org.eclipse.jst.jsdt.core.prefs.
5252
*/
53-
Properties properties = new Properties();
53+
var properties = new Properties();
5454
properties.setProperty(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaScriptCore.TAB);
5555
formatter = new EclipseJsFormatterStepImpl(properties);
5656
}

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseJsonFormatterStepImplTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void initialize() throws Exception {
4141
* org.eclipse.core.runtime/.settings/org.eclipse.wst.json.core.prefs.
4242
* So a simple test of one configuration item change is considered sufficient.
4343
*/
44-
Properties properties = new Properties();
44+
var properties = new Properties();
4545
properties.put(INDENTATION_SIZE, "3"); //Default is 1
4646
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB
4747
properties.put(CASE_PROPERTY_NAME, Integer.toString(UPPER)); //Dead code, ignored

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseXmlFormatterStepImplAllowExternalURIsTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void initializeStatic() throws Exception {
4141
* org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.core.prefs.
4242
* So a simple test of one configuration item change is considered sufficient.
4343
*/
44-
Properties properties = new Properties();
44+
var properties = new Properties();
4545
properties.put(PluginPreferences.RESOLVE_EXTERNAL_URI, "TRUE");
4646
properties.put(INDENTATION_SIZE, "2");
4747
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseXmlFormatterStepImplCatalogLookupTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void initializeStatic() throws Exception {
4141
* org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.core.prefs.
4242
* So a simple test of one configuration item change is considered sufficient.
4343
*/
44-
Properties properties = new Properties();
44+
var properties = new Properties();
4545
properties.put(INDENTATION_SIZE, "2");
4646
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB
4747
properties.put(PluginPreferences.USER_CATALOG, testData.getRestrictionsPath("catalog.xml").toString());

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/EclipseXmlFormatterStepImplTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void initialize() throws Exception {
4242
* org.eclipse.core.runtime/.settings/org.eclipse.wst.xml.core.prefs.
4343
* So a simple test of one configuration item change is considered sufficient.
4444
*/
45-
Properties properties = new Properties();
45+
var properties = new Properties();
4646
properties.put(INDENTATION_SIZE, "2");
4747
properties.put(INDENTATION_CHAR, SPACE); //Default is TAB
4848
formatter = new EclipseXmlFormatterStepImpl(properties);

_ext/eclipse-wtp/src/test/java/com/diffplug/spotless/extra/eclipse/wtp/TestData.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
public class TestData {
2424
public static TestData getTestDataOnFileSystem(String kind) {
25-
final String userDir = System.getProperty("user.dir", ".");
26-
Path dataPath = Paths.get(userDir, "src", "test", "resources", kind);
25+
final var userDir = System.getProperty("user.dir", ".");
26+
var dataPath = Paths.get(userDir, "src", "test", "resources", kind);
2727
if (Files.isDirectory(dataPath)) {
2828
return new TestData(dataPath);
2929
}
@@ -46,12 +46,12 @@ private TestData(Path dataPath) {
4646
}
4747

4848
public String[] input(final String fileName) throws Exception {
49-
Path xmlPath = inputPath.resolve(fileName);
49+
var xmlPath = inputPath.resolve(fileName);
5050
return new String[]{read(xmlPath), xmlPath.toString()};
5151
}
5252

5353
public String expected(final String fileName) {
54-
Path xmlPath = expectedPath.resolve(fileName);
54+
var xmlPath = expectedPath.resolve(fileName);
5555
return read(xmlPath);
5656
}
5757

@@ -60,15 +60,15 @@ private String read(final Path xmlPath) {
6060
throw new IllegalArgumentException(String.format("'%1$s' is not a regular file.", xmlPath));
6161
}
6262
try {
63-
String checkedOutFileContent = new String(java.nio.file.Files.readAllBytes(xmlPath), "UTF8");
63+
var checkedOutFileContent = new String(java.nio.file.Files.readAllBytes(xmlPath), "UTF8");
6464
return checkedOutFileContent.replace("\r", ""); //Align GIT end-of-line normalization
6565
} catch (IOException e) {
6666
throw new IllegalArgumentException(String.format("Failed to read '%1$s'.", xmlPath), e);
6767
}
6868
}
6969

7070
public Path getRestrictionsPath(String fileName) {
71-
Path filePath = restrictionsPath.resolve(fileName);
71+
var filePath = restrictionsPath.resolve(fileName);
7272
if (!Files.exists(filePath)) {
7373
throw new IllegalArgumentException(String.format("'%1$s' is not a restrictions file.", fileName));
7474
}

lib-extra/src/groovy/java/com/diffplug/spotless/extra/glue/groovy/GrEclipseFormatterStepImpl.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public GrEclipseFormatterStepImpl(final Properties properties) throws Exception
8989
/** Formatting Groovy string */
9090
public String format(String raw) throws Exception {
9191
IDocument doc = new Document(raw);
92-
GroovyErrorListener errorListener = new GroovyErrorListener();
92+
var errorListener = new GroovyErrorListener();
9393
TextSelection selectAll = new TextSelection(doc, 0, doc.getLength());
9494
GroovyFormatter codeFormatter = new DefaultGroovyFormatter(selectAll, doc, preferencesStore, false);
9595
TextEdit edit = codeFormatter.format();
@@ -135,7 +135,7 @@ public boolean errorsDetected() {
135135

136136
@Override
137137
public String toString() {
138-
StringBuilder string = new StringBuilder();
138+
var string = new StringBuilder();
139139
if (1 < errors.size()) {
140140
string.append("Multiple problems detected during step execution:");
141141
} else if (0 == errors.size()) {
@@ -168,9 +168,9 @@ public void log(TraceCategory arg0, String arg1) {
168168

169169
private static PreferenceStore createPreferences(final Properties properties) throws IOException {
170170
final PreferenceStore preferences = new PreferenceStore();
171-
ByteArrayOutputStream output = new ByteArrayOutputStream();
171+
var output = new ByteArrayOutputStream();
172172
properties.store(output, null);
173-
ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
173+
var input = new ByteArrayInputStream(output.toByteArray());
174174
preferences.load(input);
175175
return preferences;
176176
}

0 commit comments

Comments
 (0)