Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
sanityCheck:
sanity-check:
name: SanityCheck
runs-on: ubuntu-latest
env:
buildcacheuser: ${{ secrets.BUILDCACHE_USER }}
Expand All @@ -35,7 +36,7 @@ jobs:
- name: assemble testClasses
run: ./gradlew assemble testClasses
build:
needs: sanityCheck
needs: sanity-check
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -107,7 +108,7 @@ jobs:
# Status check that is required in branch protection rules.
final-status:
needs:
- sanityCheck
- sanity-check
- build
runs-on: ubuntu-latest
if: always()
Expand Down
53 changes: 43 additions & 10 deletions gradle/error-prone.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
apply plugin: 'net.ltgt.errorprone'
import static java.lang.System.getenv

dependencies {
errorprone('com.google.errorprone:error_prone_core:2.42.0')
errorprone('tech.picnic.error-prone-support:error-prone-contrib:0.26.0')
}
apply plugin: 'net.ltgt.errorprone'

tasks.withType(JavaCompile).configureEach {
options.errorprone {
disable( // consider fix, or reasoning.
disableAllWarnings = true // https://github.com/diffplug/spotless/issues/2745 https://github.com/google/error-prone/issues/5365
disable(
// consider fix, or reasoning.
'AnnotateFormatMethod', // We don`t want to use ErrorProne's annotations.
'CheckReturnValue', // We don`t want to use ErrorProne's annotations.
'CollectorMutability', // for freedom global exclude, might whitelist. https://github.com/diffplug/spotless/pull/2744#discussion_r2553042130
'DoNotCallSuggester', // We don`t want to use ErrorProne's annotations.
'FunctionalInterfaceMethodChanged',
'ImmutableEnumChecker', // We don`t want to use ErrorProne's annotations.
'InlineMeSuggester', // We don`t want to use ErrorProne's annotations.
'JUnitClassModifiers',
'JavaxInjectOnAbstractMethod',
'LexicographicalAnnotationAttributeListing',
'NonStaticImport',
'StaticImport',
'LexicographicalAnnotationListing',
'OverridesJavaxInjectableMethod',
'ReturnValueIgnored', // We don`t want to use ErrorProne's annotations.
// bug
'FieldMissingNullable',
'Slf4jLogStatement',
'Slf4jLoggerDeclaration',
'Var'
)
error(
'AmbiguousJsonCreator',
Expand All @@ -26,25 +42,42 @@ tasks.withType(JavaCompile).configureEach {
'IdentityConversion',
'ImmutablesSortedSetComparator',
'IsInstanceLambdaUsage',
'MissingOverride',
'MockitoMockClassReference',
'MockitoStubbing',
'NestedOptionals',
'NonStaticImport',
'PrimitiveComparison',
'RedundantStringConversion',
'RedundantStringEscape',
'ReturnValueIgnored',
'SelfAssignment',
'StaticImport',
'StringJoin',
'StringJoining',
'UnnecessarilyFullyQualified',
'UnnecessaryLambda',
)
// bug: this only happens when the file is dirty.
// might be an up2date (caching) issue, as file is currently in corrupt state.
// ForbidGradleInternal(import org.gradle.api.internal.project.ProjectInternal;)
errorproneArgs.add('-XepExcludedPaths:' +
'.*/SelfTest.java|' +
'.*/GradleIntegrationHarness.java'
// ForbidGradleInternal(import
excludedPaths.set(
'.*/GradleIntegrationHarness.java|'+
'.*/SelfTest.java'
)
if (!getenv().containsKey('CI') && getenv('IN_PLACE')?.toBoolean()) {
errorproneArgs.addAll(
'-XepPatchLocation:IN_PLACE', // how to prevent/ignore? @CanIgnoreReturnValue
'-XepPatchChecks:' +
'MissingOverride,' +
'NonStaticImport,' +
'StaticImport'
)
}
}
}

dependencies {
errorprone('com.google.errorprone:error_prone_core:2.42.0')
errorprone('tech.picnic.error-prone-support:error-prone-contrib:0.26.0')
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
*/
package com.diffplug.spotless.extra.glue.cdt;

import static java.util.stream.Collectors.toMap;

import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.eclipse.cdt.core.ToolFactory;
Expand All @@ -33,7 +34,7 @@ public class EclipseCdtFormatterStepImpl {

public EclipseCdtFormatterStepImpl(Properties settings) throws Exception {
Stream<Entry<Object, Object>> stream = settings.entrySet().stream();
Map<String, String> settingsMap = stream.collect(Collectors.toMap(
Map<String, String> settingsMap = stream.collect(toMap(
e -> String.valueOf(e.getKey()),
e -> String.valueOf(e.getValue())));
codeFormatter = ToolFactory.createDefaultCodeFormatter(settingsMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
*/
package com.diffplug.spotless.extra.glue.groovy;

import static java.util.Collections.synchronizedList;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -111,7 +112,7 @@ public GroovyErrorListener() {
* We need a synchronized list here, in case multiple instantiations
* run in parallel.
*/
errors = Collections.synchronizedList(new ArrayList<>());
errors = synchronizedList(new ArrayList<>());
ILog groovyLogger = GroovyCoreActivator.getDefault().getLog();
groovyLogger.addLogListener(this);
synchronized (GroovyLogManager.manager) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2024 DiffPlug
* Copyright 2016-2025 DiffPlug
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,11 +15,12 @@
*/
package com.diffplug.spotless.extra.glue.jdt;

import static java.util.stream.Collectors.toMap;

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;

import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jdt.internal.compiler.env.IModule;
Expand All @@ -37,7 +38,7 @@ public class EclipseJdtFormatterStepImpl {
private final EclipseJdtSortMembers.SortProperties sortProperties;

public EclipseJdtFormatterStepImpl(Properties formatterSettings, Map<String, String> sortProperties) {
Map<String, String> options = formatterSettings.entrySet().stream().collect(Collectors.toMap(
Map<String, String> options = formatterSettings.entrySet().stream().collect(toMap(
e -> String.valueOf(e.getKey()),
e -> String.valueOf(e.getValue()),
(prev, next) -> next,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,64 +98,84 @@ private static class Buffer implements IBuffer {
this.contents = contents;
}

@Override
public void addBufferChangedListener(IBufferChangedListener listener) {}

@Override
public void append(char[] text) {}

@Override
public void append(String text) {}

@Override
public void close() {}

@Override
public char getChar(int position) {
return '\u0000';
}

@Override
public char[] getCharacters() {
return contents.toCharArray();
}

@Override
public String getContents() {
return contents;
}

@Override
public int getLength() {
return 0;
}

@Override
public IOpenable getOwner() {
return null;
}

@Override
public String getText(int offset, int length) {
return null;
}

@Override
public IResource getUnderlyingResource() {
return null;
}

@Override
public boolean hasUnsavedChanges() {
return false;
}

@Override
public boolean isClosed() {
return false;
}

@Override
public boolean isReadOnly() {
return true;
}

@Override
public void removeBufferChangedListener(IBufferChangedListener listener) {}

@Override
public void replace(int position, int length, char[] text) {}

@Override
public void replace(int position, int length, String text) {}

@Override
public void save(IProgressMonitor progress, boolean force) {}

@Override
public void setContents(char[] contents) {}

@Override
public void setContents(String contents) {
this.contents = contents;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
*/
package com.diffplug.spotless.extra;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Objects.requireNonNull;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Properties;

import com.diffplug.common.base.Errors;
Expand Down Expand Up @@ -69,10 +70,10 @@ public EclipseBasedStepBuilder(String formatterName, Provisioner jarProvisioner,

/** Initialize valid default configuration, taking latest version */
public EclipseBasedStepBuilder(String formatterName, String formatterStepExt, Provisioner jarProvisioner, SerializedFunction<State, FormatterFunc> stateToFormatter) {
this.formatterName = Objects.requireNonNull(formatterName, "formatterName");
this.formatterStepExt = Objects.requireNonNull(formatterStepExt, "formatterStepExt");
this.jarProvisioner = Objects.requireNonNull(jarProvisioner, "jarProvisioner");
this.stateToFormatter = Objects.requireNonNull(stateToFormatter, "stateToFormatter");
this.formatterName = requireNonNull(formatterName, "formatterName");
this.formatterStepExt = requireNonNull(formatterStepExt, "formatterStepExt");
this.jarProvisioner = requireNonNull(jarProvisioner, "jarProvisioner");
this.stateToFormatter = requireNonNull(stateToFormatter, "stateToFormatter");
formatterVersion = "No version set"; //Will fail creation
}

Expand All @@ -91,7 +92,7 @@ public void setVersion(String version) {
throw new IllegalArgumentException("No such version " + version + ", expected at " + url);
}
byte[] content = toByteArray(depsFile);
String allLines = new String(content, StandardCharsets.UTF_8);
String allLines = new String(content, UTF_8);
String[] lines = allLines.split("\n");
dependencies.clear();
for (String line : lines) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.diffplug.spotless.extra;

import static java.util.Objects.requireNonNullElse;
import static java.util.stream.Collectors.toMap;

import java.io.File;
Expand All @@ -24,7 +25,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -190,8 +190,8 @@ static class EquoStep implements Serializable {
ImmutableMap<String, String> stepProperties) {

this.semanticVersion = semanticVersion;
this.settingProperties = Objects.requireNonNullElse(settingProperties, new ArrayList<>());
this.settingXml = Objects.requireNonNullElse(settingXml, new ArrayList<>());
this.settingProperties = requireNonNullElse(settingProperties, new ArrayList<>());
this.settingXml = requireNonNullElse(settingXml, new ArrayList<>());
this.settingsPromise = settingsPromise;
this.jarPromise = jarPromise;
this.stepProperties = stepProperties;
Expand All @@ -218,8 +218,8 @@ public static class State implements Serializable {
public State(String semanticVersion, JarState jarState, List<String> settingProperties, List<String> settingXml, FileSignature settingsFiles, ImmutableMap<String, String> stepProperties) {
this.semanticVersion = semanticVersion;
this.jarState = jarState;
this.settingProperties = Objects.requireNonNullElse(settingProperties, new ArrayList<>());
this.settingXml = Objects.requireNonNullElse(settingXml, new ArrayList<>());
this.settingProperties = requireNonNullElse(settingProperties, new ArrayList<>());
this.settingXml = requireNonNullElse(settingXml, new ArrayList<>());
this.settingsFiles = settingsFiles;
this.stepProperties = stepProperties;
}
Expand Down
Loading
Loading