Skip to content

how does one go about excluding test files from analysis using gcl? #386

@HenrikPoulsen

Description

@HenrikPoulsen

I have tests where I mock some unused things away, and nilaway is picking up on this and reporting it as a possible nil panic.
I would very much like to silence this, since it is perfectly valid to do these things for tests imo.
I see that the nilaway cli has a -test that at least sounds like it would do this, but the gcl configuration does not seem to expose this.
Since setting test: "false" in .golangci.yml for the plugin yields:

The command is terminated due to an error: build linters: plugin(nilaway): BuildAnalyzers set config flag test with false: no such flag -test

An example I have is this output from nilaway:

internal\handler\store\store.go:100:8: error: Potential nil panic detected. Observed nil flow from source to dereference point:
        - \internal\handler\changelist\changelist_test.go:69:30: literal `nil` passed as arg `store` to `NewRouter()`
        ...

The test does the following at this line:

router := handler.NewRouter(nil, nil, handl)

which is perfectly valid for this test, since it is not testing the part of the logic that would end up calling that nil argument.
So I would very much prefer if it just doesn't include tests in the analysis.

Is that possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions