Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyk committed Mar 4, 2021
1 parent 4d7f5b9 commit a96ba0c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
2 changes: 2 additions & 0 deletions src/cmd/services/m3coordinator/downsample/downsampler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ func TestDownsamplerAggregationWithRulesConfigRollupRulesAggregateTransformNoRol
func TestDownsamplerAggregationWithRulesConfigRollupRulesIncreaseAdd(t *testing.T) {
t.Parallel()

// nolint:dupl
gaugeMetrics := []testGaugeMetric{
{
tags: map[string]string{
Expand Down Expand Up @@ -1738,6 +1739,7 @@ func TestDownsamplerAggregationWithRulesConfigRollupRulesExcludeByLastMean(t *te
func TestDownsamplerAggregationWithRulesConfigRollupRulesExcludeByIncreaseSumAdd(t *testing.T) {
t.Parallel()

// nolint:dupl
gaugeMetrics := []testGaugeMetric{
{
tags: map[string]string{
Expand Down
8 changes: 5 additions & 3 deletions src/metrics/rules/active_ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,10 @@ func (as *activeRuleSet) matchRollupTarget(
nameTagValue []byte
)
// switch rollupOp.
matchTag:
for hasMoreTags := sortedTagIter.Next(); hasMoreTags; hasMoreTags = sortedTagIter.Next() {
tagName, tagVal := sortedTagIter.Current()
// nolint:gosimple
isNameTag := bytes.Compare(tagName, nameTagName) == 0
if isNameTag {
nameTagValue = tagVal
Expand All @@ -500,7 +502,7 @@ func (as *activeRuleSet) matchRollupTarget(
// If one of the target tags is not found in the ID, this is considered
// a non-match so bail immediately.
if res > 0 {
break
break matchTag
}
case mpipeline.ExcludeByRollupType:
if isNameTag {
Expand Down Expand Up @@ -530,11 +532,11 @@ func (as *activeRuleSet) matchRollupTarget(
// If one of the target tags is not found in the ID then does not
// need to be excluded.
if res > 0 {
break
break matchTag
}
}

}

sortedTagIter.Close()

// If not all the target tags are found, this is considered a no match.
Expand Down
30 changes: 15 additions & 15 deletions src/metrics/rules/ruleset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,35 +275,35 @@ func TestRuleSetLatest(t *testing.T) {
latest, err := rs.Latest()
require.NoError(t, err)

rr1, err := pipeline.NewRollupOp(
r1, err := pipeline.NewRollupOp(
pipeline.GroupByRollupType,
"rName1",
[]string{"rtagName1", "rtagName2"},
aggregation.DefaultID,
)
require.NoError(t, err)
rr3, err := pipeline.NewRollupOp(
r3, err := pipeline.NewRollupOp(
pipeline.GroupByRollupType,
"rName3",
[]string{"rtagName1", "rtagName2"},
aggregation.DefaultID,
)
require.NoError(t, err)
rr4, err := pipeline.NewRollupOp(
r4, err := pipeline.NewRollupOp(
pipeline.GroupByRollupType,
"rName4",
[]string{"rtagName1", "rtagName2"},
aggregation.DefaultID,
)
require.NoError(t, err)
rr5, err := pipeline.NewRollupOp(
r5, err := pipeline.NewRollupOp(
pipeline.GroupByRollupType,
"rName5",
[]string{"rtagName1"},
aggregation.DefaultID,
)
require.NoError(t, err)
rr6, err := pipeline.NewRollupOp(
r6, err := pipeline.NewRollupOp(
pipeline.GroupByRollupType,
"rName6",
[]string{"rtagName1", "rtagName2"},
Expand Down Expand Up @@ -374,7 +374,7 @@ func TestRuleSetLatest(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr1,
Rollup: r1,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand All @@ -393,7 +393,7 @@ func TestRuleSetLatest(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr3,
Rollup: r3,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand All @@ -413,7 +413,7 @@ func TestRuleSetLatest(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr4,
Rollup: r4,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand All @@ -432,7 +432,7 @@ func TestRuleSetLatest(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr5,
Rollup: r5,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand All @@ -451,7 +451,7 @@ func TestRuleSetLatest(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr6,
Rollup: r6,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand Down Expand Up @@ -754,7 +754,7 @@ func TestRuleSetAddRollupRuleNewRule(t *testing.T) {

_, err = rs.getRollupRuleByName("foo")
require.Equal(t, errRuleNotFound, err)
rr1, err := pipeline.NewRollupOp(
r1, err := pipeline.NewRollupOp(
pipeline.GroupByRollupType,
"blah",
[]string{"a"},
Expand All @@ -771,7 +771,7 @@ func TestRuleSetAddRollupRuleNewRule(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr1,
Rollup: r1,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand Down Expand Up @@ -803,7 +803,7 @@ func TestRuleSetAddRollupRuleNewRule(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr1,
Rollup: r1,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand Down Expand Up @@ -834,7 +834,7 @@ func TestRuleSetAddRollupRuleDuplicateRule(t *testing.T) {
r, err := rs.getRollupRuleByID("rollupRule5")
require.NoError(t, err)
require.NotNil(t, r)
rr1, err := pipeline.NewRollupOp(
r1, err := pipeline.NewRollupOp(
pipeline.GroupByRollupType,
"blah",
[]string{"a"},
Expand All @@ -849,7 +849,7 @@ func TestRuleSetAddRollupRuleDuplicateRule(t *testing.T) {
Pipeline: pipeline.NewPipeline([]pipeline.OpUnion{
{
Type: pipeline.RollupOpType,
Rollup: rr1,
Rollup: r1,
},
}),
StoragePolicies: policy.StoragePolicies{
Expand Down
6 changes: 3 additions & 3 deletions src/metrics/rules/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@ func (v *validator) validateRollupOp(
newName := rollupOp.NewName([]byte(""))
// Validate that the rollup metric name is valid.
if err := v.validateRollupMetricName(newName); err != nil {
return fmt.Errorf("invalid rollup metric name '%s': %v", newName, err)
return fmt.Errorf("invalid rollup metric name '%s': %w", newName, err)
}

// Validate that the rollup tags are valid.
if err := v.validateRollupTags(rollupOp.Tags, previousRollupTags); err != nil {
return fmt.Errorf("invalid rollup tags %v: %v", rollupOp.Tags, err)
return fmt.Errorf("invalid rollup tags %v: %w", rollupOp.Tags, err)
}

// Validate that the aggregation ID is valid.
Expand All @@ -388,7 +388,7 @@ func (v *validator) validateRollupOp(
aggType = nonFirstLevelAggregationType
}
if err := v.validateAggregationID(rollupOp.AggregationID, aggType, types); err != nil {
return fmt.Errorf("invalid aggregation ID %v: %v", rollupOp.AggregationID, err)
return fmt.Errorf("invalid aggregation ID %v: %w", rollupOp.AggregationID, err)
}

return nil
Expand Down

0 comments on commit a96ba0c

Please sign in to comment.