6.2.11.5. ImportKnip¶
Run knip and import its results
Runs knip and imports its findings (unused files, dependencies, exports, and so on) as analysis violations.
knip is invoked with --reporter sarif, which needs knip 6.35 or
later. Each result becomes a violation with the
provider
option's value, knip by default, and knip's rule id, e.g.
knip/exports, as its error number.
knip discovers its configuration from the working directory, for example a
knip.json. Set config_file to use a
specific configuration file instead.
knip needs a package.json in the working directory, and the
project's dependencies installed, so that the configuration files of its plugins
(for example vite.config.ts) can be loaded.
Possible Messages
This rule has no predefined messages.
Options¶
This rule shares the following common options: exclude_messages_in_system_headers, excludes, includes, justification_checker, post_processing, provider, severity
The following places define options that affect this rule: Analysis-GlobalOptions
additional_args¶
additional_args : list[str] = ['--no-exit-code']
check_returncode¶
check_returncode : bool = True
Whether a non-zero exit status of the tool fails the rule. Turn it off for tools that report findings through their exit status, as many linters do.
Independent of this option, a run that imports no violations while the tool exits non-zero fails: its results are indistinguishable from a run in which the tool found nothing.
config_file¶
config_file : bauhaus.analysis.config.PlainPath | None = None
knip configuration file, relative to cwd, passed as
--config in place of knip's own lookup; a knip entry in
package.json is still merged into it.
cwd¶
cwd : bauhaus.analysis.config.LayerRelativePath | None = None
encoding¶
encoding : str = 'utf-8'
encoding_error_handler¶
encoding_error_handler
Type: EncodingErrorHandler
Default:
'IGNORE'
The strategy to handle encoding errors during processing of the output of the executed command.
STRICT: abort with on error on encoding errors,IGNORE: ignore encoding errors (accepting data loss),REPLACE: replace problematic code points with a question mark (?).
environment¶
environment : dict[str, str] = {}
executable¶
executable : bauhaus.analysis.config.PlainPath | None = None
Option Types¶
These types are used by options listed above:
EncodingErrorHandler¶
STRICT
IGNORE
REPLACE