Skip to content

Commit cbd88b8

Browse files
committed
chore(args): Remove anything related to linting
1 parent 56c4625 commit cbd88b8

5 files changed

Lines changed: 6 additions & 103 deletions

File tree

src/main/java/dev/dochia/cli/core/args/FilterArguments.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -457,19 +457,6 @@ public void customFilter(String specialPlaybook) {
457457
this.dryRun = false;
458458
}
459459

460-
461-
/**
462-
* Determines whether the current run includes the {@code Linter} playbook.
463-
* <p>
464-
* This is useful to distinguish whether a linting-specific analysis will be performed.
465-
*
466-
* @return {@code true} if the supplied playbooks include "Linter", {@code false} otherwise
467-
*/
468-
public boolean isLinting() {
469-
return this.getSuppliedPlaybooks().stream()
470-
.anyMatch(playbook -> playbook.equalsIgnoreCase("Linter"));
471-
}
472-
473460
/**
474461
* Convert list of enums to list of strings.
475462
*
@@ -581,18 +568,7 @@ public long getTotalPlaybooks() {
581568
.filter(playbook -> AnnotationUtils.findAnnotation(playbook.getClass(), TrimAndValidate.class) == null)
582569
.filter(playbook -> AnnotationUtils.findAnnotation(playbook.getClass(), SanitizeAndValidate.class) == null)
583570
.filter(playbook -> AnnotationUtils.findAnnotation(playbook.getClass(), SpecialPlaybook.class) == null)
584-
.filter(playbook -> AnnotationUtils.findAnnotation(playbook.getClass(), Linter.class) == null)
585571
.count();
586572
}
587573

588-
/**
589-
* Returns the total number of playbooks that are annotated with {@link Linter}.
590-
*
591-
* @return the total number of linters to be run
592-
*/
593-
public long getTotalLinters() {
594-
return playbooks.stream()
595-
.filter(playbook -> AnnotationUtils.findAnnotation(playbook.getClass(), Linter.class) != null)
596-
.count();
597-
}
598574
}

src/main/java/dev/dochia/cli/core/command/ListCommand.java

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package dev.dochia.cli.core.command;
22

33
import dev.dochia.cli.core.command.model.*;
4-
import dev.dochia.cli.core.playbook.api.*;
5-
import dev.dochia.cli.core.playbook.special.mutators.api.CustomMutatorConfig;
6-
import dev.dochia.cli.core.playbook.special.mutators.api.Mutator;
74
import dev.dochia.cli.core.generator.format.api.OpenAPIFormat;
85
import dev.dochia.cli.core.http.HttpMethod;
96
import dev.dochia.cli.core.model.PlaybookData;
7+
import dev.dochia.cli.core.playbook.api.*;
8+
import dev.dochia.cli.core.playbook.special.mutators.api.CustomMutatorConfig;
9+
import dev.dochia.cli.core.playbook.special.mutators.api.Mutator;
1010
import dev.dochia.cli.core.util.ConsoleUtils;
1111
import dev.dochia.cli.core.util.JsonUtils;
1212
import dev.dochia.cli.core.util.OpenApiUtils;
@@ -87,9 +87,6 @@ public void run() {
8787
if (listCommandGroups.listPlaybooksGroup != null && listCommandGroups.listPlaybooksGroup.playbooks) {
8888
listPlaybooks();
8989
}
90-
if (listCommandGroups.listPlaybooksGroup != null && listCommandGroups.listPlaybooksGroup.linters) {
91-
listLinters();
92-
}
9390
if (listCommandGroups.listStrategiesGroup != null && listCommandGroups.listStrategiesGroup.strategies) {
9491
listPlaybookStrategies();
9592
}
@@ -109,18 +106,6 @@ public void run() {
109106
}
110107
}
111108

