Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure and run OpenRewrite #805

Merged
merged 12 commits into from
Jan 19, 2025
Merged
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
2 changes: 2 additions & 0 deletions net.sf.eclipsecs.checkstyle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@
import net.sf.eclipsecs.checkstyle.utils.CheckUtil;
import net.sf.eclipsecs.checkstyle.utils.XmlUtil;

public class ChecksTest {
class ChecksTest {

@Test
public void testMetadataFiles() throws Exception {
void metadataFiles() throws Exception {
final Set<Class<?>> modules = new HashSet<>(CheckUtil.getCheckstyleModules());

// don't test root modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
/**
* Class for handling preferences of the <code>net.sf.eclipsecs.core</code> plugin.
*
* @author Lars Ködderitzsch
*/
public class CheckstylePluginPrefs extends AbstractPreferenceInitializer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
/**
* Class providing messages for the checkstyle plugin. Uses the eclipse new nls mechanism.
*
* @author Lars Ködderitzsch
*/
public final class Messages extends NLS {
// CHECKSTYLE:OFF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ public class Auditor {
private IProgressMonitor mMonitor;

/** Add the check rule name to the message. */
private boolean mAddRuleName = false;
private boolean mAddRuleName;

/** Add the check module id to the message. */
private boolean mAddModuleId = false;
private boolean mAddModuleId;

/**
* Creates an auditor.
Expand Down Expand Up @@ -211,8 +211,6 @@ private IFile getFile(String fileName) {

/**
* Helper method to get an array of java.io.Files. This array gets passed to the checker.
*
* @return
*/
private List<File> getFilesList() {
List<File> files = new ArrayList<>();
Expand All @@ -226,8 +224,6 @@ private List<File> getFilesList() {
* Implementation of the audit listener. This listener creates markers on the file resources if
* checkstyle messages are reported.
*
* @author David Schneider
* @author Lars Ködderitzsch
*/
private class CheckstyleAuditListener implements AuditListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
/**
* Factory class to create (and cache) checker objects.
*
* @author Lars Ködderitzsch
*/
public final class CheckerFactory {

Expand Down Expand Up @@ -163,9 +162,7 @@ private static String getCacheKey(ICheckConfiguration config, IProject project)
URL configLocation = configFileData.getResolvedConfigFileURL();
String checkConfigName = config.getName() + "#" + (config.isGlobal() ? "Global" : "Local");

String cacheKey = project.getName() + "#" + configLocation + "#" + checkConfigName;

return cacheKey;
return project.getName() + "#" + configLocation + "#" + checkConfigName;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
/**
* Project builder for Checkstyle plug-in.
*
* @author David Schneider
* @author Lars Ködderitzsch
*/
public class CheckstyleBuilder extends IncrementalProjectBuilder {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* Base implementation of a check configuration. Leaves the specific tasks to the concrete
* subclasses.
*
* @author Lars Ködderitzsch
*/
public class CheckConfiguration implements ICheckConfiguration {

Expand Down Expand Up @@ -64,7 +63,7 @@ public class CheckConfiguration implements ICheckConfiguration {
private CheckstyleConfigurationFile mCheckstyleConfigurationFile;

/** Time stamp when the cached configuration file data expires. */
private long mExpirationTime = 0;
private long mExpirationTime;

/**
* Creates a check configuration instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,10 @@ public static ICheckConfiguration getDefaultCheckConfiguration() {
return sDefaultCheckConfig;
} else if (sDefaultBuiltInConfig != null) {
return sDefaultBuiltInConfig;
} else if (sConfigurations.size() > 0) {
} else if (!sConfigurations.isEmpty()) {
return sConfigurations.get(0);
} else {
return null;
}
return null;
}

/**
Expand Down Expand Up @@ -282,8 +281,7 @@ private static IPath getTargetStateLocation(IPath newWorkspaceRoot) {
currentStateLocation = currentStateLocation.removeFirstSegments(segmentsToRemove);

// Now add to the target workspace root
IPath targetStateLocation = newWorkspaceRoot.append(currentStateLocation);
return targetStateLocation;
return newWorkspaceRoot.append(currentStateLocation);

}

Expand Down Expand Up @@ -335,8 +333,7 @@ private static void loadFromPersistence() throws CheckstylePluginException {
private static File getInternalConfigurationFile() {
IPath configPath = CheckstylePlugin.getDefault().getStateLocation();
configPath = configPath.append(CHECKSTYLE_CONFIG_FILE);
File configFile = configPath.toFile();
return configFile;
return configPath.toFile();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
* </ul>
* .
*
* @author Lars Ködderitzsch
*/
public class CheckConfigurationTester {

Expand Down Expand Up @@ -112,7 +111,6 @@ public List<ResolvableProperty> getUnresolvedProperties() throws CheckstylePlugi
* not being resolved by a given other property resolver. This is used to find unresolved
* properties after all other property reolvers have been asked.
*
* @author Lars Ködderitzsch
*/
private static class MissingPropertyCollector implements PropertyResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
* This class acts as wrapper around check configurations to add editing aspects. Check
* configurations by themself are not editable.
*
* @author Lars Ködderitzsch
*/
public class CheckConfigurationWorkingCopy implements ICheckConfiguration, Cloneable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* Simple object containing all sort of data of a Checkstyle configuration. This is done to not
* access the Checkstyle configuration file too many times to get small bits of information.
*
* @author Lars Ködderitzsch
*/
public class CheckstyleConfigurationFile {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ public int compareTo(ConfigProperty obj) {
@Override
public ConfigProperty clone() {
try {
ConfigProperty clone = (ConfigProperty) super.clone();
return clone;
return (ConfigProperty) super.clone();
} catch (CloneNotSupportedException ex) {
// Should not happen
throw new InternalError(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
/**
* Utility class to read a checkstyle configuration and transform to the plugins module objects.
*
* @author Lars Ködderitzsch
*/
public final class ConfigurationReader {

Expand Down Expand Up @@ -201,14 +200,14 @@ private static void addProperties(final Element moduleEl, final Module module) {
final boolean isPropertyRef = (value != null)
&& PROPERTY_REF_PATTERN.matcher(value).matches();

if (name.equals(XMLTags.SEVERITY_TAG) && (module.getMetaData() != null)
if (XMLTags.SEVERITY_TAG.equals(name) && (module.getMetaData() != null)
&& module.getMetaData().hasSeverity()) {
try {
module.setSeverity(Severity.valueOf(value));
} catch (final IllegalArgumentException ex) {
module.setSeverity(Severity.inherit);
}
} else if (name.equals(XMLTags.ID_TAG)) {
} else if (XMLTags.ID_TAG.equals(name)) {
module.setId(Strings.emptyToNull(value));
} else if (module.getMetaData() != null) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
/**
* Writes the modules of a checkstyle configuration to an output stream.
*
* @author Lars Ködderitzsch
*/
public final class ConfigurationWriter {

Expand Down Expand Up @@ -110,7 +109,7 @@ public static void write(OutputStream out, List<Module> modules, ICheckConfigura
// find the root module (Checker)
// the root module is the only module that has no parent
List<Module> rootModules = getChildModules(null, modules);
if (rootModules.size() < 1) {
if (rootModules.isEmpty()) {
throw new CheckstylePluginException(Messages.errorNoRootModule);
}

Expand Down Expand Up @@ -160,7 +159,7 @@ private static void writeModule(Module module, Branch parent, Severity parentSev

// Write severity only if it differs from the parents severity
Severity severity = parentSeverity;
if (module.getSeverity() != null && !Severity.inherit.equals(module.getSeverity())) {
if (module.getSeverity() != null && Severity.inherit != module.getSeverity()) {

Element propertyEl = moduleEl.addElement(XMLTags.PROPERTY_TAG);
propertyEl.addAttribute(XMLTags.NAME_TAG, XMLTags.SEVERITY_TAG);
Expand Down Expand Up @@ -240,7 +239,7 @@ private static List<Module> getChildModules(Module module, List<Module> remainin
String childParent = tmp.getMetaData().getParentModule();

// only the checker module has no parent
if (parentInternalName == null && childParent.equals("Root")) {
if (parentInternalName == null && "Root".equals(childParent)) {
childModules.add(tmp);
} else if (childParent.equals(parentInternalName)) {
childModules.add(tmp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
* Working set implementation that manages global configurations configured for the Eclipse
* workspace.
*
* @author Lars Ködderitzsch
*/
public class GlobalCheckConfigurationWorkingSet implements ICheckConfigurationWorkingSet {

Expand Down Expand Up @@ -168,7 +167,7 @@ public void store() throws CheckstylePluginException {

@Override
public boolean isDirty() {
if (mDeletedConfigurations.size() > 0) {
if (!mDeletedConfigurations.isEmpty()) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/**
* Interface for a check configuration object.
*
* @author Lars Ködderitzsch
*/
public interface ICheckConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
/**
* Interface for implementations that provide editing services for a group of check configuration.
*
* @author Lars Ködderitzsch
*/
public interface ICheckConfigurationWorkingSet {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
/**
* Object representing a module from a checkstyle configuration. Can be augmented with meta data.
*
* @author Lars Ködderitzsch
*/
public class Module implements Cloneable {

Expand Down Expand Up @@ -272,11 +271,11 @@ public void setSeverity(Severity severityLevel) {
}

if (defaultLevel != null) {
if (severityLevel.equals(defaultLevel)) {
if (severityLevel == defaultLevel) {
mSeverityLevel = null;
setLastEnabledSeverity(null);
} else if (Severity.ignore.equals(severityLevel)) {
if (mSeverityLevel != null && !Severity.ignore.equals(mSeverityLevel)) {
} else if (Severity.ignore == severityLevel) {
if (mSeverityLevel != null && Severity.ignore != mSeverityLevel) {
setLastEnabledSeverity(mSeverityLevel);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
/**
* Represents a configuration property who's value must be resolved.
*
* @author David Schneider
* @author Lars Ködderitzsch
*/
public class ResolvableProperty implements Cloneable {

Expand Down Expand Up @@ -101,8 +99,7 @@ public int hashCode() {
@Override
public ResolvableProperty clone() {
try {
ResolvableProperty clone = (ResolvableProperty) super.clone();
return clone;
return (ResolvableProperty) super.clone();
} catch (CloneNotSupportedException ex) {
// should never happen
throw new InternalError(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
* Enumeration for Checkstyle's severity levels. The intent is to decouple highler level funtions
* (UI) from dealing with Checkstyle code API.
*
* @author Lars Ködderitzsch
*/
public enum Severity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
* Implementation of the configuration type for a built in check configuration, that is located
* inside the plugin.
*
* @author Lars Ködderitzsch
*/
public class BuiltInConfigurationType extends ConfigurationType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* Adds support for additional checkstyle config files (header, suppressions etc.) to be delivered
* with a builtin configuration.
*
* @author Lars Ködderitzsch
*/
public class BuiltInFilePropertyResolver implements PropertyResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
/**
* Property resolver that tries to resolve values from classpath variables.
*
* @author Lars Ködderitzsch
*/
public class ClasspathVariableResolver implements PropertyResolver {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
/**
* Base implementation of <code>IConfigurationType</code>.
*
* @author Lars Ködderitzsch
*/
public abstract class ConfigurationType implements IConfigurationType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
* Register for the configuration types thats use the <i>net.sf.eclipsecs.core.configurationtypes
* </i> extension point.
*
* @author Lars Ködderitzsch
*/
public final class ConfigurationTypes {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
/**
* Implementation of a check configuration that uses an exteral checkstyle configuration file.
*
* @author Lars Ködderitzsch
*/
public class ExternalFileConfigurationType extends ConfigurationType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
/**
* Interface for a configuration type.
*
* @author Lars Ködderitzsch
*/
public interface IConfigurationType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
/**
* Interface for plugin property resolvers.
*
* @author Lars Ködderitzsch
*/
public interface IContextAware {

Expand Down
Loading
Loading