Giter VIP home page Giter VIP logo

Comments (12)

cep21 avatar cep21 commented on July 16, 2024

Is there a particular reason gometalinter was written to operate on *.go rather than assuming operation on directories at a time?

from gometalinter.

alecthomas avatar alecthomas commented on July 16, 2024

Yes. If you have a directory foo then structcheck foo will error out with: cannot find package "foo" (as it assumes an absolute package path). If you do structcheck ./foo it works, or if you do ./foo/*.go it works (though apparently not ideally). However, gometalinter normalises directory names for de-duplication, so even if you use gometalinter ./foo it will be normalised to foo. To work around this, gometalinter would need to either not normalise paths, or normalise, then ensure the path looks like a path again. The latter may be possible.

from gometalinter.

cep21 avatar cep21 commented on July 16, 2024

This is reproducible even running gometalinter on gometalinter

regression_tests/deadcode_test.go:13:14:warning: unused struct field undeclared name: Issues (structcheck)
regression_tests/deadcode_test.go:16:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/defercheck_test.go:17:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/dupl_test.go:32:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/errcheck_test.go:14:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/gocyclo_test.go:65:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/golint_test.go:14:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/gotype_test.go:15:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/ineffassign_test.go:14:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/structcheck_test.go:15:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/varcheck_test.go:13:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/vet_shadow_test.go:19:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)
regression_tests/vet_test.go:10:2:warning: unused struct field undeclared name: ExpectIssues (structcheck)

One option is to cd ./foo && structcheck .

from gometalinter.

alecthomas avatar alecthomas commented on July 16, 2024

That worked!

from gometalinter.

alecthomas avatar alecthomas commented on July 16, 2024

Hmm, except it broke the tests.

from gometalinter.

cep21 avatar cep21 commented on July 16, 2024
    Error:      Not equal: regression_tests.Issues{regression_tests.Issue{Linter:"structcheck", Severity:"warning", Path:"test.go", Line:4, Col:2, Message:"unused struct field test.test.unused"}} (expected)
                    != regression_tests.Issues{regression_tests.Issue{Linter:"structcheck", Severity:"warning", Path:"test.go", Line:4, Col:2, Message:"unused struct field github.com/alecthomas/gometalinter/regression_tests/.test.unused"}} (actual)

:( I prefer the older version.

In general though, isn't cd $1 && {$CMD} . a probably better model than *.go? I imagine most tools will work better with it.

from gometalinter.

cep21 avatar cep21 commented on July 16, 2024

At least the tools that don't recurse into subdirectories.

from gometalinter.

cep21 avatar cep21 commented on July 16, 2024

That would modify vet and varcheck.

from gometalinter.

alecthomas avatar alecthomas commented on July 16, 2024

Well, there's no "better" here, they all work completely differently. Even tools from the same author work differently. So I basically just try different approaches and use whatever works.

from gometalinter.

cep21 avatar cep21 commented on July 16, 2024

What are your thoughts on changing vet and varcheck to match the "cd &&" model? I think it's closer to what most people do so is probably more future proof.

from gometalinter.

cep21 avatar cep21 commented on July 16, 2024

The dupl change may be too aggressive. It's the output we eventually want (with dupl running on ./...) but metalinter runs it on subdirectories so you end up dupl-ing into subdirectories multiple times.

from gometalinter.

alecthomas avatar alecthomas commented on July 16, 2024

Ah yes, got a little carried away there.

from gometalinter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.