Skip to content
This repository was archived by the owner on Jul 23, 2025. It is now read-only.
This repository was archived by the owner on Jul 23, 2025. It is now read-only.

Allow excluding files from search #94

@ihrwein

Description

@ihrwein

Problem

First of all, thank you for this really useful project.

Shisho finds matches in files which are auto-generated or I don't have control over them (vendored). It's not feasible to fix the reported issues in these files.

I.e. consider this policy file for Golang:

version: '1'
rules:
  - id: 'deny-fmt-println'
    language: go
    message: |
      Avoid calling fmt.Println, as it can make log output messy. Use logging instead.
    pattern: |
      fmt.Println(:[_])
  - id: 'deny-panic'
    language: go
    message: |
      Avoid calling panic() manually. Return the error instead.
    pattern: |
      panic(:[_])

Both rules will likely find matches in the vendor folder. Some libraries generate code with panic() calls in it: https://github.com/99designs/gqlgen/blob/1a0b19feff6f02d2af6631c9d847bc243f8ede39/example/chat/generated.go#L2028

Possible Solutions

  • generated code & vendor folder: I'd like to exclude it from the search, perhaps via CLI flag or extending the rule file with file excludes.
  • ignoring false positives: Sometimes we want to silence the linter in particular cases. We could use some comments and either match against those comments in constraints (manually) or make shisho aware of a convention: panic("foo") // shisho:ignore deny-panic

Additional Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions