Skip to content

Commit

Permalink
Add Checkstyle 10.18.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jshiell committed Aug 25, 2024
1 parent be58b5c commit b62c2f0
Show file tree
Hide file tree
Showing 19 changed files with 50 additions and 84 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

# CheckStyle-IDEA Changelog

* **5.94.0** New: Added CheckStyle 10.18.0.
* **5.93.5** Fixed: Improve fallback when the serialised Checkstyle version to use is absent (#648).
* **5.93.4** Fixed: resolved case-sensitivity problem that was breaking builds on case-sensitive FSs (in particular, CI) (#646).
* **5.93.3** WiP: test release to verify artefact generation on CI (#646).
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id("org.infernus.idea.checkstyle.build")
}

version = "5.93.5"
version = "5.94.0."

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,8 @@ public Map<PsiFile, List<Problem>> scan(@NotNull final CheckstyleInternalObject

@Override
public CheckstyleInternalObject loadConfiguration(@NotNull final ConfigurationLocation inputFile,
final boolean ignoreVariables,
@Nullable final Map<String, String> variables) {
OpLoadConfiguration cmd;
if (ignoreVariables) {
cmd = new OpLoadConfiguration(inputFile, checkstyleProjectService);
} else {
cmd = new OpLoadConfiguration(inputFile, variables, checkstyleProjectService);
}
return executeCommand(cmd);
return executeCommand(new OpLoadConfiguration(inputFile, variables, checkstyleProjectService));
}

@Override
Expand All @@ -100,15 +93,8 @@ public CheckstyleInternalObject loadConfiguration(@NotNull final ConfigurationLo

@Override
public CheckstyleInternalObject loadConfiguration(@NotNull final VirtualFile inputFile,
final boolean ignoreVariables,
@Nullable final Map<String, String> variables) {
OpLoadConfiguration cmd;
if (ignoreVariables) {
cmd = new OpLoadConfiguration(inputFile, checkstyleProjectService);
} else {
cmd = new OpLoadConfiguration(inputFile, variables, checkstyleProjectService);
}
return executeCommand(cmd);
return executeCommand(new OpLoadConfiguration(inputFile, variables, checkstyleProjectService));
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.infernus.idea.checkstyle.CheckstyleProjectService;
import org.infernus.idea.checkstyle.exception.CheckstyleServiceException;
import org.infernus.idea.checkstyle.model.ConfigurationLocation;
import org.infernus.idea.checkstyle.service.IgnoringResolver;
import org.infernus.idea.checkstyle.service.RulesContainer;
import org.infernus.idea.checkstyle.service.RulesContainer.ConfigurationLocationRulesContainer;
import org.infernus.idea.checkstyle.service.RulesContainer.ContentRulesContainer;
Expand All @@ -32,6 +31,7 @@
import java.util.Map;

import static java.lang.String.format;
import static java.util.Objects.requireNonNullElseGet;
import static org.infernus.idea.checkstyle.CheckStyleBundle.message;
import static org.infernus.idea.checkstyle.util.Notifications.showError;
import static org.infernus.idea.checkstyle.util.Notifications.showWarning;
Expand Down Expand Up @@ -108,11 +108,7 @@ private OpLoadConfiguration(final RulesContainer rulesContainer,
this.module = module;
this.checkstyleProjectService = checkstyleProjectService;

if (properties != null) {
resolver = new SimpleResolver(properties);
} else {
resolver = new IgnoringResolver();
}
resolver = new SimpleResolver(requireNonNullElseGet(properties, Map::of));
}

private static Map<String, String> buildReplacementsMap() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
Expand Down Expand Up @@ -404,7 +405,10 @@ public void testLoadBundledSunChecks() {
when(projectService.underlyingClassLoader()).thenReturn(getClass().getClassLoader());

CheckstyleInternalObject csConfig = new CheckstyleActionsImpl(PROJECT, projectService)
.loadConfiguration(clf.create(BundledConfig.SUN_CHECKS, TestHelper.mockProject()), true, null);
.loadConfiguration(clf.create(BundledConfig.SUN_CHECKS, TestHelper.mockProject()), Map.of(
"org.checkstyle.sun.suppressionfilter.config", "",
"org.checkstyle.sun.suppressionxpathfilter.config", ""
));
Assert.assertNotNull(csConfig);
}

Expand All @@ -415,7 +419,10 @@ public void testLoadBundledGoogleChecks() {
CheckstyleProjectService projectService = mock(CheckstyleProjectService.class);
when(projectService.underlyingClassLoader()).thenReturn(getClass().getClassLoader());
CheckstyleInternalObject csConfig = new CheckstyleActionsImpl(PROJECT, projectService)
.loadConfiguration(clf.create(BundledConfig.GOOGLE_CHECKS, TestHelper.mockProject()), true, null);
.loadConfiguration(clf.create(BundledConfig.GOOGLE_CHECKS, TestHelper.mockProject()), Map.of(
"org.checkstyle.google.suppressionfilter.config", "",
"org.checkstyle.google.suppressionxpathfilter.config", ""
));
Assert.assertNotNull(csConfig);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void visitCurrentConfiguration(@NotNull final ConfigurationVisitor visito
checkstyleInstance.peruseConfiguration(
checkstyleInstance.loadConfiguration(
it,
true,
new HashMap<>()),
module -> visitor.accept(it.getDescription(), module));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,10 @@ Map<PsiFile, List<Problem>> scan(@NotNull CheckstyleInternalObject checkerWithCo
* Load a Checkstyle configuration file.
*
* @param inputFile the file to load
* @param ignoreVariables if <code>true</code>, all variables in the config file wil be replaced with the empty
* String; if <code>false</code>, the variables will be filled from the given map
* @param variables variables to substitute in the loaded config file
* @return a Checkstyle configuration object
*/
CheckstyleInternalObject loadConfiguration(@NotNull ConfigurationLocation inputFile,
boolean ignoreVariables,
@Nullable Map<String, String> variables);

/**
Expand All @@ -106,13 +103,10 @@ CheckstyleInternalObject loadConfiguration(@NotNull ConfigurationLocation inputF
* Load a Checkstyle configuration file.
*
* @param inputFile the file to load
* @param ignoreVariables if <code>true</code>, all variables in the config file wil be replaced with the empty
* String; if <code>false</code>, the variables will be filled from the given map
* @param variables variables to substitute in the loaded config file
* @return a Checkstyle configuration object
*/
CheckstyleInternalObject loadConfiguration(@NotNull VirtualFile inputFile,
boolean ignoreVariables,
@Nullable Map<String, String> variables);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private CheckstyleInternalObject loadConfiguration(@NotNull final Project projec
@NotNull final VirtualFile selectedFile) {
return checkstyleProjectService(project)
.getCheckstyleInstance()
.loadConfiguration(selectedFile, true, null);
.loadConfiguration(selectedFile, null);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModuleRootManager;
import com.intellij.openapi.vfs.VirtualFile;
Expand All @@ -14,6 +13,7 @@
import org.infernus.idea.checkstyle.checker.CheckerFactoryCache;
import org.infernus.idea.checkstyle.util.CheckStyleEntityResolver;
import org.infernus.idea.checkstyle.util.Objects;
import org.infernus.idea.checkstyle.util.ProjectPaths;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -323,7 +323,7 @@ private File checkRelativeToRulesFile(final String fileName) {
}

private File checkProjectBaseDir(final String fileName) {
VirtualFile baseDir = ProjectUtil.guessProjectDir(project);
VirtualFile baseDir = projectPaths().projectPath(project);
if (baseDir != null) {
final File projectRelativePath = new File(baseDir.getPath(), fileName);
if (projectRelativePath.exists()) {
Expand All @@ -335,7 +335,7 @@ private File checkProjectBaseDir(final String fileName) {

private File checkModuleFile(final Module module,
final String fileName) {
VirtualFile moduleDir = ProjectUtil.guessModuleDir(module);
VirtualFile moduleDir = projectPaths().modulePath(module);
if (moduleDir != null) {
final File moduleRelativePath = new File(moduleDir.getPath(), fileName);
if (moduleRelativePath.exists()) {
Expand Down Expand Up @@ -463,6 +463,10 @@ private int compareStrings(@Nullable final String pStr1, @Nullable final String
return result;
}

@NotNull
protected ProjectPaths projectPaths() {
return getProject().getService(ProjectPaths.class);
}

public synchronized boolean isBlocked() {
return blockedUntil > currentTimeMillis();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ public class ProjectFilePaths {
private final Function<File, String> absolutePathOf;

public ProjectFilePaths(@NotNull final Project project) {
this(project, File.separatorChar, File::getAbsolutePath, new ProjectPaths());
this(project, File.separatorChar, File::getAbsolutePath, project.getService(ProjectPaths.class));
}

public ProjectFilePaths(@NotNull final Project project,
@NotNull final ProjectPaths projectPaths) {
this(project, File.separatorChar, File::getAbsolutePath, projectPaths);
}

public ProjectFilePaths(@NotNull final Project project,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.infernus.idea.checkstyle.util;

import com.intellij.openapi.module.Module;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;

import org.jetbrains.annotations.Nullable;

public class ProjectPaths {
Expand All @@ -15,4 +15,9 @@ public VirtualFile projectPath(@NotNull final Project project) {
return ProjectUtil.guessProjectDir(project);
}

@Nullable
public VirtualFile modulePath(@NotNull final Module module) {
return ProjectUtil.guessModuleDir(module);
}

}
9 changes: 2 additions & 7 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<change-notes>
<![CDATA[
<ul>
<li>5.94.0: New: Added Checkstyle 10.18.0.</li>
<li>5.93.5: Fixed: Improve fallback when the serialised Checkstyle version to use is absent (#648).</li>
<li>5.93.4: Fixed: resolved case-sensitivity problem that was breaking builds on case-sensitive FSs (in particular, CI) (#646).</li>
<li>5.93.3: WiP: test release to verify artefact generation on CI (#646).</li>
Expand All @@ -48,13 +49,6 @@
<li>5.86.0: New: Added Checkstyle 10.13.0, 10.12.7.</li>
<li>5.85.1: Fixed: EDT access error in commit dialogue (#626).</li>
<li>5.85.0: New: Added Checkstyle 10.12.5.</li>
<li>5.84.0: New: Added Checkstyle 10.12.4.</li>
<li>5.83.0: New: New: Add ability to add bundled rules via the `BundledConfigProvider` interface (#622) - thanks to @rhierlmeier.</li>
<li>5.83.0: New: Added Checkstyle 10.12.3.</li>
<li>5.82.0: New: Added Checkstyle 10.12.2.</li>
<li>5.81.0: New: Added Checkstyle 10.12.1.</li>
<li>5.80.1: Fixed: Skip changelist & module checks to ensure update action is fast enough on toolbar actions (#612, #615).</li>
<li>5.80.0: New: Added Checkstyle 10.12.0.</li>
<li><em>For older changes please see the changelog.</em></li>
</ul>
]]>
Expand All @@ -73,6 +67,7 @@
<projectService serviceImplementation="org.infernus.idea.checkstyle.config.PluginConfigurationManager"/>
<projectService serviceImplementation="org.infernus.idea.checkstyle.config.ProjectConfigurationState"/>
<projectService serviceImplementation="org.infernus.idea.checkstyle.CheckstylePluginApi"/>
<projectService serviceImplementation="org.infernus.idea.checkstyle.util.ProjectPaths"/>
<projectService serviceImplementation="org.infernus.idea.checkstyle.util.ProjectFilePaths"/>
<projectService serviceImplementation="org.infernus.idea.checkstyle.ConfigurationInvalidator"/>

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/checkstyle-idea.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
checkstyle.versions.supported = \
9.0.1, 9.1, 9.2.1, 9.3, \
10.0, 10.1, 10.2, 10.3.4, 10.4, 10.5.0, 10.6.0, 10.7.0, 10.8.1, 10.9.3, \
10.10.0, 10.12.7, 10.13.0, 10.14.2, 10.15.0, 10.16.0, 10.17.0
10.10.0, 10.12.7, 10.13.0, 10.14.2, 10.15.0, 10.16.0, 10.17.0, 10.18.0


# The "base version" must be one of the versions listed above. The sources are compiled against this version, so it is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.infernus.idea.checkstyle.config.PluginConfigurationManager;
import org.infernus.idea.checkstyle.csapi.ConfigurationModule;
import org.infernus.idea.checkstyle.model.*;
import org.infernus.idea.checkstyle.util.ProjectPaths;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
Expand All @@ -16,7 +17,6 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.infernus.idea.checkstyle.csapi.BundledConfig.GOOGLE_CHECKS;

import static org.junit.Assert.fail;
import static org.mockito.Mockito.*;

Expand Down Expand Up @@ -73,6 +73,9 @@ public void currentConfigurationCanBeVisited() {
BundledConfigurationLocation googleChecks = new ConfigurationLocationFactory().create(GOOGLE_CHECKS, project);
TreeSet<ConfigurationLocation> locations = new TreeSet<>();
locations.add(googleChecks);
ProjectPaths projectPaths = mock(ProjectPaths.class);
when(projectPaths.projectPath(project)).thenReturn(null);
when(project.getService(ProjectPaths.class)).thenReturn(projectPaths);
when(pluginConfigManager.getCurrent())
.thenReturn(PluginConfigurationBuilder
.testInstance(CHECKSTYLE_VERSION)
Expand All @@ -92,7 +95,7 @@ public void currentConfigurationCanBeVisited() {
verify(visitor, atLeastOnce()).accept(eq("Google Checks"), configModuleCaptor.capture());

assertThat(configModuleCaptor.getValue(), is(not(nullValue())));
assertThat(configModuleCaptor.getValue().getName(), is("SuppressionXpathFilter"));

// note that SuppressionXpathFilter is filtered out as there's no valid suppressions file found
assertThat(configModuleCaptor.getValue().getName(), is("CommentsIndentation"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.infernus.idea.checkstyle.model.ConfigurationLocation;
import org.infernus.idea.checkstyle.model.ConfigurationLocationFactory;
import org.infernus.idea.checkstyle.util.ProjectFilePaths;
import org.infernus.idea.checkstyle.util.ProjectPaths;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -22,7 +23,7 @@ public class DescriptorTest {
@Before
public void setUp() {
when(project.getService(ConfigurationLocationFactory.class)).thenReturn(new ConfigurationLocationFactory());
when(project.getService(ProjectFilePaths.class)).thenReturn(new ProjectFilePaths(project));
when(project.getService(ProjectFilePaths.class)).thenReturn(new ProjectFilePaths(project, new ProjectPaths()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.infernus.idea.checkstyle.TestHelper;
import org.infernus.idea.checkstyle.csapi.BundledConfig;
import org.infernus.idea.checkstyle.util.ProjectFilePaths;
import org.infernus.idea.checkstyle.util.ProjectPaths;
import org.junit.Before;
import org.junit.Test;

Expand All @@ -24,7 +25,7 @@ public class ConfigurationLocationFactoryTest {
@Before
public void setUp() {
when(project.getService(ConfigurationLocationFactory.class)).thenReturn(underTest);
when(project.getService(ProjectFilePaths.class)).thenReturn(new ProjectFilePaths(project));
when(project.getService(ProjectFilePaths.class)).thenReturn(new ProjectFilePaths(project, new ProjectPaths()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.infernus.idea.checkstyle.config.Descriptor;
import org.infernus.idea.checkstyle.csapi.BundledConfig;
import org.infernus.idea.checkstyle.util.ProjectFilePaths;
import org.infernus.idea.checkstyle.util.ProjectPaths;
import org.jetbrains.annotations.NotNull;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -240,7 +241,7 @@ public Object clone() {
@Test
public void testSorting() {
final Project project = TestHelper.mockProject();
when(project.getService(ProjectFilePaths.class)).thenReturn(new ProjectFilePaths(project));
when(project.getService(ProjectFilePaths.class)).thenReturn(new ProjectFilePaths(project, new ProjectPaths()));

List<ConfigurationLocation> list = new ArrayList<>();
FileConfigurationLocation fcl = new FileConfigurationLocation(project, "id1", ConfigurationType.LOCAL_FILE);
Expand Down

0 comments on commit b62c2f0

Please sign in to comment.