
Also do following improvements: - show proper sublinter name for megacheck sublinters - refactor and make more simple and robust megacheck merging/optimizing - improve handling of unknown linter names in //nolint directives - minimize diff of our megacheck version from the upstream, https://github.com/golang/go/issues/29612 blocks usage of the upstream version - support the new `stylecheck` linter - improve tests coverage for megacheck and nolint related cases - update and use upstream versions of unparam and interfacer instead of forked ones - don't use golangci/tools repo anymore - fix newly found issues after updating linters Also should be noted that megacheck works much faster and consumes less memory in the newest release, therefore golangci-lint works noticeably faster and consumes less memory for large repos. Relates: #314
74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
package vrp
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/golangci/go-tools/ssa"
|
|
)
|
|
|
|
type ChannelInterval struct {
|
|
Size IntInterval
|
|
}
|
|
|
|
func (c ChannelInterval) Union(other Range) Range {
|
|
i, ok := other.(ChannelInterval)
|
|
if !ok {
|
|
i = ChannelInterval{EmptyIntInterval}
|
|
}
|
|
if c.Size.Empty() || !c.Size.IsKnown() {
|
|
return i
|
|
}
|
|
if i.Size.Empty() || !i.Size.IsKnown() {
|
|
return c
|
|
}
|
|
return ChannelInterval{
|
|
Size: c.Size.Union(i.Size).(IntInterval),
|
|
}
|
|
}
|
|
|
|
func (c ChannelInterval) String() string {
|
|
return c.Size.String()
|
|
}
|
|
|
|
func (c ChannelInterval) IsKnown() bool {
|
|
return c.Size.IsKnown()
|
|
}
|
|
|
|
type MakeChannelConstraint struct {
|
|
aConstraint
|
|
Buffer ssa.Value
|
|
}
|
|
type ChannelChangeTypeConstraint struct {
|
|
aConstraint
|
|
X ssa.Value
|
|
}
|
|
|
|
func NewMakeChannelConstraint(buffer, y ssa.Value) Constraint {
|
|
return &MakeChannelConstraint{NewConstraint(y), buffer}
|
|
}
|
|
func NewChannelChangeTypeConstraint(x, y ssa.Value) Constraint {
|
|
return &ChannelChangeTypeConstraint{NewConstraint(y), x}
|
|
}
|
|
|
|
func (c *MakeChannelConstraint) Operands() []ssa.Value { return []ssa.Value{c.Buffer} }
|
|
func (c *ChannelChangeTypeConstraint) Operands() []ssa.Value { return []ssa.Value{c.X} }
|
|
|
|
func (c *MakeChannelConstraint) String() string {
|
|
return fmt.Sprintf("%s = make(chan, %s)", c.Y().Name(), c.Buffer.Name())
|
|
}
|
|
func (c *ChannelChangeTypeConstraint) String() string {
|
|
return fmt.Sprintf("%s = changetype(%s)", c.Y().Name(), c.X.Name())
|
|
}
|
|
|
|
func (c *MakeChannelConstraint) Eval(g *Graph) Range {
|
|
i, ok := g.Range(c.Buffer).(IntInterval)
|
|
if !ok {
|
|
return ChannelInterval{NewIntInterval(NewZ(0), PInfinity)}
|
|
}
|
|
if i.Lower.Sign() == -1 {
|
|
i.Lower = NewZ(0)
|
|
}
|
|
return ChannelInterval{i}
|
|
}
|
|
func (c *ChannelChangeTypeConstraint) Eval(g *Graph) Range { return g.Range(c.X) }
|