mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
build: add even more linting rules
Notably, shorten function signatures by not repeating types.
This commit is contained in:
@@ -43,7 +43,7 @@ var (
|
||||
|
||||
// TransformQueryOnCluster turns a ClickHouse query into its equivalent to be
|
||||
// run on a cluster by adding the ON CLUSTER directive.
|
||||
func TransformQueryOnCluster(query string, cluster string) string {
|
||||
func TransformQueryOnCluster(query, cluster string) string {
|
||||
// From utils/antlr/ClickHouseParser.g4:
|
||||
//
|
||||
// ALTER TABLE tableIdentifier clusterClause? alterTableClause (COMMA alterTableClause)*
|
||||
|
||||
2
common/helpers/cache/cache_test.go
vendored
2
common/helpers/cache/cache_test.go
vendored
@@ -12,7 +12,7 @@ import (
|
||||
"akvorado/common/helpers/cache"
|
||||
)
|
||||
|
||||
func expectCacheGet(t *testing.T, c *cache.Cache[netip.Addr, string], key string, expectedResult string, expectedOk bool) {
|
||||
func expectCacheGet(t *testing.T, c *cache.Cache[netip.Addr, string], key, expectedResult string, expectedOk bool) {
|
||||
t.Helper()
|
||||
ip := netip.MustParseAddr(key)
|
||||
ip = helpers.AddrTo6(ip)
|
||||
|
||||
@@ -152,9 +152,6 @@ func (c *Component) widgetTopHandlerFunc(gc *gin.Context) {
|
||||
}
|
||||
|
||||
switch uriParams.WidgetName {
|
||||
default:
|
||||
gc.JSON(http.StatusNotFound, gin.H{"message": "Unknown top request."})
|
||||
return
|
||||
case HomepageTopWidgetSrcAS:
|
||||
selector = fmt.Sprintf(`concat(toString(SrcAS), ': ', dictGetOrDefault('%s', 'name', SrcAS, '???'))`, schema.DictionaryASNs)
|
||||
groupby = `SrcAS`
|
||||
@@ -181,6 +178,9 @@ func (c *Component) widgetTopHandlerFunc(gc *gin.Context) {
|
||||
selector = fmt.Sprintf(`concat(dictGetOrDefault('%s', 'name', Proto, '???'), '/', toString(DstPort))`, schema.DictionaryProtocols)
|
||||
groupby = `Proto, DstPort`
|
||||
mainTableRequired = true
|
||||
default:
|
||||
gc.JSON(http.StatusNotFound, gin.H{"message": "Unknown top request."})
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(gc.Param("name"), "src-") {
|
||||
filter = "AND InIfBoundary = 'external'"
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"akvorado/common/embed"
|
||||
)
|
||||
|
||||
func (c *Component) addHandlerEmbedded(url string, path string) {
|
||||
func (c *Component) addHandlerEmbedded(url, path string) {
|
||||
data, _ := fs.Sub(embed.Data(), "orchestrator/clickhouse")
|
||||
c.d.HTTP.AddHandler(url,
|
||||
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -97,7 +97,7 @@ func (c *Component) tableAlreadyExists(ctx context.Context, table, column, targe
|
||||
|
||||
// mergeTreeEngine returns a MergeTree engine definition, either plain or using
|
||||
// Replicated if we are on a cluster.
|
||||
func (c *Component) mergeTreeEngine(table string, variant string, args ...string) string {
|
||||
func (c *Component) mergeTreeEngine(table, variant string, args ...string) string {
|
||||
if c.d.ClickHouse.ClusterName() != "" {
|
||||
return fmt.Sprintf(`Replicated%sMergeTree(%s)`, variant, strings.Join(
|
||||
append([]string{
|
||||
|
||||
@@ -25,7 +25,7 @@ type geoDatabase interface {
|
||||
|
||||
// openDatabase opens the provided database and closes the current
|
||||
// one. Do nothing if the path is empty.
|
||||
func (c *Component) openDatabase(which string, path string, notifySubscribers bool) error {
|
||||
func (c *Component) openDatabase(which, path string, notifySubscribers bool) error {
|
||||
if path == "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"akvorado/common/reporter"
|
||||
)
|
||||
|
||||
func copyFile(t *testing.T, src string, dst string) {
|
||||
func copyFile(t *testing.T, src, dst string) {
|
||||
t.Helper()
|
||||
source, err := os.Open(src)
|
||||
if err != nil {
|
||||
|
||||
@@ -199,7 +199,7 @@ func (c *Component) getNetMask(flowMask, bmpMask uint8) (mask uint8) {
|
||||
return mask
|
||||
}
|
||||
|
||||
func (c *Component) getNextHop(flowNextHop netip.Addr, bmpNextHop netip.Addr) (nextHop netip.Addr) {
|
||||
func (c *Component) getNextHop(flowNextHop, bmpNextHop netip.Addr) (nextHop netip.Addr) {
|
||||
nextHop = netip.IPv6Unspecified()
|
||||
for _, provider := range c.config.NetProviders {
|
||||
if !nextHop.IsUnspecified() {
|
||||
@@ -227,7 +227,7 @@ func (c *Component) writeExporter(flow *schema.FlowMessage, classification expor
|
||||
return true
|
||||
}
|
||||
|
||||
func (c *Component) classifyExporter(t time.Time, ip string, name string, flow *schema.FlowMessage, classification exporterClassification) bool {
|
||||
func (c *Component) classifyExporter(t time.Time, ip, name string, flow *schema.FlowMessage, classification exporterClassification) bool {
|
||||
// we already have the info provided by the metadata component
|
||||
if (classification != exporterClassification{}) {
|
||||
return c.writeExporter(flow, classification)
|
||||
@@ -281,8 +281,7 @@ func (c *Component) writeInterface(flow *schema.FlowMessage, classification inte
|
||||
|
||||
func (c *Component) classifyInterface(
|
||||
t time.Time,
|
||||
ip string,
|
||||
exporterName string,
|
||||
ip, exporterName string,
|
||||
fl *schema.FlowMessage,
|
||||
ifIndex uint32,
|
||||
ifName,
|
||||
|
||||
@@ -205,7 +205,7 @@ func (p *Provider) Refresh(ctx context.Context) {
|
||||
// Lookup does an lookup on one of the specified RIS Instances and returns the
|
||||
// well known bmp lookup result. NextHopIP is ignored, but maintained for
|
||||
// compatibility to the internal bmp
|
||||
func (p *Provider) Lookup(ctx context.Context, ip netip.Addr, _ netip.Addr, agent netip.Addr) (provider.LookupResult, error) {
|
||||
func (p *Provider) Lookup(ctx context.Context, ip, _, agent netip.Addr) (provider.LookupResult, error) {
|
||||
p.mu.RLock()
|
||||
defer p.mu.RUnlock()
|
||||
|
||||
@@ -326,7 +326,7 @@ func (p *Provider) lpmResponseToLookupResult(lpm *pb.LPMResponse) (bmp.LookupRes
|
||||
}
|
||||
|
||||
// lookupLPM does an lookupLPM GRPC call to a BioRis instance
|
||||
func (p *Provider) lookupLPM(ctx context.Context, ip netip.Addr, agent netip.Addr) (*pb.LPMResponse, error) {
|
||||
func (p *Provider) lookupLPM(ctx context.Context, ip, agent netip.Addr) (*pb.LPMResponse, error) {
|
||||
// Choose router id and ris
|
||||
chosenRouterID, chosenRis, err := p.chooseRouter(agent)
|
||||
if err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ var errNoRouteFound = errors.New("no route found")
|
||||
// we use the best route we have, while the exporter may not have this
|
||||
// best route available. The returned result should not be modified!
|
||||
// The last parameter, the agent, is ignored by this provider.
|
||||
func (p *Provider) Lookup(_ context.Context, ip netip.Addr, nh netip.Addr, _ netip.Addr) (LookupResult, error) {
|
||||
func (p *Provider) Lookup(_ context.Context, ip, nh, _ netip.Addr) (LookupResult, error) {
|
||||
if !p.config.CollectASNs && !p.config.CollectASPaths && !p.config.CollectCommunities {
|
||||
return LookupResult{}, nil
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ type stopper interface {
|
||||
}
|
||||
|
||||
// Lookup uses the selected provider to get an answer.
|
||||
func (c *Component) Lookup(ctx context.Context, ip netip.Addr, nh netip.Addr, agent netip.Addr) provider.LookupResult {
|
||||
func (c *Component) Lookup(ctx context.Context, ip, nh, agent netip.Addr) provider.LookupResult {
|
||||
c.metrics.routingLookups.Inc()
|
||||
result, err := c.provider.Lookup(ctx, ip, nh, agent)
|
||||
if err != nil {
|
||||
|
||||
@@ -11,6 +11,10 @@ confidence = 0.8
|
||||
[rule.defer]
|
||||
[rule.dot-imports]
|
||||
[rule.empty-block]
|
||||
[rule.enforce-repeated-arg-type-style]
|
||||
arguments = ["short"]
|
||||
[rule.enforce-switch-style]
|
||||
arguments = ["allowNoDefault"]
|
||||
[rule.error-naming]
|
||||
[rule.error-return]
|
||||
[rule.error-strings]
|
||||
|
||||
Reference in New Issue
Block a user