This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 8675e1e2c0 hop lint uses a hop-lint.yml from any parent folder of the 
project, f… (#9391)
8675e1e2c0 is described below

commit 8675e1e2c0b2657f57516802e4446b0bf730aba8
Author: Bart Maertens <[email protected]>
AuthorDate: Thu Nov 12 11:24:53 2026 +0100

    hop lint uses a hop-lint.yml from any parent folder of the project, f… 
(#9391)
    
    * hop lint uses a hop-lint.yml from any parent folder of the project, fixes 
#9387
    
    * Address review on #9391: no working-directory boundary, 
hop-project.config and PROJECT_HOME roots, nearest hop-lint.yml in GUI and CLI
---
 .../modules/ROOT/pages/linting/lint-rules.adoc     |  11 +-
 .../ROOT/pages/workflow/actions/runlinter.adoc     |   2 +-
 .../lint/main-0006-lint-config-outside-project.hwf | 191 ++++++++++++++
 .../lint/outside-project/hop-lint.yml              |  25 ++
 .../lint/outside-project/project/orphan.hpl        | 101 +++++++
 .../outside-project/project/project-config.json    |   9 +
 .../lint/outside-project/project/undocumented.hpl  |  45 ++++
 .../main/java/org/apache/hop/lint/HopLinter.java   |  68 ++++-
 .../main/java/org/apache/hop/lint/LintCommand.java |   4 +-
 .../src/main/java/org/apache/hop/lint/LintRun.java |   1 +
 .../org/apache/hop/lint/LinterConfigPlugin.java    |  17 +-
 .../org/apache/hop/lint/registry/RuleRegistry.java | 160 +++++++++--
 .../hop/lint/registry/ProjectYamlBoundaryTest.java | 293 +++++++++++++++++++++
 13 files changed, 892 insertions(+), 35 deletions(-)

diff --git a/docs/hop-user-manual/modules/ROOT/pages/linting/lint-rules.adoc 
b/docs/hop-user-manual/modules/ROOT/pages/linting/lint-rules.adoc
index 8f50bb1771..a7b0bff2fb 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/linting/lint-rules.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/linting/lint-rules.adoc
@@ -502,7 +502,16 @@ That can miss a dead file which happens to share a name 
with a live one, which i
 
 == Configuring a project
 
-Put a `hop-lint.yml` in the project root. It holds overrides and project-local 
rules only, not a copy of the rule packs:
+Put a `hop-lint.yml` in the project root. It holds overrides and project-local 
rules only, not a copy of the rule packs.
+
+A file is linted with the nearest `hop-lint.yml` in its own folder or a folder 
above it, up to the project root.
+That is the same in Hop Gui, `hop lint` and the Run Linter action, so a 
`hop-lint.yml` in a subfolder of the project open in Hop Gui applies to the 
files below it there too.
+The project root is the folder that holds `project-config.json` or 
`hop-project.config`, or the project's home folder (`PROJECT_HOME`) when a 
project is in use, for example the one open in Hop Gui or chosen with `-j`.
+The folder Hop was started from is not a project root.
+A `hop-lint.yml` above the project root, in a home or workspace folder for 
example, is not used for the project's files, and Hop logs once that it is 
ignored.
+To share one `hop-lint.yml` between several projects, at the root of a 
monorepo for example, pass it with `--config` or in the *Config file* field of 
the Run Linter action.
+Paths in `exclude` and `suppress` are relative to the folder of the project's 
`hop-lint.yml`, or of the shared one when it is passed that way.
+A file that is in no project uses the nearest `hop-lint.yml` above it.
 
 [source,yaml]
 ----
diff --git 
a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/runlinter.adoc 
b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/runlinter.adoc
index 54a3dea297..51a26f21a5 100644
--- a/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/runlinter.adoc
+++ b/docs/hop-user-manual/modules/ROOT/pages/workflow/actions/runlinter.adoc
@@ -52,7 +52,7 @@ On by default.
 |Config file
 |`--config`
 |A `hop-lint.yml` to use instead of the project's.
-Leave it empty to use the `hop-lint.yml` in or above the folder.
+Leave it empty to use the `hop-lint.yml` in or above the folder, up to the 
project root.
 
 |Minimum severity
 |`--severity`
diff --git a/integration-tests/lint/main-0006-lint-config-outside-project.hwf 
b/integration-tests/lint/main-0006-lint-config-outside-project.hwf
new file mode 100644
index 0000000000..5ed3abce8a
--- /dev/null
+++ b/integration-tests/lint/main-0006-lint-config-outside-project.hwf
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+  <name>main-0006-lint-config-outside-project</name>
+  <name_sync_with_filename>Y</name_sync_with_filename>
+  <description>Issue #9387: a hop-lint.yml above a project's root is not used 
for that project, and its exclude paths do not apply to it.</description>
+  <extended_description/>
+  <workflow_version/>
+  <created_user>-</created_user>
+  <created_date>2026/11/08 12:00:00.000</created_date>
+  <modified_user>-</modified_user>
+  <modified_date>2026/11/08 12:00:00.000</modified_date>
+  <parameters>
+    </parameters>
+  <actions>
+    <action>
+      <name>Start</name>
+      <description/>
+      <type>SPECIAL</type>
+      <attributes/>
+      <DayOfMonth>1</DayOfMonth>
+      <hour>12</hour>
+      <intervalMinutes>60</intervalMinutes>
+      <intervalSeconds>0</intervalSeconds>
+      <minutes>0</minutes>
+      <repeat>N</repeat>
+      <schedulerType>0</schedulerType>
+      <weekDay>1</weekDay>
+      <parallel>N</parallel>
+      <xloc>96</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Lint the nested project</name>
+      <description>outside-project/project has its own project-config.json and 
no hop-lint.yml. The one in outside-project, above it, switches on DOC-001 and 
excludes orphan.hpl. Fail on None, so the action succeeds, and writes a JSON 
report.</description>
+      <type>RUN_LINTER</type>
+      <attributes/>
+      <target>${PROJECT_HOME}/outside-project/project</target>
+      <include_metadata>Y</include_metadata>
+      <config_file/>
+      <minimum_severity>INFO</minimum_severity>
+      <fail_on>NONE</fail_on>
+      <max_warnings/>
+      <baseline_file/>
+      <report_file>${PROJECT_HOME}/output/outside-project.json</report_file>
+      <report_format>JSON</report_format>
+      <parallel>N</parallel>
+      <xloc>288</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Check the findings</name>
+      <description>TRANS-002 on orphan.hpl (linted) and no DOC-001 (it stays 
off), from the action and from hop lint on each file.</description>
+      <type>SHELL</type>
+      <attributes/>
+      <filename/>
+      <work_directory>${PROJECT_HOME}/outside-project</work_directory>
+      <arg_from_previous>N</arg_from_previous>
+      <exec_per_row>N</exec_per_row>
+      <set_logfile>N</set_logfile>
+      <logfile/>
+      <set_append_logfile>N</set_append_logfile>
+      <logext/>
+      <add_date>N</add_date>
+      <add_time>N</add_time>
+      <insertScript>Y</insertScript>
+      <script>#!/bin/bash
+# Note on ${} below: Hop resolves its own variables in this script before 
running it, so only Hop
+# variables are written with braces. Shell variables are written without them.
+
+set -u
+
+PROJECT_DIR="${PROJECT_HOME}"
+NESTED="$PROJECT_DIR/outside-project/project"
+
+failures=0
+
+# $1 label, $2 actual, $3 expected
+expect() {
+  if [ "$2" != "$3" ]; then
+    echo "FAIL: $1: expected '$3', got '$2'"
+    failures=$((failures + 1))
+  else
+    echo "OK: $1 = $2"
+  fi
+}
+
+echo "=== The Run Linter action ignores the hop-lint.yml above the project ==="
+# With it: one warning, DOC-001 on undocumented.hpl, and orphan.hpl excluded. 
Without it: the four
+# warnings on orphan.hpl, TRANS-002 and three HOP-CHECK remarks on its 
transform with no hops.
+expect "LINT_ERRORS" "${LINT_ERRORS}" "0"
+expect "LINT_WARNINGS" "${LINT_WARNINGS}" "4"
+
+REPORT="$PROJECT_DIR/output/outside-project.json"
+if [ ! -s "$REPORT" ]; then
+  echo "FAIL: the action wrote no report at $REPORT"
+  exit 1
+fi
+expect "TRANS-002 findings" "$(grep -cF '"ruleId" : "TRANS-002"' "$REPORT")" 
"1"
+expect "DOC-001 findings" "$(grep -cF '"ruleId" : "DOC-001"' "$REPORT")" "0"
+
+echo "=== hop lint on one file of the project does the same ==="
+# hop-run.sh starts the JVM from the Hop installation, so ${user.dir} is the 
install folder.
+HOP_CLI="${user.dir}/hop"
+if [ ! -x "$HOP_CLI" ]; then
+  echo "FAIL: no hop CLI at $HOP_CLI"
+  exit 1
+fi
+export HOP_CONFIG_FOLDER="$PROJECT_DIR"
+
+# DOC-001 is off in the core pack: no warning, so --fail-on WARNING passes.
+"$HOP_CLI" lint "$NESTED/undocumented.hpl" --fail-on WARNING --format json \
+  --output "$PROJECT_DIR/output/outside-project-undocumented.json"
+expect "hop lint undocumented.hpl --fail-on WARNING exit code" "$?" "0"
+
+# The exclude above the project does not apply: orphan.hpl is linted, and 
TRANS-002 fails the run.
+"$HOP_CLI" lint "$NESTED/orphan.hpl" --fail-on WARNING --format json \
+  --output "$PROJECT_DIR/output/outside-project-orphan.json"
+expect "hop lint orphan.hpl --fail-on WARNING exit code" "$?" "1"
+
+if [ $failures -gt 0 ]; then
+  echo "$failures check(s) failed."
+  exit 1
+fi
+echo "All checks passed."
+exit 0
+</script>
+      <loglevel>Basic</loglevel>
+      <nr>0</nr>
+      <parallel>N</parallel>
+      <xloc>480</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Success</name>
+      <description/>
+      <type>SUCCESS</type>
+      <attributes/>
+      <parallel>N</parallel>
+      <xloc>672</xloc>
+      <yloc>96</yloc>
+      <attributes_hac/>
+    </action>
+  </actions>
+  <hops>
+    <hop>
+      <from>Start</from>
+      <to>Lint the nested project</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>Y</unconditional>
+    </hop>
+    <hop>
+      <from>Lint the nested project</from>
+      <to>Check the findings</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+    <hop>
+      <from>Check the findings</from>
+      <to>Success</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+  </hops>
+  <notepads>
+  </notepads>
+  <attributes/>
+</workflow>
diff --git a/integration-tests/lint/outside-project/hop-lint.yml 
b/integration-tests/lint/outside-project/hop-lint.yml
new file mode 100644
index 0000000000..8de7d828bc
--- /dev/null
+++ b/integration-tests/lint/outside-project/hop-lint.yml
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+
+# Issue #9387: this file sits above the project in outside-project/project, so 
the linter must not
+# use it for that project. If it did, DOC-001 would report undocumented.hpl, 
and orphan.hpl, which
+# this pattern names relative to this folder, would not be linted: its 
TRANS-002 warning would go.
+rules:
+  DOC-001:
+    enabled: true
+exclude:
+  - "project/orphan.hpl"
diff --git a/integration-tests/lint/outside-project/project/orphan.hpl 
b/integration-tests/lint/outside-project/project/orphan.hpl
new file mode 100644
index 0000000000..b52811a2e9
--- /dev/null
+++ b/integration-tests/lint/outside-project/project/orphan.hpl
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <name>orphan</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description>Issue #8591: one transform with no hops beside two connected 
ones</description>
+    <extended_description/>
+    <pipeline_version/>
+    <pipeline_type>Normal</pipeline_type>
+    <parameters>
+    </parameters>
+    <capture_transform_performance>N</capture_transform_performance>
+    
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <created_user>-</created_user>
+    <created_date>2026/10/10 12:00:00.000</created_date>
+    <modified_user>-</modified_user>
+    <modified_date>2026/10/10 12:00:00.000</modified_date>
+  </info>
+  <notepads>
+  </notepads>
+  <order>
+    <hop>
+      <from>Connected source</from>
+      <to>Connected target</to>
+      <enabled>Y</enabled>
+    </hop>
+  </order>
+  <transform>
+    <name>Connected source</name>
+    <type>Dummy</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+    <GUI>
+      <xloc>64</xloc>
+      <yloc>64</yloc>
+    </GUI>
+  </transform>
+  <transform>
+    <name>Connected target</name>
+    <type>Dummy</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+    <GUI>
+      <xloc>256</xloc>
+      <yloc>64</yloc>
+    </GUI>
+  </transform>
+  <transform>
+    <name>Left over</name>
+    <type>Dummy</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+    <GUI>
+      <xloc>64</xloc>
+      <yloc>192</yloc>
+    </GUI>
+  </transform>
+  <transform_error_handling>
+  </transform_error_handling>
+  <attributes/>
+</pipeline>
diff --git a/integration-tests/lint/outside-project/project/project-config.json 
b/integration-tests/lint/outside-project/project/project-config.json
new file mode 100644
index 0000000000..94f3969eaf
--- /dev/null
+++ b/integration-tests/lint/outside-project/project/project-config.json
@@ -0,0 +1,9 @@
+{
+  "metadataBaseFolder" : "${PROJECT_HOME}/metadata",
+  "unitTestsBasePath" : "${PROJECT_HOME}",
+  "dataSetsCsvFolder" : "${PROJECT_HOME}/datasets",
+  "enforcingExecutionInHome" : true,
+  "config" : {
+    "variables" : [ ]
+  }
+}
diff --git a/integration-tests/lint/outside-project/project/undocumented.hpl 
b/integration-tests/lint/outside-project/project/undocumented.hpl
new file mode 100644
index 0000000000..0493d9ba75
--- /dev/null
+++ b/integration-tests/lint/outside-project/project/undocumented.hpl
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <name>undocumented</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description/>
+    <extended_description/>
+    <pipeline_version/>
+    <pipeline_type>Normal</pipeline_type>
+    <parameters>
+    </parameters>
+    <capture_transform_performance>N</capture_transform_performance>
+    
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <created_user>-</created_user>
+    <created_date>2026/10/09 12:00:00.000</created_date>
+    <modified_user>-</modified_user>
+    <modified_date>2026/10/09 12:00:00.000</modified_date>
+  </info>
+  <notepads>
+  </notepads>
+  <order>
+  </order>
+  <transform_error_handling>
+  </transform_error_handling>
+  <attributes/>
+</pipeline>
diff --git a/plugins/misc/lint/src/main/java/org/apache/hop/lint/HopLinter.java 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/HopLinter.java
index f17d2b2f86..7ff06a20d4 100644
--- a/plugins/misc/lint/src/main/java/org/apache/hop/lint/HopLinter.java
+++ b/plugins/misc/lint/src/main/java/org/apache/hop/lint/HopLinter.java
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Stream;
 import org.apache.hop.core.ICheckResult;
 import org.apache.hop.core.IProgressMonitor;
@@ -81,6 +82,15 @@ public class HopLinter {
   private LinterConfig config;
   private EffectiveRuleSet effectiveRuleSet;
 
+  /** The configuration file given to {@link #loadConfig(String)}, or null. */
+  private File explicitConfigFile;
+
+  /** The home folder of the project in use, {@code PROJECT_HOME}, or null. */
+  private String projectHome;
+
+  /** The root of exclude and suppress paths per folder, as {@link 
#projectRootFor} found it. */
+  private final Map<Path, Optional<Path>> projectRoots = new 
ConcurrentHashMap<>();
+
   /** Whether a folder run lints metadata files too; null follows the Linter 
configuration. */
   private Boolean includeMetadata;
 
@@ -126,6 +136,8 @@ public class HopLinter {
    */
   public void loadConfig(String filePath) throws IOException {
     File configFile = new File(filePath);
+    explicitConfigFile =
+        configFile.exists() ? 
configFile.toPath().toAbsolutePath().normalize().toFile() : null;
     if (!configFile.exists()) {
       log.logBasic("Configuration file not found: " + filePath + ". Using rule 
packs only.");
       applyEffectiveRuleSet(RuleRegistry.getInstance().resolve(null));
@@ -147,6 +159,7 @@ public class HopLinter {
   private void applyEffectiveRuleSet(EffectiveRuleSet resolved) {
     this.effectiveRuleSet = resolved;
     this.config = resolved.getConfig();
+    projectRoots.clear();
     // Detailed, not basic: resolving happens on every lint of every file, and 
now on every
     // right-click that has to work out what the lint menu should offer.
     log.logDetailed(
@@ -227,7 +240,7 @@ public class HopLinter {
       ProgressCallback progressCallback) {
     // In order of preference:
     // 1. Project-specific hop-lint.yml file
-    // 2. hop-lint.yml in parent directories of the project
+    // 2. hop-lint.yml in the folder or a parent folder, up to the project root
     // 3. Configuration plugin settings
     // 4. Default configuration
     loadConfigurationForContext(new File(projectPath));
@@ -482,6 +495,7 @@ public class HopLinter {
    * @param context A file or directory used to locate hop-lint.yml in parent 
folders
    */
   public void loadConfigurationForContext(File context) {
+    explicitConfigFile = null;
     try {
       if (isSwitchedOff()) {
         this.config = new LinterConfig();
@@ -507,7 +521,8 @@ public class HopLinter {
    * @throws LintConfigurationException when the project's {@code 
hop-lint.yml} cannot be read
    */
   public void loadConfigurationStrictly(File context) {
-    
applyEffectiveRuleSet(RuleRegistry.getInstance().resolveForContext(context));
+    explicitConfigFile = null;
+    
applyEffectiveRuleSet(RuleRegistry.getInstance().resolveForContext(context, 
projectHome));
   }
 
   /** Whether the linter is switched off in Hop Gui's configuration. */
@@ -871,15 +886,52 @@ public class HopLinter {
    * <p>Patterns are written against project-relative paths so a configuration 
is portable between a
    * developer's machine and CI. The root is the folder holding the project's 
hop-lint.yml, which is
    * what the user means by "the project".
+   *
+   * <p>Remembered per folder for the life of this linter, which is one run: 
finding it stats a file
+   * or two in every folder up to the project root, and a project lint asks 
for every file it lints,
+   * which on a network drive adds up.
    */
   private Path projectRootFor(String fileName) {
-    File configFile = RuleRegistry.getInstance().findProjectYaml(new 
File(fileName));
+    File file = new File(fileName);
+    Path path = file.toPath().toAbsolutePath().normalize();
+    Path directory = file.isDirectory() ? path : path.getParent();
+    if (directory == null) {
+      return null;
+    }
+    return projectRoots
+        .computeIfAbsent(directory, key -> 
Optional.ofNullable(findProjectRoot(file, key)))
+        .orElse(null);
+  }
+
+  private Path findProjectRoot(File file, Path directory) {
+    File configFile =
+        RuleRegistry.getInstance().findProjectYaml(file, projectHome, 
explicitConfigFile == null);
+    if (configFile == null && isHopLintYmlAbove(explicitConfigFile, 
directory)) {
+      // A hop-lint.yml above the project root, passed with --config or in the 
Run Linter action.
+      configFile = explicitConfigFile;
+    }
     if (configFile != null && configFile.getParentFile() != null) {
       return configFile.getParentFile().toPath().toAbsolutePath();
     }
     return null;
   }
 
+  /** Whether this configuration file is the nearest hop-lint.yml in this 
folder or one above. */
+  private static boolean isHopLintYmlAbove(File configFile, Path start) {
+    if (configFile == null) {
+      return false;
+    }
+    for (File directory = start.toFile();
+        directory != null;
+        directory = directory.getParentFile()) {
+      File candidate = new File(directory, RuleRegistry.LINT_CONFIG_FILENAME);
+      if (candidate.isFile()) {
+        return candidate.equals(configFile);
+      }
+    }
+    return false;
+  }
+
   private boolean shouldIncludeNativeChecks() {
     try {
       return LinterConfigPlugin.getInstance().isIncludeNativeChecks();
@@ -896,6 +948,16 @@ public class HopLinter {
     this.includeMetadata = includeMetadata;
   }
 
+  /**
+   * @param projectHome the home folder of the project in use, {@code 
PROJECT_HOME}, or null. The
+   *     search for a hop-lint.yml stops there, which covers a project whose 
configuration file has
+   *     a name of its own. Set it before loading the configuration.
+   */
+  public void setProjectHome(String projectHome) {
+    this.projectHome = projectHome;
+    projectRoots.clear();
+  }
+
   private boolean includeMetadataInProjectLint() {
     if (includeMetadata != null) {
       return includeMetadata;
diff --git 
a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintCommand.java 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintCommand.java
index 34f883b2d8..47d69f81cb 100644
--- a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintCommand.java
+++ b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintCommand.java
@@ -585,7 +585,8 @@ public class LintCommand implements Callable<Integer>, 
IHopCommand, IHasHopMetad
     EffectiveRuleSet ruleSet =
         configFile != null
             ? RuleRegistry.getInstance().resolve(new File(configFile))
-            : RuleRegistry.getInstance().resolveForContext(new File(context));
+            : RuleRegistry.getInstance()
+                .resolveForContext(new File(context), 
variables().getVariable("PROJECT_HOME"));
 
     List<CustomLintRule> rules = new ArrayList<>(ruleSet.getRules());
     rules.sort(Comparator.comparing(CustomLintRule::generateRuleId));
@@ -632,6 +633,7 @@ public class LintCommand implements Callable<Integer>, 
IHopCommand, IHasHopMetad
     // project's hop-lint.yml or an installed pack could not be read.
     LintRun.checkRulePacks();
     HopLinter linter = new HopLinter();
+    linter.setProjectHome(variables().getVariable("PROJECT_HOME"));
     linter.loadConfigurationStrictly(firstFile);
 
     // The lint target for path-relative purposes is the project the staged 
files live in.
diff --git a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintRun.java 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintRun.java
index d71785e6c1..3738bfa044 100644
--- a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintRun.java
+++ b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LintRun.java
@@ -129,6 +129,7 @@ public class LintRun {
 
     HopLinter linter = new HopLinter();
     linter.setIncludeMetadata(includeMetadata);
+    linter.setProjectHome(variables == null ? null : 
variables.getVariable("PROJECT_HOME"));
     if (configFile != null) {
       if (!configFile.isFile()) {
         throw new IOException("Configuration file not found: " + configFile);
diff --git 
a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LinterConfigPlugin.java 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LinterConfigPlugin.java
index 83eb369e77..081e2e5d0c 100644
--- 
a/plugins/misc/lint/src/main/java/org/apache/hop/lint/LinterConfigPlugin.java
+++ 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/LinterConfigPlugin.java
@@ -548,7 +548,22 @@ public class LinterConfigPlugin implements IConfigOptions, 
IGuiPluginCompositeWi
     this.configFilePath = configFilePath;
   }
 
+  /** The project folder; outside Hop Gui, the working directory. */
   public String getProjectPath() {
+    return projectFolder(true);
+  }
+
+  /**
+   * The folder of the configured hop-lint.yml or of the project Hop Gui has 
open, or null. Unlike
+   * {@link #getProjectPath()} this never falls back to the working directory, 
which is no project:
+   * hop-run or a container started in a project's subfolder has that 
subfolder as its working
+   * directory.
+   */
+  public String getProjectHome() {
+    return projectFolder(false);
+  }
+
+  private String projectFolder(boolean workingDirectoryOutsideGui) {
     if (configFilePath != null && !configFilePath.isEmpty()) {
       return new File(configFilePath).getParent();
     }
@@ -573,7 +588,7 @@ public class LinterConfigPlugin implements IConfigOptions, 
IGuiPluginCompositeWi
       log.logDetailed("No Hop GUI available to resolve the project path: " + 
e);
     }
 
-    return System.getProperty("user.dir");
+    return workingDirectoryOutsideGui ? System.getProperty("user.dir") : null;
   }
 
   /** The effective set of lint rules for the current project (YAML packs + 
project overrides). */
diff --git 
a/plugins/misc/lint/src/main/java/org/apache/hop/lint/registry/RuleRegistry.java
 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/registry/RuleRegistry.java
index a4201c9708..6801939817 100644
--- 
a/plugins/misc/lint/src/main/java/org/apache/hop/lint/registry/RuleRegistry.java
+++ 
b/plugins/misc/lint/src/main/java/org/apache/hop/lint/registry/RuleRegistry.java
@@ -17,11 +17,15 @@
 package org.apache.hop.lint.registry;
 
 import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.apache.hop.core.logging.LogChannel;
 import org.apache.hop.core.util.Utils;
@@ -38,6 +42,15 @@ public class RuleRegistry {
 
   private static final RuleRegistry INSTANCE = new RuleRegistry();
 
+  public static final String LINT_CONFIG_FILENAME = "hop-lint.yml";
+
+  /**
+   * The files that mark a Hop project's home folder, the ones the projects 
plugin looks for. A
+   * project with a configuration file of another name is recognised by its 
home folder instead.
+   */
+  private static final List<String> PROJECT_CONFIG_FILENAMES =
+      List.of("project-config.json", "hop-project.config");
+
   private final RulePackDiscovery packDiscovery;
 
   /**
@@ -323,51 +336,142 @@ public class RuleRegistry {
   }
 
   public EffectiveRuleSet resolveForContext(File context) {
-    return resolve(findProjectYaml(context));
+    return resolveForContext(context, null);
+  }
+
+  /**
+   * @param projectHome the home folder of the project in use, {@code 
PROJECT_HOME}, or null
+   * @see #findProjectYaml(File, String, boolean)
+   */
+  public EffectiveRuleSet resolveForContext(File context, String projectHome) {
+    return resolve(findProjectYaml(context, projectHome, true));
   }
 
+  /** The rules of the project Hop Gui has open, or of the rule packs alone 
when none is open. */
   public EffectiveRuleSet resolveForCurrentProject() {
-    File projectYaml = null;
-    try {
-      String projectPath = LinterConfigPlugin.getInstance().getProjectPath();
-      if (!Utils.isEmpty(projectPath)) {
-        projectYaml = new File(projectPath, "hop-lint.yml");
-      }
-    } catch (Exception ignored) {
-      // CLI mode
-    }
-    return resolve(
-        projectYaml != null && projectYaml.exists() ? projectYaml : 
findProjectYaml(null));
+    return resolve(findProjectYaml(null));
   }
 
-  /** Locate the project hop-lint.yml governing a file, or null. Used to root 
relative patterns. */
+  /**
+   * Locate the project hop-lint.yml governing a file, or null. Used to root 
relative patterns.
+   *
+   * @see #findProjectYaml(File, String, boolean)
+   */
   public File findProjectYaml(File context) {
+    return findProjectYaml(context, null, true);
+  }
+
+  /**
+   * Locate the project hop-lint.yml governing a file, or null. Used to root 
relative patterns.
+   *
+   * <p>The nearest hop-lint.yml in the file's folder or above it is used, up 
to the project root:
+   * the folder holding {@code project-config.json} or {@code 
hop-project.config}, the project's
+   * home folder, or the project Hop Gui has open. A hop-lint.yml above the 
project, left in a home
+   * or workspace folder, changed the findings of every project below it and 
rooted their exclude
+   * and suppress paths outside the project, so a CI checkout linted 
differently from a developer's
+   * machine. A file in no project still uses the nearest one above it.
+   *
+   * <p>The working directory is not a project root: hop-run, hop-server or a 
container started in a
+   * project's subfolder would otherwise stop the search there and miss the 
project's own file.
+   *
+   * @param context the file or folder being linted; null for the project Hop 
Gui has open
+   * @param projectHome the home folder of the project in use, {@code 
PROJECT_HOME}, or null
+   * @param warnAboutOneAbove whether to say once that a hop-lint.yml above 
the project root is not
+   *     used; off when the run has a configuration file of its own
+   */
+  public File findProjectYaml(File context, String projectHome, boolean 
warnAboutOneAbove) {
+    Set<Path> projectHomes = new LinkedHashSet<>();
+    addProjectHome(projectHomes, projectHome);
+    String guiProjectHome = null;
     try {
-      String projectPath = LinterConfigPlugin.getInstance().getProjectPath();
-      if (!Utils.isEmpty(projectPath)) {
-        File projectConfig = new File(projectPath, "hop-lint.yml");
-        if (projectConfig.exists()) {
-          return projectConfig;
-        }
-      }
-    } catch (Exception ignored) {
+      guiProjectHome = LinterConfigPlugin.getInstance().getProjectHome();
+    } catch (Exception | LinkageError ignored) {
       // Plugin may not be initialized in CLI mode.
     }
+    addProjectHome(projectHomes, guiProjectHome);
 
-    File directory =
-        context != null && context.isDirectory()
-            ? context
-            : (context != null ? context.getParentFile() : null);
+    Path directory;
+    if (context != null) {
+      // Absolute first: the parents of a relative path run out before the 
project root.
+      Path path = normalised(context);
+      directory = context.isDirectory() ? path : path.getParent();
+    } else {
+      directory = Utils.isEmpty(guiProjectHome) ? null : normalised(new 
File(guiProjectHome));
+    }
     while (directory != null) {
-      File configFile = new File(directory, "hop-lint.yml");
-      if (configFile.exists()) {
+      File configFile = directory.resolve(LINT_CONFIG_FILENAME).toFile();
+      if (configFile.isFile()) {
         return configFile;
       }
-      directory = directory.getParentFile();
+      if (projectHomes.contains(directory) || 
hasProjectConfig(directory.toFile())) {
+        if (warnAboutOneAbove) {
+          warnAboutHopLintYmlAbove(directory.toFile());
+        }
+        return null;
+      }
+      directory = directory.getParent();
     }
     return null;
   }
 
+  /**
+   * Add a project home folder as written and, when it differs, as it is on 
disk: a home reached
+   * through a symbolic link never equals the folder a file's path walks 
through otherwise.
+   */
+  private static void addProjectHome(Set<Path> projectHomes, String 
projectHome) {
+    if (Utils.isEmpty(projectHome)) {
+      return;
+    }
+    Path path = normalised(new File(projectHome));
+    projectHomes.add(path);
+    try {
+      projectHomes.add(path.toRealPath());
+    } catch (IOException | SecurityException e) {
+      // A home folder that does not exist marks no files.
+    }
+  }
+
+  private static Path normalised(File file) {
+    return file.toPath().toAbsolutePath().normalize();
+  }
+
+  /**
+   * Say once that a hop-lint.yml above the project root is not used, so that 
one shared above
+   * several projects, at the root of a monorepo for example, does not stop 
applying without a word.
+   * The hop-lint.yml of an enclosing project is that project's own and is not 
mentioned.
+   */
+  private static void warnAboutHopLintYmlAbove(File projectRoot) {
+    for (File directory = projectRoot.getAbsoluteFile().getParentFile();
+        directory != null;
+        directory = directory.getParentFile()) {
+      if (hasProjectConfig(directory)) {
+        return;
+      }
+      File configFile = new File(directory, LINT_CONFIG_FILENAME);
+      if (configFile.isFile()) {
+        String warning =
+            "Warning: "
+                + configFile.getAbsolutePath()
+                + " is above the project root "
+                + projectRoot.getAbsolutePath()
+                + " and is not used. Pass it with --config or in the Config 
file field of the"
+                + " Run Linter action, or copy it into the project.";
+        LintWarnings.logOnce(warning, warning);
+        return;
+      }
+    }
+  }
+
+  /** Whether this folder holds a project configuration file, which makes it a 
project's root. */
+  private static boolean hasProjectConfig(File directory) {
+    for (String filename : PROJECT_CONFIG_FILENAMES) {
+      if (new File(directory, filename).isFile()) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   private LinterConfig buildLinterConfig(Map<String, CustomLintRule> merged) {
     LinterConfig config = new LinterConfig();
     for (CustomLintRule rule : merged.values()) {
diff --git 
a/plugins/misc/lint/src/test/java/org/apache/hop/lint/registry/ProjectYamlBoundaryTest.java
 
b/plugins/misc/lint/src/test/java/org/apache/hop/lint/registry/ProjectYamlBoundaryTest.java
new file mode 100644
index 0000000000..5bf1ad36b3
--- /dev/null
+++ 
b/plugins/misc/lint/src/test/java/org/apache/hop/lint/registry/ProjectYamlBoundaryTest.java
@@ -0,0 +1,293 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hop.lint.registry;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.function.Supplier;
+import org.apache.hop.core.logging.HopLogStore;
+import org.apache.hop.core.logging.IHopLoggingEventListener;
+import org.apache.hop.core.logging.LogLevel;
+import org.apache.hop.lint.CustomLintRule;
+import org.apache.hop.lint.HopLinter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+/**
+ * A hop-lint.yml above the project root is not the project's (#9387). It used 
to be found by
+ * walking up to the root of the file system, so one left in a home or 
workspace folder changed the
+ * findings of every project below it, and its folder became the root of 
exclude and suppress paths.
+ */
+class ProjectYamlBoundaryTest {
+
+  @TempDir private Path workspace;
+  private Path project;
+  private File pipeline;
+
+  @BeforeEach
+  void createProject() throws Exception {
+    project = workspace.resolve("samples");
+    Files.createDirectories(project.resolve("transforms/zero-shot"));
+    Files.writeString(project.resolve("project-config.json"), "{}\n");
+    pipeline = project.resolve("transforms/zero-shot/openai.hpl").toFile();
+    Files.writeString(pipeline.toPath(), "<pipeline/>\n");
+  }
+
+  @Test
+  void aHopLintYmlAboveTheProjectIsNotUsed() throws Exception {
+    Files.writeString(
+        workspace.resolve("hop-lint.yml"), "rules:\n  SEC-002:\n    enabled: 
false\n");
+
+    assertNull(RuleRegistry.getInstance().findProjectYaml(pipeline));
+    assertTrue(ruleOf("SEC-002", pipeline).isEnabled(), "SEC-002 was switched 
off from outside");
+  }
+
+  @Test
+  void theProjectRootHopLintYmlIsUsed() throws Exception {
+    Files.writeString(workspace.resolve("hop-lint.yml"), "rules:\n  SEC-002:\n 
   enabled: true\n");
+    Path projectYaml = project.resolve("hop-lint.yml");
+    Files.writeString(projectYaml, "rules:\n  SEC-002:\n    enabled: false\n");
+
+    assertEquals(projectYaml.toFile(), 
RuleRegistry.getInstance().findProjectYaml(pipeline));
+    assertFalse(ruleOf("SEC-002", pipeline).isEnabled());
+  }
+
+  @Test
+  void aHopLintYmlInAFolderOfTheProjectStillWins() throws Exception {
+    Files.writeString(project.resolve("hop-lint.yml"), "rules: {}\n");
+    Path nested = project.resolve("transforms/hop-lint.yml");
+    Files.writeString(nested, "rules: {}\n");
+
+    assertEquals(nested.toFile(), 
RuleRegistry.getInstance().findProjectYaml(pipeline));
+  }
+
+  @Test
+  void aProjectNestedInAnotherProjectStopsAtItsOwnRoot() throws Exception {
+    Files.writeString(workspace.resolve("project-config.json"), "{}\n");
+    Files.writeString(workspace.resolve("hop-lint.yml"), "rules: {}\n");
+
+    assertNull(RuleRegistry.getInstance().findProjectYaml(pipeline));
+  }
+
+  @Test
+  void aFileInNoProjectStillUsesTheNearestHopLintYmlAboveIt() throws Exception 
{
+    Path loose = workspace.resolve("loose/load.hpl");
+    Files.createDirectories(loose.getParent());
+    Files.writeString(loose, "<pipeline/>\n");
+    Path workspaceYaml = workspace.resolve("hop-lint.yml");
+    Files.writeString(workspaceYaml, "rules: {}\n");
+
+    assertEquals(
+        workspaceYaml.toFile(), 
RuleRegistry.getInstance().findProjectYaml(loose.toFile()));
+  }
+
+  @Test
+  void excludePathsAreNotRootedAboveTheProject() throws Exception {
+    // Relative to the workspace, which is how the file was excluded before.
+    Files.writeString(
+        workspace.resolve("hop-lint.yml"), "exclude:\n  - 
\"samples/transforms/**\"\n");
+    HopLinter linter = new HopLinter();
+    linter.loadConfigurationStrictly(pipeline);
+
+    assertFalse(linter.isExcluded(pipeline.getAbsolutePath()));
+  }
+
+  @Test
+  void excludePathsAreRelativeToTheProjectRoot() throws Exception {
+    Files.writeString(project.resolve("hop-lint.yml"), "exclude:\n  - 
\"transforms/**\"\n");
+    HopLinter linter = new HopLinter();
+    linter.loadConfigurationStrictly(pipeline);
+
+    assertTrue(linter.isExcluded(pipeline.getAbsolutePath()));
+  }
+
+  @Test
+  void aHopProjectConfigFileMarksTheProjectRootToo() throws Exception {
+    Files.delete(project.resolve("project-config.json"));
+    Files.writeString(project.resolve("hop-project.config"), "{}\n");
+    Files.writeString(workspace.resolve("hop-lint.yml"), "rules: {}\n");
+
+    assertNull(RuleRegistry.getInstance().findProjectYaml(pipeline));
+  }
+
+  /** A project whose configuration file has a name of its own has no marker; 
its home stops it. */
+  @Test
+  void theProjectHomeIsTheRootOfAProjectWithoutAMarker() throws Exception {
+    Files.delete(project.resolve("project-config.json"));
+    Files.writeString(workspace.resolve("hop-lint.yml"), "rules: {}\n");
+
+    assertNull(RuleRegistry.getInstance().findProjectYaml(pipeline, 
project.toString(), false));
+    // Written with ".." it is the same folder.
+    String throughParent = project.resolve("transforms/..").toString();
+    assertNull(RuleRegistry.getInstance().findProjectYaml(pipeline, 
throughParent, false));
+  }
+
+  /** With a project in use the nearest hop-lint.yml still wins, as it does 
without one. */
+  @Test
+  void aHopLintYmlInAFolderOfTheProjectInUseWins() throws Exception {
+    Files.writeString(project.resolve("hop-lint.yml"), "rules: {}\n");
+    Path nested = project.resolve("transforms/hop-lint.yml");
+    Files.writeString(nested, "rules: {}\n");
+
+    assertEquals(
+        nested.toFile(),
+        RuleRegistry.getInstance().findProjectYaml(pipeline, 
project.toString(), false));
+  }
+
+  /**
+   * hop-run, hop-server or a container started in a project's subfolder has 
that subfolder as its
+   * working directory. That is no project root, and the project's own 
hop-lint.yml still applies.
+   */
+  @Test
+  void theWorkingDirectoryIsNotAProjectRoot() throws Exception {
+    Path projectYaml = project.resolve("hop-lint.yml");
+    Files.writeString(projectYaml, "rules: {}\n");
+
+    File found =
+        withWorkingDirectory(
+            project.resolve("transforms"),
+            () -> RuleRegistry.getInstance().findProjectYaml(pipeline));
+
+    assertEquals(projectYaml.toFile(), found);
+  }
+
+  /** A hop-lint.yml left in the folder Hop runs from, the installation, is no 
project's. */
+  @Test
+  void aHopLintYmlInTheWorkingDirectoryIsNotTheCurrentProjects() throws 
Exception {
+    Path hopHome = workspace.resolve("hop");
+    Files.createDirectories(hopHome);
+    Files.writeString(hopHome.resolve("hop-lint.yml"), "rules:\n  SEC-002:\n   
 enabled: false\n");
+
+    EffectiveRuleSet ruleSet =
+        withWorkingDirectory(hopHome, () -> 
RuleRegistry.getInstance().resolveForCurrentProject());
+
+    assertTrue(
+        ruleSet.getRules().stream()
+            .filter(rule -> "SEC-002".equals(rule.generateRuleId()))
+            .findFirst()
+            .orElseThrow()
+            .isEnabled());
+  }
+
+  /** The parents of a relative path run out before the project root; it is 
made absolute first. */
+  @Test
+  void aRelativePathIsResolvedAgainstTheWorkingDirectory() throws Exception {
+    Path projectYaml = project.resolve("hop-lint.yml");
+    Files.writeString(projectYaml, "rules: {}\n");
+    File relative = 
Path.of("").toAbsolutePath().relativize(pipeline.toPath()).toFile();
+
+    assertEquals(projectYaml.toFile(), 
RuleRegistry.getInstance().findProjectYaml(relative));
+  }
+
+  private static <T> T withWorkingDirectory(Path directory, Supplier<T> 
action) {
+    String previous = System.getProperty("user.dir");
+    System.setProperty("user.dir", directory.toString());
+    try {
+      return action.get();
+    } finally {
+      System.setProperty("user.dir", previous);
+    }
+  }
+
+  /**
+   * A hop-lint.yml shared above several projects, at the root of a monorepo, 
stops applying. Hop
+   * says so once, not for every file it lints.
+   */
+  @Test
+  void aHopLintYmlAboveTheProjectIsReportedOnce() throws Exception {
+    Path workspaceYaml = workspace.resolve("hop-lint.yml");
+    Files.writeString(workspaceYaml, "rules: {}\n");
+    File other = project.resolve("transforms/other.hpl").toFile();
+    Files.writeString(other.toPath(), "<pipeline/>\n");
+
+    List<String> logged =
+        warningsAbout(
+            workspaceYaml,
+            () -> {
+              RuleRegistry.getInstance().findProjectYaml(pipeline);
+              RuleRegistry.getInstance().findProjectYaml(other);
+              RuleRegistry.getInstance().findProjectYaml(pipeline);
+            });
+
+    assertEquals(1, logged.size(), logged.toString());
+    assertTrue(logged.get(0).contains("--config"), logged.get(0));
+  }
+
+  @Test
+  void theHopLintYmlOfAnEnclosingProjectIsNotReported() throws Exception {
+    Files.writeString(workspace.resolve("project-config.json"), "{}\n");
+    Path workspaceYaml = workspace.resolve("hop-lint.yml");
+    Files.writeString(workspaceYaml, "rules: {}\n");
+
+    List<String> logged =
+        warningsAbout(workspaceYaml, () -> 
RuleRegistry.getInstance().findProjectYaml(pipeline));
+
+    assertTrue(logged.isEmpty(), logged.toString());
+  }
+
+  /** Passed with --config, as the warning says, it applies the way it did 
before #9387. */
+  @Test
+  void aHopLintYmlAboveTheProjectPassedAsConfigRootsItsExcludePaths() throws 
Exception {
+    Path workspaceYaml = workspace.resolve("hop-lint.yml");
+    Files.writeString(workspaceYaml, "exclude:\n  - 
\"samples/transforms/**\"\n");
+    HopLinter linter = new HopLinter();
+    linter.loadConfig(workspaceYaml.toString());
+
+    List<String> logged =
+        warningsAbout(
+            workspaceYaml, () -> 
assertTrue(linter.isExcluded(pipeline.getAbsolutePath())));
+
+    assertTrue(logged.isEmpty(), "the file is in use: " + logged);
+  }
+
+  private static List<String> warningsAbout(Path hopLintYml, Runnable action) {
+    HopLogStore.init();
+    String path = hopLintYml.toFile().getAbsolutePath();
+    List<String> logged = new ArrayList<>();
+    IHopLoggingEventListener listener =
+        event -> {
+          if (event.getLevel() == LogLevel.MINIMAL
+              && String.valueOf(event.getMessage()).contains(path)) {
+            logged.add(String.valueOf(event.getMessage()));
+          }
+        };
+    HopLogStore.getAppender().addLoggingEventListener(listener);
+    try {
+      action.run();
+    } finally {
+      HopLogStore.getAppender().removeLoggingEventListener(listener);
+    }
+    return logged;
+  }
+
+  private static CustomLintRule ruleOf(String ruleId, File context) {
+    return 
RuleRegistry.getInstance().resolveForContext(context).getRules().stream()
+        .filter(rule -> ruleId.equals(rule.generateRuleId()))
+        .findFirst()
+        .orElseThrow();
+  }
+}

Reply via email to