Skip to content

Conversation

@dtor
Copy link

@dtor dtor commented Nov 20, 2025

Linux kernel is not the only project that uses checkpatch.pl for patch validation, other projects (for example qemu) use it too, and their version is different from the one used by the kernel. Also checkpatch.pl changes from kernel version to kernel version when working with multiple versions, so requiring a single version covering everything is not practical.

Additionally running checkpatch.pl on projects that do not use it and do not use kernel coding style is counter-productive.

To solve this issue make the linter locate and favor the version of checkpatch.pl belonging to the project that file being linted belongs to. Also, if checkpatch.pl is not accessible use "true" as the command so that there are no errors/notifications and no diagnostic.

Comment on lines 23 to 38
local git_dir = vim.fs.find('.git', {
path = dir,
upward = true,
type = 'directory',
limit = 1,
})[1]

if git_dir then
local project_root = vim.fs.dirname(git_dir)
local tool_path = vim.fs.joinpath(project_root, 'scripts', tool_name)
if vim.fn.executable(tool_path) == 1 then
return tool_path
end
end

if vim.fn.executable(tool_name) == 1 then
Copy link
Owner

@mfussenegger mfussenegger Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change this to only check ./scripts/checkpath.pl? Project root dir detection is out of scope for nvim-lint as managing root heuristics that fit everyone would be too much of a hassle to maintain. Users can provide a custom cwd as part of the try_lint call if cwd != project_root.

See also:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I can do that. Would you be open to make linter's cwd a function? This way users would not need to map from file type to linter before calling try_lint() to decide whether they need to supply cwd

Linux kernel is not the only project that uses checkpatch.pl for patch
validation, other projects (for example qemu) use it too, and their
version is different from the one used by the kernel. Also checkpatch.pl
changes from kernel version to kernel version when working with multiple
versions, so requiring a single version covering everything is not
practical.

Additionally running checkpatch.pl on projects that do not use it and do
not use kernel coding style is counter-productive.

To solve this issue make the linter locate and favor the version of
checkpatch.pl belonging to the project that file being linted belongs
to. Also, if checkpatch.pl is not accessible use "true" as the command
so that there are no errors/notifications and no diagnostic.
@dtor dtor force-pushed the per-project-checkpatch branch from 39a63f1 to 661786a Compare December 8, 2025 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants