Skip to content

Commit

Permalink
The plugn description migration probe requires to have a clone of the…
Browse files Browse the repository at this point in the history
… code (#488)
  • Loading branch information
alecharp authored Mar 15, 2024
1 parent ef679f2 commit 77d1a4a
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand All @@ -40,7 +39,7 @@
@Order(PluginDescriptionMigrationProbe.ORDER)
public class PluginDescriptionMigrationProbe extends Probe {
public static final String KEY = "description-migration";
public static final int ORDER = DocumentationMigrationProbe.ORDER + 100;
public static final int ORDER = SCMLinkValidationProbe.ORDER + 100;

@Override
protected ProbeResult doApply(Plugin plugin, ProbeContext context) {
Expand All @@ -50,21 +49,20 @@ protected ProbeResult doApply(Plugin plugin, ProbeContext context) {
}

final Path repository = scmRepositoryOpt.get();
final Path pluginFolder = context.getScmFolderPath().map(repository::resolve).orElse(repository);
final Path pluginFolder =
context.getScmFolderPath().map(repository::resolve).orElse(repository);

try (Stream<Path> files = Files.find(
pluginFolder.resolve("src").resolve("main").resolve("resources"),
1,
(path, attributes) -> "index.jelly".equals(path.getFileName().toString())
)) {
pluginFolder.resolve("src").resolve("main").resolve("resources"), 1, (path, attributes) -> "index.jelly"
.equals(path.getFileName().toString()))) {
final Optional<Path> jellyFileOpt = files.findFirst();
if (jellyFileOpt.isEmpty()) {
return success("There is no `index.jelly` file in `src/main/resources`.");
}
final Path jellyFile = jellyFileOpt.get();
return Files.readAllLines(jellyFile).stream().map(String::trim).anyMatch(s -> s.contains("TODO")) ?
success("Plugin is using description from the plugin archetype.") :
success("Plugin seems to have a correct description.");
return Files.readAllLines(jellyFile).stream().map(String::trim).anyMatch(s -> s.contains("TODO"))
? success("Plugin is using description from the plugin archetype.")
: success("Plugin seems to have a correct description.");
} catch (IOException e) {
return error("Cannot browse plugin source code folder.");
}
Expand Down

0 comments on commit 77d1a4a

Please sign in to comment.