Skip to content

Commit

Permalink
Bundled configurations now have constant IDs when recreated or ported…
Browse files Browse the repository at this point in the history
… from earlier versions (#569).
  • Loading branch information
jshiell committed Jun 11, 2022
1 parent 8f57a4c commit f442e70
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 13 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.67.3** Fix: Bundled configurations now have constant IDs when recreated or ported from earlier versions (#569).
* **5.67.3** Fix: Bundled configurations are restored if absent.
* **5.67.2** Fix: NPE in active modules configurations (#576).
* **5.67.1** Fix: Improve serialisation from legacy formats (#574).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,34 @@
public enum BundledConfig {

/** the Sun checks */
SUN_CHECKS("(bundled)", "Sun Checks", "/sun_checks.xml"),
SUN_CHECKS("bundled-sun-checks", "(bundled)", "Sun Checks", "/sun_checks.xml"),

/** the Google checks */
GOOGLE_CHECKS("(bundled)", "Google Checks", "/google_checks.xml");
GOOGLE_CHECKS("bundled-google-checks", "(bundled)", "Google Checks", "/google_checks.xml");


private final String id;

private final String location;

private final String description;

private final String path;


BundledConfig(@NotNull final String location, @NotNull final String description,
BundledConfig(@NotNull final String id,
@NotNull final String location,
@NotNull final String description,
@NotNull final String path) {
this.id = id;
this.location = location;
this.description = description;
this.path = path;
}

public String getId() {
return id;
}

@NotNull
public String getLocation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ public class BundledConfigurationLocation extends ConfigurationLocation {
@NotNull
private final BundledConfig bundledConfig;

BundledConfigurationLocation(@NotNull final String id,
@NotNull final BundledConfig bundledConfig,
BundledConfigurationLocation(@NotNull final BundledConfig bundledConfig,
@NotNull final Project project) {
super(id, ConfigurationType.BUNDLED, project);
super(bundledConfig.getId(), ConfigurationType.BUNDLED, project);
super.setLocation(bundledConfig.getLocation());
super.setDescription(bundledConfig.getDescription());

Expand Down Expand Up @@ -62,6 +61,6 @@ public boolean isRemovable() {
@Override
@NotNull
public BundledConfigurationLocation clone() {
return new BundledConfigurationLocation(getId(), bundledConfig, getProject());
return new BundledConfigurationLocation(bundledConfig, getProject());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class ConfigurationLocationFactory {
break;

case BUNDLED:
configurationLocation = new BundledConfigurationLocation(id, BundledConfig.fromDescription(description), project);
configurationLocation = new BundledConfigurationLocation(BundledConfig.fromDescription(description), project);
break;

case LEGACY_CLASSPATH:
Expand Down Expand Up @@ -95,7 +95,7 @@ public class ConfigurationLocationFactory {

public @NotNull BundledConfigurationLocation create(@NotNull final BundledConfig bundledConfig,
@NotNull final Project project) {
return new BundledConfigurationLocation(UUID.randomUUID().toString(), bundledConfig, project);
return new BundledConfigurationLocation(bundledConfig, project);
}

}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<change-notes>
<![CDATA[
<ul>
<li>5.67.3: Fix: Bundled configurations now have constant IDs when recreated or ported from earlier versions (#569).</li>
<li>5.67.3: Fix: Bundled configurations are restored if absent.</li>
<li>5.67.2: Fix: NPE in active modules configurations (#576).</li>
<li>5.67.1: Fix: Improve serialisation from legacy formats (#574).</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,21 @@ public void testSorting() {
rfcl1.setDescription("descA");
rfcl1.setLocation("locA");
list.add(rfcl1);
list.add(new BundledConfigurationLocation("id3", BundledConfig.SUN_CHECKS, project));
list.add(new BundledConfigurationLocation(BundledConfig.SUN_CHECKS, project));
RelativeFileConfigurationLocation rfcl2 = new RelativeFileConfigurationLocation(project, "id4");
rfcl2.setDescription("descC");
rfcl2.setLocation("locC");
list.add(rfcl2);
list.add(new BundledConfigurationLocation("id5", BundledConfig.GOOGLE_CHECKS, project));
list.add(new BundledConfigurationLocation(BundledConfig.GOOGLE_CHECKS, project));

Collections.sort(list);

assertEquals(BundledConfigurationLocation.class, list.get(0).getClass());
assertTrue(list.get(0).getDescription().contains("Sun Checks"));
assertTrue(list.contains(new BundledConfigurationLocation("id6", BundledConfig.SUN_CHECKS, project)));
assertTrue(list.contains(new BundledConfigurationLocation(BundledConfig.SUN_CHECKS, project)));
assertEquals(BundledConfigurationLocation.class, list.get(1).getClass());
assertTrue(list.get(1).getDescription().contains("Google Checks"));
assertTrue(list.contains(new BundledConfigurationLocation("id7", BundledConfig.GOOGLE_CHECKS, project)));
assertTrue(list.contains(new BundledConfigurationLocation(BundledConfig.GOOGLE_CHECKS, project)));
assertEquals(RelativeFileConfigurationLocation.class, list.get(2).getClass());
assertEquals("descA", list.get(2).getDescription());
assertEquals(FileConfigurationLocation.class, list.get(3).getClass());
Expand Down

0 comments on commit f442e70

Please sign in to comment.