112-
void listLinters() {
113-
List<TestCasePlaybook> linters = filterPlaybooks(Linter.class);
114-
if (json) {
115-
List<PlaybookListEntry> playbookEntries = List.of(new PlaybookListEntry().category("Linters").playbooks(linters));
116-
PrettyLoggerFactory.getConsoleLogger().noFormat(JsonUtils.GSON.toJson(playbookEntries));
117-
} else {
118-
String message = ansi().bold().fg(Ansi.Color.GREEN).a("dochia has {} registered linters:").reset().toString();
119-
logger.noFormat(message, playbooksList.size());
120-
displayPlaybooks(linters, Linter.class);
121-
}
122-
}
123-
124109
void listFormats() {
125110
if (json) {
126111
PrettyLoggerFactory.getConsoleLogger().noFormat(JsonUtils.GSON.toJson(formats));
@@ -267,22 +252,19 @@ void listPlaybooks() {
267252
List<TestCasePlaybook> fieldTestCasePlaybooks = filterPlaybooks(FieldPlaybook.class);
268253
List<TestCasePlaybook> headerTestCasePlaybooks = filterPlaybooks(HeaderPlaybook.class);
269254
List<TestCasePlaybook> httpTestCasePlaybooks = filterPlaybooks(BodyPlaybook.class);
270-
List<TestCasePlaybook> contractInfo = filterPlaybooks(Linter.class);
271255

272256
if (json) {
273257
List<PlaybookListEntry> playbookEntries = List.of(
274258
new PlaybookListEntry().category("Field").playbooks(fieldTestCasePlaybooks),
275259
new PlaybookListEntry().category("Header").playbooks(headerTestCasePlaybooks),
276-
new PlaybookListEntry().category("HTTP").playbooks(httpTestCasePlaybooks),
277-
new PlaybookListEntry().category("Linters").playbooks(contractInfo));
260+
new PlaybookListEntry().category("Body").playbooks(httpTestCasePlaybooks));
278261
PrettyLoggerFactory.getConsoleLogger().noFormat(JsonUtils.GSON.toJson(playbookEntries));
279262
} else {
280263
String message = ansi().bold().fg(Ansi.Color.GREEN).a("dochia has {} registered playbooks:").reset().toString();
281264
logger.noFormat(message, playbooksList.size());
282265
displayPlaybooks(fieldTestCasePlaybooks, FieldPlaybook.class);
283266
displayPlaybooks(headerTestCasePlaybooks, HeaderPlaybook.class);
284267
displayPlaybooks(httpTestCasePlaybooks, BodyPlaybook.class);
285-
displayPlaybooks(contractInfo, Linter.class);
286268
}
287269
}
288270

@@ -339,11 +321,6 @@ static class ListPlaybooksGroup {
339321
names = {"-f", "--playbooks", "playbooks"},
340322
description = "Display all current registered Playbooks")
341323
boolean playbooks;
342-
343-
@CommandLine.Option(
344-
names = {"-l", "--linters", "linters"},
345-
description = "Display all current registered Linters")
346-
boolean linters;
347324
}
348325

