nunnatsa / ginkgolinter

golang linter for ginkgo and gomega
MIT License
24 stars 6 forks source link

New Rule: Avoid spec Pollution #141

Closed nunnatsa closed 3 months ago

nunnatsa commented 3 months ago

Description

Does not allow variable assignments in container nodes. See here for more details: https://onsi.github.io/ginkgo/#avoid-spec-pollution-dont-initialize-variables-in-container-nodes

This rule is disabled by default. use the --forbid-spec-pollution=true flag to enable it.

For example, this code will trigger a warning:

var _ = Describe("description", func(){
    var x = 10
    ...
})

Instead, use BeforeEach(); e.g.

var _ = Describe("description", func (){
    var x int

    BeforeEach(func (){
        x = 10
    })
    ...
})

Closes: #136

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Checklist:

coveralls commented 3 months ago

Pull Request Test Coverage Report for Build 8324983153

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/ginkgohandler/handler.go 0 20 0.0%
<!-- Total: 2 22 9.09% -->
Files with Coverage Reduction New Missed Lines %
internal/ginkgohandler/handler.go 1 47.46%
<!-- Total: 1 -->
Totals Coverage Status
Change from base Build 8321952766: -3.2%
Covered Lines: 204
Relevant Lines: 319

💛 - Coveralls