diff --git a/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbe.java b/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbe.java index 189f399e5..34be7e00b 100644 --- a/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbe.java +++ b/core/src/main/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbe.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2023 Jenkins Infra + * Copyright (c) 2022-2024 Jenkins Infra * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - package io.jenkins.pluginhealth.scoring.probes; import java.io.IOException; @@ -48,13 +47,19 @@ protected ProbeResult doApply(Plugin plugin, ProbeContext context) { } final Path repository = context.getScmRepository().get(); - try (Stream paths = Files.find(repository, 2, - (file, basicFileAttributes) -> Files.isReadable(file) - && ("CONTRIBUTING.md".equalsIgnoreCase(file.getFileName().toString()) - || "CONTRIBUTING.adoc".equalsIgnoreCase(file.getFileName().toString())))) { + try (Stream paths = Files.find( + repository, + 2, + (file, basicFileAttributes) -> Files.isReadable(file) + && ("CONTRIBUTING.md" + .equalsIgnoreCase(file.getFileName().toString()) + || "CONTRIBUTING.adoc" + .equalsIgnoreCase(file.getFileName().toString())))) { return paths.findAny() - .map(file -> this.success("Contributing guidelines found.")) - .orElseGet(() -> this.success("No contributing guidelines found.")); + .map(file -> file.toFile().length() != 0 + ? this.success("Contributing guidelines found.") + : this.success("Contributing guide seems to be empty.")) + .orElseGet(() -> this.success("Inherit from organization contributing guide.")); } catch (IOException e) { return this.error(e.getMessage()); } diff --git a/core/src/main/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoring.java b/core/src/main/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoring.java index 88bb02084..bc2ac3aa5 100644 --- a/core/src/main/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoring.java +++ b/core/src/main/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoring.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 Jenkins Infra + * Copyright (c) 2022-2024 Jenkins Infra * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - package io.jenkins.pluginhealth.scoring.scores; import java.util.List; @@ -61,145 +60,153 @@ public String description() { @Override public List getComponents() { return List.of( - new ScoringComponent() { - @Override - public String getDescription() { - return "The plugin has a specific contributing guide."; - } - - @Override - public ScoringComponentResult getScore(Plugin plugin, Map probeResults) { - ProbeResult probeResult = probeResults.get(ContributingGuidelinesProbe.KEY); - if (probeResult != null && "Contributing guidelines found.".equals(probeResult.message())) { - return new ScoringComponentResult(100, getWeight(), List.of("Plugin has a contributing guide.")); - } - return new ScoringComponentResult( - 0, - getWeight(), - List.of("The plugin relies on the global contributing guide."), - List.of(new Resolution( - "See why and how to add a contributing guide", - "https://www.jenkins.io/doc/developer/tutorial-improve/add-a-contributing-guide/" - )) - ); - } - - @Override - public int getWeight() { - return 2; - } - }, - new ScoringComponent() { - @Override - public String getDescription() { - return "Plugin documentation should be migrated from the wiki."; - } - - @Override - public ScoringComponentResult getScore(Plugin $, Map probeResults) { - final ProbeResult probeResult = probeResults.get(DocumentationMigrationProbe.KEY); - if (probeResult == null || ProbeResult.Status.ERROR.equals(probeResult.status())) { - return new ScoringComponentResult(0, getWeight(), List.of("Cannot confirm or not the documentation migration.")); + new ScoringComponent() { + @Override + public String getDescription() { + return "The plugin should have a specific contributing guide."; } - return switch (probeResult.message()) { - case "Documentation is located in the plugin repository." -> - new ScoringComponentResult(100, getWeight(), List.of("Documentation is in plugin repository.")); - case "Documentation is not located in the plugin repository." -> new ScoringComponentResult( - 0, - getWeight(), - List.of("Documentation should be migrated in plugin repository."), - List.of( - new Resolution("https://www.jenkins.io/doc/developer/tutorial-improve/migrate-documentation-to-github/") - ) - ); - default -> - new ScoringComponentResult(0, getWeight(), List.of("Cannot confirm or not the documentation migration.", probeResult.message())); - }; - } - - @Override - public int getWeight() { - return 4; - } - }, - new ScoringComponent() { - @Override - public String getDescription() { - return "Recommend to setup Release Drafter on the plugin repository."; - } - - @Override - public ScoringComponentResult getScore(Plugin plugin, Map probeResults) { - ProbeResult cdProbe = probeResults.get(ContinuousDeliveryProbe.KEY); - if (cdProbe != null && "JEP-229 workflow definition found.".equals(cdProbe.message())) { + + @Override + public ScoringComponentResult getScore(Plugin plugin, Map probeResults) { + ProbeResult probeResult = probeResults.get(ContributingGuidelinesProbe.KEY); + if (probeResult == null || ProbeResult.Status.ERROR.equals(probeResult.status())) { + return new ScoringComponentResult( + 0, getWeight(), List.of("Cannot determine if the plugin has contributing guide.")); + } + if ("Inherit from organization contributing guide.".equals(probeResult.message())) { + return new ScoringComponentResult( + 100, 0, List.of("Plugin is inheriting the organization contributing guide.")); + } + if ("Contributing guidelines found.".equals(probeResult.message())) { + return new ScoringComponentResult( + 100, getWeight(), List.of("Plugin seems to have a dedicated contributing guide.")); + } return new ScoringComponentResult( - 100, - getWeight(), - List.of("Plugin using Release Drafter because it has CD configured.") - ); + 0, + getWeight(), + List.of("The plugin relies on the global contributing guide."), + List.of( + new Resolution( + "See why and how to add a contributing guide", + "https://www.jenkins.io/doc/developer/tutorial-improve/add-a-contributing-guide/"))); + } + + @Override + public int getWeight() { + return 2; + } + }, + new ScoringComponent() { + @Override + public String getDescription() { + return "Plugin documentation should be migrated from the wiki."; + } + + @Override + public ScoringComponentResult getScore(Plugin $, Map probeResults) { + final ProbeResult probeResult = probeResults.get(DocumentationMigrationProbe.KEY); + if (probeResult == null || ProbeResult.Status.ERROR.equals(probeResult.status())) { + return new ScoringComponentResult( + 0, getWeight(), List.of("Cannot confirm or not the documentation migration.")); + } + return switch (probeResult.message()) { + case "Documentation is located in the plugin repository." -> new ScoringComponentResult( + 100, getWeight(), List.of("Documentation is in plugin repository.")); + case "Documentation is not located in the plugin repository." -> new ScoringComponentResult( + 0, + getWeight(), + List.of("Documentation should be migrated in plugin repository."), + List.of( + new Resolution( + "https://www.jenkins.io/doc/developer/tutorial-improve/migrate-documentation-to-github/"))); + default -> new ScoringComponentResult( + 0, + getWeight(), + List.of( + "Cannot confirm or not the documentation migration.", + probeResult.message())); + }; } - ProbeResult result = probeResults.get(ReleaseDrafterProbe.KEY); - if (result != null && "Release Drafter is configured.".equals(result.message())) { + + @Override + public int getWeight() { + return 4; + } + }, + new ScoringComponent() { + @Override + public String getDescription() { + return "Recommend to setup Release Drafter on the plugin repository."; + } + + @Override + public ScoringComponentResult getScore(Plugin plugin, Map probeResults) { + ProbeResult cdProbe = probeResults.get(ContinuousDeliveryProbe.KEY); + if (cdProbe != null && "JEP-229 workflow definition found.".equals(cdProbe.message())) { + return new ScoringComponentResult( + 100, + getWeight(), + List.of("Plugin using Release Drafter because it has CD configured.")); + } + ProbeResult result = probeResults.get(ReleaseDrafterProbe.KEY); + if (result != null && "Release Drafter is configured.".equals(result.message())) { + return new ScoringComponentResult( + 100, getWeight(), List.of("Plugin is using Release Drafter.")); + } return new ScoringComponentResult( - 100, - getWeight(), - List.of("Plugin is using Release Drafter.") - ); + 0, + 0, + List.of("Plugin is not using Release Drafter to manage its changelog."), + List.of( + new Resolution( + "Plugin could benefit from using Release Drafter.", + "https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc"))); } - return new ScoringComponentResult( - 0, - 0, - List.of("Plugin is not using Release Drafter to manage its changelog."), - List.of(new Resolution( - "Plugin could benefit from using Release Drafter.", - "https://github.com/jenkinsci/.github/blob/master/.github/release-drafter.adoc" - )) - ); - } - - @Override - public int getWeight() { - return 0; - } - }, - new ScoringComponent() { - @Override - public String getDescription() { - return "Plugin description should be located in the index.jelly file."; - } - - @Override - public ScoringComponentResult getScore(Plugin plugin, Map probeResults) { - final ProbeResult result = probeResults.get(PluginDescriptionMigrationProbe.KEY); - if (result == null || ProbeResult.Status.ERROR.equals(result.status())) { + + @Override + public int getWeight() { + return 0; + } + }, + new ScoringComponent() { + @Override + public String getDescription() { + return "Plugin description should be located in the index.jelly file."; + } + + @Override + public ScoringComponentResult getScore(Plugin plugin, Map probeResults) { + final ProbeResult result = probeResults.get(PluginDescriptionMigrationProbe.KEY); + if (result == null || ProbeResult.Status.ERROR.equals(result.status())) { + return new ScoringComponentResult( + 0, + getWeight(), + List.of("Cannot determine if the plugin description was correctly migrated.")); + } + + final String message = result.message(); + if ("Plugin seems to have a correct description.".equals(message)) { + return new ScoringComponentResult(100, getWeight(), List.of(message)); + } return new ScoringComponentResult( - 0, - getWeight(), - List.of("Cannot determine if the plugin description was correctly migrated.") - ); + 0, + getWeight(), + List.of(message), + List.of( + new Resolution( + "Please see how to migrate the plugin description for the plugin.", + "https://www.jenkins.io/doc/developer/tutorial-improve/move-description-to-index/"))); } - final String message = result.message(); - if ("Plugin seems to have a correct description.".equals(message)) { - return new ScoringComponentResult(100, getWeight(), List.of(message)); + @Override + public int getWeight() { + return 4; } - return new ScoringComponentResult(0, getWeight(), List.of(message), - List.of(new Resolution( - "Please see how to migrate the plugin description for the plugin.", - "https://www.jenkins.io/doc/developer/tutorial-improve/move-description-to-index/" - ))); - } - - @Override - public int getWeight() { - return 4; - } - } - ); + }); } @Override public int version() { - return 2; + return 3; } } diff --git a/core/src/test/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbeTest.java b/core/src/test/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbeTest.java index 1b37f7341..a4c382a46 100644 --- a/core/src/test/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbeTest.java +++ b/core/src/test/java/io/jenkins/pluginhealth/scoring/probes/ContributingGuidelinesProbeTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2023 Jenkins Infra + * Copyright (c) 2022-2024 Jenkins Infra * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - package io.jenkins.pluginhealth.scoring.probes; import static org.assertj.core.api.Assertions.assertThat; @@ -66,9 +65,12 @@ public void shouldCorrectlyDetectMissingContributingGuidelines() throws IOExcept when(ctx.getScmRepository()).thenReturn(Optional.of(repository)); assertThat(probe.apply(plugin, ctx)) - .usingRecursiveComparison() - .comparingOnlyFields("id", "status", "message") - .isEqualTo(ProbeResult.success(ContributingGuidelinesProbe.KEY, "No contributing guidelines found.", probe.getVersion())); + .usingRecursiveComparison() + .comparingOnlyFields("id", "status", "message") + .isEqualTo(ProbeResult.success( + ContributingGuidelinesProbe.KEY, + "Inherit from organization contributing guide.", + probe.getVersion())); } @Test @@ -79,13 +81,17 @@ public void shouldCorrectlyDetectContributingGuidelinesInRootLevelOfRepository() when(plugin.getName()).thenReturn("foo"); final Path repository = Files.createTempDirectory(plugin.getName()); - Files.createFile(repository.resolve("CONTRIBUTING.md")); + final Path guide = Files.createFile(repository.resolve("CONTRIBUTING.md")); + Files.writeString(guide, """ + Everything is awesome. + """); when(ctx.getScmRepository()).thenReturn(Optional.of(repository)); assertThat(probe.apply(plugin, ctx)) - .usingRecursiveComparison() - .comparingOnlyFields("id", "status", "message") - .isEqualTo(ProbeResult.success(ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", probe.getVersion())); + .usingRecursiveComparison() + .comparingOnlyFields("id", "status", "message") + .isEqualTo(ProbeResult.success( + ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", probe.getVersion())); } @Test @@ -94,14 +100,37 @@ public void shouldCorrectlyDetectContributingGuidelinesInDocsFolder() throws IOE final ProbeContext ctx = mock(ProbeContext.class); final ContributingGuidelinesProbe probe = getSpy(); + when(plugin.getName()).thenReturn("foo"); + final Path repository = Files.createTempDirectory(plugin.getName()); + final Path guide = Files.createFile( + Files.createDirectory(repository.resolve("docs")).resolve("CONTRIBUTING.md")); + Files.writeString(guide, """ + Everything is awesome. + """); + when(ctx.getScmRepository()).thenReturn(Optional.of(repository)); + + assertThat(probe.apply(plugin, ctx)) + .usingRecursiveComparison() + .comparingOnlyFields("id", "status", "message") + .isEqualTo(ProbeResult.success( + ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", probe.getVersion())); + } + + @Test + public void shouldDetectEmptyContributingGuidelines() throws IOException { + final Plugin plugin = mock(Plugin.class); + final ProbeContext ctx = mock(ProbeContext.class); + final ContributingGuidelinesProbe probe = getSpy(); + when(plugin.getName()).thenReturn("foo"); final Path repository = Files.createTempDirectory(plugin.getName()); Files.createFile(Files.createDirectory(repository.resolve("docs")).resolve("CONTRIBUTING.md")); when(ctx.getScmRepository()).thenReturn(Optional.of(repository)); assertThat(probe.apply(plugin, ctx)) - .usingRecursiveComparison() - .comparingOnlyFields("id", "status", "message") - .isEqualTo(ProbeResult.success(ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", probe.getVersion())); + .usingRecursiveComparison() + .comparingOnlyFields("id", "status", "message") + .isEqualTo(ProbeResult.success( + ContributingGuidelinesProbe.KEY, "Contributing guide seems to be empty.", probe.getVersion())); } } diff --git a/core/src/test/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoringTest.java b/core/src/test/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoringTest.java index 2d062a3e0..6c4be41b0 100644 --- a/core/src/test/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoringTest.java +++ b/core/src/test/java/io/jenkins/pluginhealth/scoring/scores/DocumentationScoringTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2024 Jenkins Infra + * Copyright (c) 2022-2024 Jenkins Infra * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,7 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - package io.jenkins.pluginhealth.scoring.scores; import static org.assertj.core.api.Assertions.assertThat; @@ -51,22 +50,32 @@ DocumentationScoring getSpy() { } @Test - void shouldScoreOneHundredWithMigratedDocumentationAndContributingGuide() { + void shouldScoreOneHundredWithInheritedContributingGuide() { final Plugin plugin = mock(Plugin.class); final DocumentationScoring scoring = getSpy(); - when(plugin.getDetails()).thenReturn(Map.of( - DocumentationMigrationProbe.KEY, ProbeResult.success(DocumentationMigrationProbe.KEY, "Documentation is located in the plugin repository.", 1), - PluginDescriptionMigrationProbe.KEY, ProbeResult.success(PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), - ContributingGuidelinesProbe.KEY, ProbeResult.success(ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", 1), - ReleaseDrafterProbe.KEY, ProbeResult.success(ReleaseDrafterProbe.KEY, "Release Drafter is configured.", 1) - )); + when(plugin.getDetails()) + .thenReturn(Map.of( + DocumentationMigrationProbe.KEY, + ProbeResult.success( + DocumentationMigrationProbe.KEY, + "Documentation is located in the plugin repository.", + 1), + PluginDescriptionMigrationProbe.KEY, + ProbeResult.success( + PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), + ContributingGuidelinesProbe.KEY, + ProbeResult.success( + ContributingGuidelinesProbe.KEY, "Inherit from organization contributing guide.", 1), + ReleaseDrafterProbe.KEY, + ProbeResult.success(ReleaseDrafterProbe.KEY, "Release Drafter is configured.", 1))); ScoreResult result = scoring.apply(plugin); assertThat(result) - .isNotNull() - .usingRecursiveComparison().comparingOnlyFields("key", "value") - .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 100, .5f, Set.of(), 1)); + .isNotNull() + .usingRecursiveComparison() + .comparingOnlyFields("key", "value") + .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 100, .5f, Set.of(), 1)); } @Test @@ -74,27 +83,39 @@ void shouldScoreOneHundredEvenWithoutReleaseDrafter() { final Plugin plugin = mock(Plugin.class); final DocumentationScoring scoring = getSpy(); - when(plugin.getDetails()).thenReturn(Map.of( - DocumentationMigrationProbe.KEY, ProbeResult.success(DocumentationMigrationProbe.KEY, "Documentation is located in the plugin repository.", 1), - PluginDescriptionMigrationProbe.KEY, ProbeResult.success(PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), - ContributingGuidelinesProbe.KEY, ProbeResult.success(ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", 1), - ReleaseDrafterProbe.KEY, ProbeResult.success(ReleaseDrafterProbe.KEY, "Release Drafter not is configured.", 1) - )); + when(plugin.getDetails()) + .thenReturn(Map.of( + DocumentationMigrationProbe.KEY, + ProbeResult.success( + DocumentationMigrationProbe.KEY, + "Documentation is located in the plugin repository.", + 1), + PluginDescriptionMigrationProbe.KEY, + ProbeResult.success( + PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), + ContributingGuidelinesProbe.KEY, + ProbeResult.success( + ContributingGuidelinesProbe.KEY, "Inherit from organization contributing guide.", 1), + ReleaseDrafterProbe.KEY, + ProbeResult.success(ReleaseDrafterProbe.KEY, "Release Drafter not is configured.", 1))); ScoreResult result = scoring.apply(plugin); assertThat(result) - .isNotNull() - .usingRecursiveComparison().comparingOnlyFields("key", "value") - .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 100, .5f, Set.of(), 1)); + .isNotNull() + .usingRecursiveComparison() + .comparingOnlyFields("key", "value") + .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 100, .5f, Set.of(), 1)); assertThat(result.componentsResults()) - .hasSize(4) - .haveAtLeastOne(new Condition<>( - res -> { - return res.weight() == 0 && res.score() == 0 && res.resolutions().size() == 1 && - res.reasons().contains("Plugin is not using Release Drafter to manage its changelog."); - }, - "Release drafter is not configured" - )); + .hasSize(4) + .haveAtLeastOne(new Condition<>( + res -> { + return res.weight() == 0 + && res.score() == 0 + && res.resolutions().size() == 1 + && res.reasons() + .contains("Plugin is not using Release Drafter to manage its changelog."); + }, + "Release drafter is not configured")); } @Test @@ -102,28 +123,40 @@ void shouldConsiderCDAsConfiguringReleaseDrafter() { final Plugin plugin = mock(Plugin.class); final DocumentationScoring scoring = getSpy(); - when(plugin.getDetails()).thenReturn(Map.of( - DocumentationMigrationProbe.KEY, ProbeResult.success(DocumentationMigrationProbe.KEY, "Documentation is located in the plugin repository.", 1), - PluginDescriptionMigrationProbe.KEY, ProbeResult.success(PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), - ContributingGuidelinesProbe.KEY, ProbeResult.success(ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", 1), - ReleaseDrafterProbe.KEY, ProbeResult.success(ReleaseDrafterProbe.KEY, "Release Drafter not is configured.", 1), - ContinuousDeliveryProbe.KEY, ProbeResult.success(ContinuousDeliveryProbe.KEY, "JEP-229 workflow definition found.", 1) - )); + when(plugin.getDetails()) + .thenReturn(Map.of( + DocumentationMigrationProbe.KEY, + ProbeResult.success( + DocumentationMigrationProbe.KEY, + "Documentation is located in the plugin repository.", + 1), + PluginDescriptionMigrationProbe.KEY, + ProbeResult.success( + PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), + ContributingGuidelinesProbe.KEY, + ProbeResult.success(ContributingGuidelinesProbe.KEY, "Contributing guidelines found.", 1), + ReleaseDrafterProbe.KEY, + ProbeResult.success(ReleaseDrafterProbe.KEY, "Release Drafter not is configured.", 1), + ContinuousDeliveryProbe.KEY, + ProbeResult.success(ContinuousDeliveryProbe.KEY, "JEP-229 workflow definition found.", 1))); ScoreResult result = scoring.apply(plugin); assertThat(result) - .isNotNull() - .usingRecursiveComparison().comparingOnlyFields("key", "value") - .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 100, .5f, Set.of(), 1)); + .isNotNull() + .usingRecursiveComparison() + .comparingOnlyFields("key", "value") + .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 100, .5f, Set.of(), 1)); assertThat(result.componentsResults()) - .hasSize(4) - .haveAtLeastOne(new Condition<>( - res -> { - return res.weight() == 0 && res.score() == 100 && res.reasons().size() == 1 && - res.reasons().contains("Plugin using Release Drafter because it has CD configured."); - }, - "CD is configured." - )); + .hasSize(4) + .haveAtLeastOne(new Condition<>( + res -> { + return res.weight() == 0 + && res.score() == 100 + && res.reasons().size() == 1 + && res.reasons() + .contains("Plugin using Release Drafter because it has CD configured."); + }, + "CD is configured.")); } @Test @@ -131,17 +164,27 @@ void shouldScoreFortyWithMigratedDocumentationOnly() { final Plugin plugin = mock(Plugin.class); final DocumentationScoring scoring = getSpy(); - when(plugin.getDetails()).thenReturn(Map.of( - DocumentationMigrationProbe.KEY, ProbeResult.success(DocumentationMigrationProbe.KEY, "Documentation is located in the plugin repository.", 1), - PluginDescriptionMigrationProbe.KEY, ProbeResult.success(PluginDescriptionMigrationProbe.KEY, "Plugin is using description from the plugin archetype.", 1), - ContributingGuidelinesProbe.KEY, ProbeResult.success(ContributingGuidelinesProbe.KEY, "No contributing guidelines found.", 1) - )); + when(plugin.getDetails()) + .thenReturn(Map.of( + DocumentationMigrationProbe.KEY, + ProbeResult.success( + DocumentationMigrationProbe.KEY, + "Documentation is located in the plugin repository.", + 1), + PluginDescriptionMigrationProbe.KEY, + ProbeResult.success( + PluginDescriptionMigrationProbe.KEY, + "Plugin is using description from the plugin archetype.", + 1), + ContributingGuidelinesProbe.KEY, + ProbeResult.success(ContributingGuidelinesProbe.KEY, "No contributing guidelines found.", 1))); ScoreResult result = scoring.apply(plugin); assertThat(result) - .isNotNull() - .usingRecursiveComparison().comparingOnlyFields("key", "value") - .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 40, .5f, Set.of(), 1)); + .isNotNull() + .usingRecursiveComparison() + .comparingOnlyFields("key", "value") + .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 40, .5f, Set.of(), 1)); } @Test @@ -149,17 +192,25 @@ void shouldScoreFortyWithMigratedDescriptionOnly() { final Plugin plugin = mock(Plugin.class); final DocumentationScoring scoring = getSpy(); - when(plugin.getDetails()).thenReturn(Map.of( - DocumentationMigrationProbe.KEY, ProbeResult.success(DocumentationMigrationProbe.KEY, "Documentation is not located in the plugin repository.", 1), - PluginDescriptionMigrationProbe.KEY, ProbeResult.success(PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), - ContributingGuidelinesProbe.KEY, ProbeResult.success(ContributingGuidelinesProbe.KEY, "No contributing guidelines found.", 1) - )); + when(plugin.getDetails()) + .thenReturn(Map.of( + DocumentationMigrationProbe.KEY, + ProbeResult.success( + DocumentationMigrationProbe.KEY, + "Documentation is not located in the plugin repository.", + 1), + PluginDescriptionMigrationProbe.KEY, + ProbeResult.success( + PluginDescriptionMigrationProbe.KEY, "Plugin seems to have a correct description.", 1), + ContributingGuidelinesProbe.KEY, + ProbeResult.success(ContributingGuidelinesProbe.KEY, "No contributing guidelines found.", 1))); ScoreResult result = scoring.apply(plugin); assertThat(result) - .isNotNull() - .usingRecursiveComparison().comparingOnlyFields("key", "value") - .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 40, .5f, Set.of(), 1)); + .isNotNull() + .usingRecursiveComparison() + .comparingOnlyFields("key", "value") + .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 40, .5f, Set.of(), 1)); } @Test @@ -167,16 +218,26 @@ void shouldScoreZeroWithMigratedDocumentationOnly() { final Plugin plugin = mock(Plugin.class); final DocumentationScoring scoring = getSpy(); - when(plugin.getDetails()).thenReturn(Map.of( - DocumentationMigrationProbe.KEY, ProbeResult.success(DocumentationMigrationProbe.KEY, "Documentation is not located in the plugin repository.", 1), - PluginDescriptionMigrationProbe.KEY, ProbeResult.success(PluginDescriptionMigrationProbe.KEY, "Plugin is using description from the plugin archetype.", 1), - ContributingGuidelinesProbe.KEY, ProbeResult.success(ContributingGuidelinesProbe.KEY, "No contributing guidelines found.", 1) - )); + when(plugin.getDetails()) + .thenReturn(Map.of( + DocumentationMigrationProbe.KEY, + ProbeResult.success( + DocumentationMigrationProbe.KEY, + "Documentation is not located in the plugin repository.", + 1), + PluginDescriptionMigrationProbe.KEY, + ProbeResult.success( + PluginDescriptionMigrationProbe.KEY, + "Plugin is using description from the plugin archetype.", + 1), + ContributingGuidelinesProbe.KEY, + ProbeResult.success(ContributingGuidelinesProbe.KEY, "No contributing guidelines found.", 1))); ScoreResult result = scoring.apply(plugin); assertThat(result) - .isNotNull() - .usingRecursiveComparison().comparingOnlyFields("key", "value") - .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 0, .5f, Set.of(), 1)); + .isNotNull() + .usingRecursiveComparison() + .comparingOnlyFields("key", "value") + .isEqualTo(new ScoreResult(DocumentationScoring.KEY, 0, .5f, Set.of(), 1)); } }