349326
static class ListMutatorsGroup {

src/main/java/dev/dochia/cli/core/playbook/api/Linter.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/test/java/dev/dochia/cli/core/args/FilterArgumentsTest.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,6 @@ void shouldReturnAllPlaybooksWhenNoCheckSupplied() {
7979
Assertions.assertThat(playbooks).contains("CheckSecurityHeadersPlaybook", "HappyPathPlaybook", "RemoveFieldsPlaybook");
8080
}
8181

82-
@Test
83-
void shouldNotReturnContractPlaybooksWhenIgnoredSupplied() {
84-
ReflectionTestUtils.setField(ignoreArguments, "ignoreResponseCodes", List.of("2xx"));
85-
86-
List<String> playbooks = filterArguments.getFirstPhasePlaybooksForPath();
87-
88-
Assertions.assertThat(playbooks).contains("CheckSecurityHeadersPlaybook", "HappyPathPlaybook", "RemoveFieldsPlaybook")
89-
.doesNotContain("TopLevelElementsLinter");
90-
}
91-
92-
@Test
93-
void shouldNotReturnContractPlaybooksWhenBlackbox() {
94-
ignoreArguments.setBlackbox(true);
95-
List<String> playbooks = filterArguments.getFirstPhasePlaybooksForPath();
96-
97-
Assertions.assertThat(playbooks).contains("CheckSecurityHeadersPlaybook", "HappyPathPlaybook", "RemoveFieldsPlaybook")
98-
.doesNotContain("TopLevelElementsLinter");
99-
}
100-
10182
@Test
10283
void shouldRemoveSkippedPlaybooks() {
10384
ReflectionTestUtils.setField(filterArguments, "skipPlaybooks", List.of("VeryLarge", "SecurityHeaders", "Jumbo"));
@@ -113,7 +94,7 @@ void shouldOnlyIncludeSuppliedPlaybooks() {
11394
ReflectionTestUtils.setField(filterArguments, "suppliedPlaybooks", List.of("VeryLarge", "SecurityHeaders", "Jumbo"));
11495
List<String> playbooks = filterArguments.getFirstPhasePlaybooksForPath();
11596

116-
Assertions.assertThat(playbooks).doesNotContain("TopLevelElementsLinter", "HappyPathPlaybook", "RemoveFieldsPlaybook", "Jumbo")
97+
Assertions.assertThat(playbooks).doesNotContain("HappyPathPlaybook", "RemoveFieldsPlaybook", "Jumbo")
11798
.containsOnly("CheckSecurityHeadersPlaybook", "VeryLargeStringsInFieldsPlaybook", "VeryLargeUnicodeStringsInFieldsPlaybook", "VeryLargeUnicodeStringsInHeadersPlaybook", "VeryLargeStringsInHeadersPlaybook",
11899
"VeryLargeDecimalsInNumericFieldsPlaybook", "VeryLargeIntegersInNumericFieldsPlaybook");
119100
}

src/test/java/dev/dochia/cli/core/command/ListCommandTest.java

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package dev.dochia.cli.core.command;
22

3+
import dev.dochia.cli.core.generator.format.api.OpenAPIFormat;
34
import dev.dochia.cli.core.playbook.api.TestCasePlaybook;
45
import dev.dochia.cli.core.playbook.special.mutators.api.Mutator;
5-
import dev.dochia.cli.core.generator.format.api.OpenAPIFormat;
66
import io.github.ludovicianul.prettylogger.PrettyLogger;
77
import io.quarkus.test.junit.QuarkusTest;
88
import jakarta.enterprise.inject.Instance;
@@ -81,15 +81,6 @@ void shouldListPlaybooksJson() {
8181
Mockito.verify(spyListCommand, Mockito.times(0)).displayPlaybooks(Mockito.anyList(), Mockito.any());
8282
}
8383

84-
@Test
85-
void shouldListLintersJson() {
86-
ListCommand spyListCommand = Mockito.spy(listCommand);
87-
CommandLine commandLine = new CommandLine(spyListCommand);
88-
commandLine.execute("-l", "-j");
89-
Mockito.verify(spyListCommand, Mockito.times(1)).listLinters();
90-
Mockito.verify(spyListCommand, Mockito.times(0)).displayPlaybooks(Mockito.anyList(), Mockito.any());
91-
}
92-
9384
@Test
9485
void shouldListPathsJson() {
9586
ListCommand spyListCommand = Mockito.spy(listCommand);
@@ -123,14 +114,6 @@ void shouldListPlaybooks() {
123114
Mockito.verify(spyListCommand, Mockito.times(1)).listPlaybooks();
124115
}
125116

126-
@Test
127-
void shouldListLinters() {
128-
ListCommand spyListCommand = Mockito.spy(listCommand);
129-
CommandLine commandLine = new CommandLine(spyListCommand);
130-
commandLine.execute("-l");
131-
Mockito.verify(spyListCommand, Mockito.times(1)).listLinters();
132-
}
133-
134117
@Test
135118
void shouldNotListPlaybooks() {
136119
ListCommand spyListCommand = Mockito.spy(listCommand);

0 commit comments

Comments
 (0)