From 88db909824a46b1422b419a69a2a1cb252efe975 Mon Sep 17 00:00:00 2001 From: Iskander Sharipov Date: Tue, 31 Jul 2018 10:52:47 +0300 Subject: [PATCH] simplify assignments with = syntax x = x + 1 => x += 1 => x++ x = x / 10 => x /= 10 etc. Found usign gocritic check called assignOp --- benchutil/wide_schema.go | 2 +- language/visitor/visitor.go | 2 +- rules.go | 4 ++-- testutil/rules_test_harness.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/benchutil/wide_schema.go b/benchutil/wide_schema.go index 2c7c43a2..1177fce6 100644 --- a/benchutil/wide_schema.go +++ b/benchutil/wide_schema.go @@ -81,7 +81,7 @@ func generateFieldNameFromX(x int) string { for { r := v % 10 out = alphabet[r] + out - v = v / 10 + v /= 10 if v == 0 { break } diff --git a/language/visitor/visitor.go b/language/visitor/visitor.go index 70754364..efd720dd 100644 --- a/language/visitor/visitor.go +++ b/language/visitor/visitor.go @@ -203,7 +203,7 @@ func Visit(root ast.Node, visitorOpts *VisitorOptions, keyMap KeyMap) interface{ // abstract algorithm Loop: for { - index = index + 1 + index++ isLeaving := (len(keys) == index) var ( diff --git a/rules.go b/rules.go index 41b94494..ae0c75b9 100644 --- a/rules.go +++ b/rules.go @@ -297,7 +297,7 @@ func getSuggestedTypeNames(schema *Schema, ttype Output, fieldName string) []str if index < len(suggestedInterfaces) { s := suggestedInterfaces[index] if s.name == possibleInterface.Name() { - s.count = s.count + 1 + s.count++ } } } @@ -782,7 +782,7 @@ func LoneAnonymousOperationRule(context *ValidationContext) *ValidationRuleInsta operationCount = 0 for _, definition := range node.Definitions { if definition.GetKind() == kinds.OperationDefinition { - operationCount = operationCount + 1 + operationCount++ } } } diff --git a/testutil/rules_test_harness.go b/testutil/rules_test_harness.go index db956736..6de492f6 100644 --- a/testutil/rules_test_harness.go +++ b/testutil/rules_test_harness.go @@ -604,7 +604,7 @@ func ExpectPassesRuleWithSchema(t *testing.T, schema *graphql.Schema, rule graph } func RuleError(message string, locs ...int) gqlerrors.FormattedError { locations := []location.SourceLocation{} - for i := 0; i < len(locs); i = i + 2 { + for i := 0; i < len(locs); i += 2 { line := locs[i] col := 0 if i+1 < len(locs) {