Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
charphi committed Apr 5, 2024
1 parent 82dc591 commit ea55fc5
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions heylogs-api/src/main/java/internal/heylogs/ExtendedRules.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.vladsch.flexmark.util.ast.Document;
import com.vladsch.flexmark.util.ast.Node;
import lombok.NonNull;
import nbbrd.design.DirectImpl;
import nbbrd.design.MightBeGenerated;
import nbbrd.design.VisibleForTesting;
import nbbrd.heylogs.Nodes;
Expand Down Expand Up @@ -104,6 +105,7 @@ static RuleIssue validateConsistentSeparator(Document doc) {
}

@SuppressWarnings("unused")
@DirectImpl
@MightBeGenerated
@ServiceProvider
public static final class Batch implements RuleBatch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.vladsch.flexmark.util.ast.Document;
import com.vladsch.flexmark.util.ast.Node;
import lombok.NonNull;
import nbbrd.design.DirectImpl;
import nbbrd.design.MightBeGenerated;
import nbbrd.design.VisibleForTesting;
import nbbrd.heylogs.Changelog;
Expand Down Expand Up @@ -264,6 +265,7 @@ private static <T> T getFirstUnsortedItem(List<T> list, Comparator<T> comparator
}

@SuppressWarnings("unused")
@DirectImpl
@MightBeGenerated
@ServiceProvider
public static final class Batch implements RuleBatch {
Expand Down
2 changes: 2 additions & 0 deletions heylogs-api/src/main/java/internal/heylogs/JsonFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.*;
import lombok.NonNull;
import nbbrd.design.DirectImpl;
import nbbrd.design.MightBeGenerated;
import nbbrd.heylogs.*;
import nbbrd.heylogs.spi.Format;
Expand All @@ -19,6 +20,7 @@

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

@DirectImpl
@ServiceProvider
public final class JsonFormat implements Format {

Expand Down
2 changes: 2 additions & 0 deletions heylogs-api/src/main/java/internal/heylogs/StylishFormat.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package internal.heylogs;

import lombok.NonNull;
import nbbrd.design.DirectImpl;
import nbbrd.design.MightBePromoted;
import nbbrd.heylogs.*;
import nbbrd.heylogs.spi.Format;
Expand All @@ -19,6 +20,7 @@
import static java.util.Locale.ROOT;

// https://eslint.org/docs/latest/user-guide/formatters/#stylish
@DirectImpl
@ServiceProvider
public final class StylishFormat implements Format {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import internal.heylogs.GitHostRef;
import internal.heylogs.GitHostRefRuleSupport;
import lombok.NonNull;
import nbbrd.design.DirectImpl;
import nbbrd.design.VisibleForTesting;
import nbbrd.heylogs.spi.Rule;
import nbbrd.heylogs.spi.RuleBatch;
import nbbrd.service.ServiceProvider;

import java.util.stream.Stream;

@DirectImpl
@ServiceProvider
public final class GitHubRules implements RuleBatch {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.vladsch.flexmark.ast.Heading;
import com.vladsch.flexmark.util.ast.Node;
import lombok.NonNull;
import nbbrd.design.DirectImpl;
import nbbrd.design.VisibleForTesting;
import nbbrd.heylogs.Version;
import nbbrd.heylogs.spi.Rule;
Expand All @@ -11,6 +12,7 @@
import nbbrd.service.ServiceProvider;
import org.semver4j.Semver;

@DirectImpl
@ServiceProvider
public final class SemVerRule implements Rule {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
import nbbrd.heylogs.Nodes;
import nbbrd.heylogs.spi.Rule;
import nbbrd.heylogs.spi.RuleIssue;
import nbbrd.service.ServiceId;
import nbbrd.heylogs.spi.RuleLoader;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Objects;
import java.util.regex.Pattern;

import static _test.Sample.using;
import static internal.heylogs.ExtendedRules.NO_RULE_ISSUE;
Expand All @@ -26,7 +25,7 @@ public class ExtendedRulesTest {
public void testIdPattern() {
assertThat(ExtendedRules.values())
.extracting(Rule::getRuleId)
.allMatch(Pattern.compile(ServiceId.KEBAB_CASE).asPredicate());
.allMatch(RuleLoader.ID_PATTERN.asPredicate());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import com.vladsch.flexmark.util.ast.Node;
import nbbrd.heylogs.spi.Rule;
import nbbrd.heylogs.spi.RuleIssue;
import nbbrd.service.ServiceId;
import nbbrd.heylogs.spi.RuleLoader;
import org.junit.jupiter.api.Test;

import java.util.Objects;
import java.util.regex.Pattern;

import static _test.Sample.using;
import static internal.heylogs.GuidingPrinciples.validateForHumans;
Expand All @@ -23,7 +22,7 @@ public class GuidingPrinciplesTest {
public void testIdPattern() {
assertThat(GuidingPrinciples.values())
.extracting(Rule::getRuleId)
.allMatch(Pattern.compile(ServiceId.KEBAB_CASE).asPredicate());
.allMatch(RuleLoader.ID_PATTERN.asPredicate());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package internal.heylogs;

import nbbrd.heylogs.spi.Format;
import nbbrd.heylogs.spi.FormatLoader;
import org.junit.jupiter.api.Test;

import static _test.Sample.*;
Expand All @@ -11,6 +12,12 @@

class JsonFormatTest {

@Test
public void testIdPattern() {
assertThat(new JsonFormat().getFormatId())
.matches(FormatLoader.ID_PATTERN);
}

@Test
public void testFormatProblems() {
Format x = new JsonFormat();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package internal.heylogs;

import nbbrd.heylogs.spi.Format;
import nbbrd.heylogs.spi.FormatLoader;
import nbbrd.heylogs.spi.FormatType;
import org.junit.jupiter.api.Test;

Expand All @@ -12,6 +13,12 @@

class StylishFormatTest {

@Test
public void testIdPattern() {
assertThat(new StylishFormat().getFormatId())
.matches(FormatLoader.ID_PATTERN);
}

@Test
public void testSupportedTypes() {
Format x = new StylishFormat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
import nbbrd.heylogs.Nodes;
import nbbrd.heylogs.spi.Rule;
import nbbrd.heylogs.spi.RuleIssue;
import nbbrd.service.ServiceId;
import nbbrd.heylogs.spi.RuleLoader;
import org.junit.jupiter.api.Test;

import java.util.Objects;
import java.util.regex.Pattern;

import static _test.Sample.using;
import static internal.heylogs.github.GitHubRules.*;
Expand All @@ -25,7 +24,7 @@ public class GitHubRulesTest {
public void testIdPattern() {
assertThat(new GitHubRules().getProviders())
.extracting(Rule::getRuleId)
.allMatch(Pattern.compile(ServiceId.KEBAB_CASE).asPredicate());
.allMatch(RuleLoader.ID_PATTERN.asPredicate());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.vladsch.flexmark.ast.Heading;
import com.vladsch.flexmark.util.ast.Node;
import nbbrd.heylogs.spi.RuleIssue;
import nbbrd.service.ServiceId;
import nbbrd.heylogs.spi.RuleLoader;
import org.junit.jupiter.api.Test;

import java.util.Objects;
Expand All @@ -17,7 +17,7 @@ public class SemVerRuleTest {
@Test
public void testIdPattern() {
assertThat(new SemVerRule().getRuleId())
.matches(ServiceId.KEBAB_CASE);
.matches(RuleLoader.ID_PATTERN);
}

@Test
Expand Down

0 comments on commit ea55fc5

Please sign in to comment.