delivery-club / delivery-club-rules Goto Github PK
View Code? Open in Web Editor NEWDelivery club go linter
License: MIT License
Delivery club go linter
License: MIT License
Is your feature request related to a problem? Please describe.
a common problem on code reviews with simplify error checking in one line if
Describe the solution you'd like
new rule for simplify error check that under 120 LOC
Is your feature request related to a problem? Please describe.
module vendoring doesn't download pkg directory, so rules can't properly compile
Describe the solution you'd like
we can create explict repository for interfaces like in pkg/
dir and import them in rules
Is your feature request related to a problem? Please describe.
to prevent goroutines leak check for cancelFunc defer call (from context.WithCancel)
Describe the solution you'd like
add new rule for cancelFunc call after creation
Code example(s) or test data
ctx, cancel := context.WithCancel(context.Background())
defer cancel() <- expect warning if line doesn't exist
Is your feature request related to a problem? Please describe.
after implementing #13 we can use linter as explict binary without on any other files, but we dont have test for this usage (flags, etc)
Is your feature request related to a problem? Please describe.
now we have tests for match , but not for suggest, need to add tests like here: https://github.com/quasilyte/go-perfguard/tree/master/internal/quickfix
also some suggest blocks can be invalid as described in #26
Describe the solution you'd like
add autofix/Suggest tests
Is your feature request related to a problem? Please describe.
check for useless local consts
Describe the solution you'd like
add new rule
Is your feature request related to a problem? Please describe.
add rule which will check sql structs with pointers to basic types (string, int, bool, etc) and will recommend change it to sql.Null* type. So we can decrease load on heap and increase runtime speed
POC:
type RowHeap struct {
Str *string `db:"str"`
}
type RowStack struct {
Str sql.NullString `db:"str"`
}
BenchmarkResults https://github.com/peakle/meetup/blob/master/go-optimizations/bench2_test.go:
RowHeap:
BenchmarkRowHeap-16 59960768 19.82 ns/op 16 B/op 1 allocs/op
BenchmarkRowHeap-16 61210947 21.10 ns/op 16 B/op 1 allocs/op
BenchmarkRowHeap-16 49640668 28.02 ns/op 16 B/op 1 allocs/op
RowStack:
BenchmarkRowStack-16 1000000000 0.7385 ns/op 0 B/op 0 allocs/op
BenchmarkRowStack-16 1000000000 0.7114 ns/op 0 B/op 0 allocs/op
BenchmarkRowStack-16 1000000000 0.7178 ns/op 0 B/op 0 allocs/op
Is your feature request related to a problem? Please describe.
with experimental tag we will be able to create some rules, which may be false-positive in some cases or useful for some specific situations and will be skipped by default run
Solution: need to check feature on runtime and binary modes
Is your feature request related to a problem? Please describe.
add rule for one line return after assign var
Describe the solution you'd like
such cases can be simplified for better code understanding
code example:
before:
func() string {
/.../
foo := "123123"
return foo
}
after:
func() string {
/.../
return "123123"
}
Is your feature request related to a problem? Please describe.
discard cases when switch type statement precedes type assert
Is your feature request related to a problem? Please describe.
Create explict binary with rules. We now rely on golangci-lint/gocritic dependencies, so sometimes we have to wait for new release to get updated dsl/ruleguard dependencies. That block our releases. Also add support matrix with golangci-lint/gocritic realeases complitable with our releases.
Is your feature request related to a problem? Please describe.
add test cases for expressions like param.Method().Method(arg).Method()
for deferInLopp, uncheckedTypeAssert
Is your feature request related to a problem? Please describe.
on start linter in binary mode for non 1.17 projects like https://github.com/peakle/eapteka-hackathon errors occurred:
deliveryClubRules: used Run() with an empty rule set; forgot to call Load() first?
deliveryClubRules: used Run() with an empty rule set; forgot to call Load() first?
deliveryClubRules: on load ir rules: rulesdata.go:282: can't load github.com/delivery-club/delivery-club-rules/pkg
Describe the solution you'd like
find and fix bugs
Code example(s) or test data
https://github.com/peakle/eapteka-hackathon
Is your feature request related to a problem? Please describe.
now we find only =
and :=
and not match var $_ =
and var $_ $_ =
assiments
Describe the solution you'd like
add another assigment patterns to rule
Code example(s) or test data
var r = regexp.MustCompile("\w")
var r *regexp.Regexp = regexp.MustCompile("\w")
Is your feature request related to a problem? Please describe.
unreleased time.Ticker can't be collected by GC
Is your feature request related to a problem? Please describe.
There is no documentation for the each rule, and it is not clear how to fix some warnings.
Describe the solution you'd like
It would be nice to write documentation with code examples for each rule: when triggered, how to fix it. Like this: https://github.com/Antonboom/errname#examples
Is your feature request related to a problem? Please describe.
add installation option by curl like in golangci-lint, see for details: https://github.com/goreleaser/godownloader
Is your feature request related to a problem? Please describe.
create support matrix for releases of ruleguard/go-critic/golangci-lint wth releases of our rules from v0.0.5, afaik rules loaded dynamicly so dependencies in this repository will not be equal to dependencies in binaries (golangci-lint/gocritic/ruleguard)
Describe the solution you'd like
add support matrix for dc-rules releases by one of two last releases of binaries (golangci-lint/gocritic/ruleguard)
if no one of two last releases of binaries not support yet dc-rules, write not supported yet
if both releases of binaries support rules version write earliest
Is your feature request related to a problem? Please describe.
now we check err only from func/method/closure calls, but sometimes we need to check error field after method execution
Is your feature request related to a problem? Please describe.
after implementing quickfix logic from go-critic/go-critic#1179, golangci-lint can use our suggest blocks to fix code, but there are some bugs in our suggest blocks, so we need to fix that
see simplifyErrorReturn rule (maybe smth else), it have $*_
in suggest block which can't be properly moved to code base, it need to add some name like $*args or smth else, need to test
Describe the solution you'd like
our linter fix code fine when execute golangci-lint with --fix
option
Code example(s) or test
in testdata
dir
Is your feature request related to a problem? Please describe.
Text.Matches method use regexp so it slower in execution than Contains method which based on go ast
Describe the solution you'd like
replace Text.Matches calls to Contains method
Is your feature request related to a problem? Please describe.
now we support expressions like:
db, err := sql.Open("", "")
but don't support situation when:
res, err := package.Open().Exec()
Solution:
add support consecutive calls for rule
Is your feature request related to a problem? Please describe.
extend type assert rule
Describe the solution you'd like
now not supported statements like:
var f interface{}
ch <- f.(string)
map[string]string{
f.(string): "123",
"123": f.(string),
}
which also can panic
Is your feature request related to a problem? Please describe.
now binary mode can work only with predefined rules
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.