Skip to content

Review skipExcludes Analyzer option #10292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tsteenbe opened this issue May 8, 2025 · 4 comments
Open

Review skipExcludes Analyzer option #10292

tsteenbe opened this issue May 8, 2025 · 4 comments
Labels
analyzer About the analyzer tool documentation About end-user documentation

Comments

@tsteenbe
Copy link
Member

tsteenbe commented May 8, 2025

In the ORT community meeting of May 8th, 2025 there was some confusion of how skipExcludes works for the Analyzer as a question to 13960e9 / PR #10212. Propose we review the code in question and as needed make it clearer with code comments how the code works and improve user document to state for which package managers this Analyzer option is supported.

@tsteenbe tsteenbe added analyzer About the analyzer tool documentation About end-user documentation labels May 8, 2025
@tsteenbe tsteenbe changed the title Review skipExcludes Analyzer options Review skipExcludes Analyzer option May 8, 2025
@sschuberth
Copy link
Member

In particular, this logic should be reviewed:

/**
* Return an [Excludes] instance to be applied during analysis based on the given [repositoryConfiguration].
* If this [AnalyzerConfiguration] has the [AnalyzerConfiguration.skipExcluded] flag set to true, the
* excludes configured in [repositoryConfiguration] are actually applied. Otherwise, return an empty [Excludes]
* object. This means that all dependencies are collected, and excludes are applied later on the report level.
*/
internal fun AnalyzerConfiguration.excludes(repositoryConfiguration: RepositoryConfiguration): Excludes =
repositoryConfiguration.excludes.takeIf { skipExcluded } ?: Excludes.EMPTY

@sschuberth
Copy link
Member

To me, this reads as if this option works very different compared to options of the same name in other tools, e.g. ScannerConfiguration.skipExcluded:

Instead of configuring whether analysis should be skipped, it configures whether excludes defined in the RepositoryConfiguration should be taken into account or not. Or am I misreading things, @oss-review-toolkit/kotlin-devs?

@oheger-bosch
Copy link
Member

From my understanding, the feature works in this way:

  • An Excludes object is used by the Analyzer to control which parts of the project should be analyzed. Based on this, Analyzer may for instance filter out definition files matched by path excludes.
  • If the skipExcluded flag is true, this Excludes object is initialized from the exclusion rules defined in the repository configuration. So, everything marked as to be excluded there is going to be skipped.
  • If the skipExcluded flag is false, an empty Excludes object is used. Then Analyzer will do a full analysis, and later pipeline steps can ignore parts of the result based on the exclusion rules from the repository configuration.

I assume, this is actually what this feature is supposed to do, right?

@sschuberth
Copy link
Member

I think the behavior is indeed correct, but the naming / docs are partly misleading. For example the comment at

/**
* Defines which parts of the repository will be excluded. Note that excluded parts will still be analyzed and
* scanned, but related errors will be marked as resolved in the reporter output.
*/
@JsonInclude(value = JsonInclude.Include.CUSTOM, valueFilter = ExcludesFilter::class)
val excludes: Excludes = Excludes(),

says "Note that excluded parts will still be analyzed" which is not true e.g. for path excludes and skipExcluded enabled.

In general, path and scope excludes are handled quite differently, so that I'm thinking about having dedicated classes for each, actually. Path excludes are handled globally by findManagedFiles(), see

excludes.isPathExcluded(rootPath, dirAsPath) -> {
logger.info { "Not analyzing directory '$dir' as it is excluded." }
false
}

whereas scope excludes are sometimes handled directly in the package manager implementation, but are also handled by some (?) OrtResult helper functions / properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer About the analyzer tool documentation About end-user documentation
Projects
None yet
Development

No branches or pull requests

3 participants