Skip to content

Path for gocritic ruleguard rules depends on the current working directory #1662

Closed
@oschwald

Description

@oschwald

I am using ruleguard via the gocritic linter. As part of using this linter, you must set the path to your rules:

ruleguard:
# path to a gorules file for the ruleguard checker
rules: ''

Unfortunately, if you currently set a relative path, it will be relative to the directory that you run golangci-lint from. This means that you must always run golangci-lint from the same directory or use an absolute path, which may not work across different environments.

#1572 dealt with a similar issue for custom plugins. It fixed the issue by adding an explicit check to see if the path was relative or absolute.

I looked into doing this for the ruleguard settings, but it appears that the settings code is very generic and doesn't know anything in particular. Would a PR that added a special case to that code for ruleguard be accepted? I would understand if it would be considered in bad taste.

A more general alternative might be if golangci-criitc changed the working directory to the configuration dir directory before running the linters. However, I suspect this would cause other problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions