Giter Site home page Giter Site logo

Comments (9)

ldez avatar ldez commented on June 2, 2024 2

@HartBlanc with PR #4653, if you run only a "fast" linter like gci only the syntax errors will be checked.
Bonus: the performance will be better.

from golangci-lint.

HartBlanc avatar HartBlanc commented on June 2, 2024 1

This sounds like a significant improvement! Thanks @ldez!

from golangci-lint.

boring-cyborg avatar boring-cyborg commented on June 2, 2024

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

from golangci-lint.

ldez avatar ldez commented on June 2, 2024

Hello,

in v1.57.0, we introduced the flag --enable-only.
This option overrides enable/disable/preset/fast section from the file configuration but uses the linters-settings from the file configuration.

Then you can use golangci-lint run --enable-only=gci --fix.

The --fast flag is ignored when using --enable-only.

When typecheck errors occur, most linters (107 linters on 117) cannot perform the analysis because they need type information.
I will force this behavior on all linters.

Another element, golangci-lint is made to handle packages, I recommend avoiding the usage on file because side effects can appear (e.g. typecheck)

from golangci-lint.

HartBlanc avatar HartBlanc commented on June 2, 2024

Hello,

If there is no interest in file-level formatting or modifying/disabling the typechecking process then I think the applicability of golangci-lint for this use case will always be a little lacking.

In my particular case, using gci directly is probably the best solution.

Thanks for considering the issue! (and the advice on the flags)

from golangci-lint.

ldez avatar ldez commented on June 2, 2024

Just a precision, typecheck is not a linter or specific golangci-lint process: https://golangci-lint.run/welcome/faq/#why-do-you-have-typecheck-errors

So it's not really because "no interest modifying/disabling the typechecking process" but because typecheck is used to display those blocking errors in the "issue style".
The loading of the code is performed in a way that we can't skip.

I highly recommend using golangci-lint on a package instead of a file.

from golangci-lint.

ldez avatar ldez commented on June 2, 2024

Do you have a minimal reproducible example?

Because gci, as a standalone app, has the same "problem" as golangci-lint with typecheck errors:

$ gci print main.go                          
Error: main.go:15:9: expected 'IDENT', found '{' (and 1 more errors)

from golangci-lint.

HartBlanc avatar HartBlanc commented on June 2, 2024

For example, with the following file:

# gciexample.go
package gciexample

var a = b

Running gci directly:

$ gci print gciexample.go

package gciexample

var a = b

Running gci via golangci-lint:

$ golangci-lint run --fix --enable-only=gci a.go
a.go:3:9: undefined: b (typecheck)
var a = b
        ^

from golangci-lint.

ldez avatar ldez commented on June 2, 2024

thank you

if you use this sample:

package gciexample

func () {

}

The behavior will be different: an error will be reported by gci.

gci detects syntax errors only, and golangci-lint detects syntax errors and type checking error.

Related to #2914

Side note: I know that the name typecheck is not really accurate, I plan to change that at some point.

from golangci-lint.

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.