Repository: bombsimon/wsl
Pull request #67 (2020-02-03 22:00:09)

Extract error and warning strings to constants
As discussed in #66 :)

coveralls: ## Pull Request Test Coverage Report for [Build 167](https://coveralls.io/builds/28507697)

* **24** of **35**   **(68.57%)**  changed or added relevant lines in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **89.319%**

---

|  Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
| :-----|--------------|--------|---: |
| [wsl.go](https://coveralls.io/builds/28507697/source?filename=wsl.go#L235) | 24 | 35 | 68.57%
<!-- | **Total:** | **24** | **35** | **68.57%** | -->


|  Totals | [![Coverage Status](https://coveralls.io/builds/28507697/badge)](https://coveralls.io/builds/28507697) |
| :-- | --: |
| Change from base [Build 164](https://coveralls.io/builds/28497443): |  0.0% |
| Covered Lines: | 577 |
| Relevant Lines: | 646 |

---
##### 💛  - [Coveralls](https://coveralls.io)

bombsimon: Wow, this is awesome! ❤️ 

It looks much better but I didn't even realise how great this would be to maintain regarding tests!

Thank you so much!

Patch:
diff --git a/wsl.go b/wsl.go
index d270b7d..154df64 100644
--- a/wsl.go
+++ b/wsl.go
@@ -10,6 +10,49 @@ import (
 	"strings"
 )
 
+// Error reason strings
+const (
+	reasonMustCuddleErrCheck             = "if statements that check an error must be cuddled with the statement that assigned the error"
+	reasonOnlyCuddleIfWithAssign         = "if statements should only be cuddled with assignments"
+	reasonOnlyOneCuddle                  = "only one cuddle assignment allowed before if statement"
+	reasonOnlyCuddleWithUsedAssign       = "if statements should only be cuddled with assignments used in the if statement itself"
+	reasonOnlyCuddle2LineReturn          = "return statements should not be cuddled if block has more than two lines"
+	reasonMultiLineBranchCuddle          = "branch statements should not be cuddled if block has more than two lines"
+	reasonAppendCuddledWithoutUse        = "append only allowed to cuddle with appended value"
+	reasonAssignsCuddleAssign            = "assignments should only be cuddled with other assignments"
+	reasonNeverCuddleDeclare             = "declarations should never be cuddled"
+	reasonExpressionCuddledWithDeclOrRet = "expressions should not be cuddled with declarations or returns"
+	reasonExpressionCuddledWithBlock     = "expressions should not be cuddled with blocks"
+	reasonExprCuddlingNonAssignedVar     = "only cuddled expressions if assigning variable or using from line above"
+	reasonOneCuddleBeforeRange           = "only one cuddle assignment allowed before range statement"
+	reasonRangeCuddledWithoutUse         = "ranges should only be cuddled with assignments used in the iteration"
+	reasonOneCuddleBeforeDefer           = "only one cuddle assignment allowed before defer statement"
+	reasonDeferCuddledWithOtherVar       = "defer statements should only be cuddled with expressions on same variable"
+	reasonForWithoutCondition            = "for statement without condition should never be cuddled"
+	reasonForWithMoreThanOneCuddle       = "only one cuddle assignment allowed before for statement"
+	reasonForCuddledAssignWithoutUse     = "for statements should only be cuddled with assignments used in the iteration"
+	reasonOneCuddleBeforeGo              = "only one cuddle assignment allowed before go statement"
+	reasonGoFuncWithoutAssign            = "go statements can only invoke functions assigned on line above"
+	reasonSwitchManyCuddles              = "only one cuddle assignment allowed before switch statement"
+	reasonAnonSwitchCuddled              = "anonymous switch statements should never be cuddled"
+	reasonSwitchCuddledWithoutUse        = "switch statements should only be cuddled with variables switched"
+	reasonTypeSwitchTooCuddled           = "only one cuddle assignment allowed before type switch statement"
+	reasonTypeSwitchCuddledWithoutUse    = "type switch statements should only be cuddled with variables switched"
+	reasonBlockStartsWithWS              = "block should not start with a whitespace"
+	reasonBlockEndsWithWS                = "block should not end with a whitespace (or comment)"
+	reasonCaseBlockTooCuddly             = "case block should end with newline at this size"
+)
+
+// Warning strings
+const (
+	warnTypeNotImplement           = "type not implemented"
+	warnStmtNotImplemented         = "stmt type not implemented"
+	warnBodyStmtTypeNotImplemented = "body statement type not implemented "
+	warnWSNodeTypeNotImplemented   = "whitespace node type not implemented "
+	warnUnknownLHS                 = "UNKNOWN LHS"
+	warnUnknownRHS                 = "UNKNOWN RHS"
+)
+
 type Configuration struct {
 	// StrictAppend will do strict checking when assigning from append (x =
 	// append(x, y)). If this is set to true the append call must append either
@@ -189,7 +232,7 @@ func (p *Processor) process(filename string, data []byte) {
 			// `go fmt` will handle proper spacing for GenDecl such as imports,
 			// constants etc.
 		default:
-			p.addWarning("type not implemented", d.Pos(), v)
+			p.addWarning(warnTypeNotImplement, d.Pos(), v)
 		}
 	}
 }
@@ -335,7 +378,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 				checkingErr := atLeastOneInListsMatch(rightAndLeftHandSide, p.config.ErrorVariableNames)
 				if checkingErr {
 					if atLeastOneInListsMatch(assignedOnLineAbove, p.config.ErrorVariableNames) {
-						p.addError(t.Pos(), "if statements that check an error must be cuddled with the statement that assigned the error")
+						p.addError(t.Pos(), reasonMustCuddleErrCheck)
 					}
 				}
 
@@ -343,12 +386,12 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			}
 
 			if len(assignedOnLineAbove) == 0 {
-				p.addError(t.Pos(), "if statements should only be cuddled with assignments")
+				p.addError(t.Pos(), reasonOnlyCuddleIfWithAssign)
 				continue
 			}
 
 			if moreThanOneStatementAbove() {
-				p.addError(t.Pos(), "only one cuddle assignment allowed before if statement")
+				p.addError(t.Pos(), reasonOnlyOneCuddle)
 				continue
 			}
 
@@ -360,26 +403,26 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 				continue
 			}
 
-			p.addError(t.Pos(), "if statements should only be cuddled with assignments used in the if statement itself")
+			p.addError(t.Pos(), reasonOnlyCuddleWithUsedAssign)
 		case *ast.ReturnStmt:
 			if isLastStatementInBlockOfOnlyTwoLines() {
 				continue
 			}
 
-			p.addError(t.Pos(), "return statements should not be cuddled if block has more than two lines")
+			p.addError(t.Pos(), reasonOnlyCuddle2LineReturn)
 		case *ast.BranchStmt:
 			if isLastStatementInBlockOfOnlyTwoLines() {
 				continue
 			}
 
-			p.addError(t.Pos(), "branch statements should not be cuddled if block has more than two lines")
+			p.addError(t.Pos(), reasonMultiLineBranchCuddle)
 		case *ast.AssignStmt:
 			// append is usually an assignment but should not be allowed to be
 			// cuddled with anything not appended.
 			if len(rightHandSide) > 0 && rightHandSide[len(rightHandSide)-1] == "append" {
 				if p.config.StrictAppend {
 					if !atLeastOneInListsMatch(calledOrAssignedOnLineAbove, rightHandSide) {
-						p.addError(t.Pos(), "append only allowed to cuddle with appended value")
+						p.addError(t.Pos(), reasonAppendCuddledWithoutUse)
 					}
 				}
 
@@ -402,17 +445,17 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 				}
 			}
 
-			p.addError(t.Pos(), "assignments should only be cuddled with other assignments")
+			p.addError(t.Pos(), reasonAssignsCuddleAssign)
 		case *ast.DeclStmt:
 			if !p.config.AllowCuddleDeclaration {
-				p.addError(t.Pos(), "declarations should never be cuddled")
+				p.addError(t.Pos(), reasonNeverCuddleDeclare)
 			}
 		case *ast.ExprStmt:
 			switch previousStatement.(type) {
 			case *ast.DeclStmt, *ast.ReturnStmt:
-				p.addError(t.Pos(), "expressions should not be cuddled with declarations or returns")
+				p.addError(t.Pos(), reasonExpressionCuddledWithDeclOrRet)
 			case *ast.IfStmt, *ast.RangeStmt, *ast.SwitchStmt:
-				p.addError(t.Pos(), "expressions should not be cuddled with blocks")
+				p.addError(t.Pos(), reasonExpressionCuddledWithBlock)
 			}
 
 			// If the expression is called on a type or variable used or
@@ -430,17 +473,17 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			// If we assigned variables on the line above but didn't use them in
 			// this expression there should probably be a newline between them.
 			if len(assignedOnLineAbove) > 0 && !atLeastOneInListsMatch(rightAndLeftHandSide, assignedOnLineAbove) {
-				p.addError(t.Pos(), "only cuddled expressions if assigning variable or using from line above")
+				p.addError(t.Pos(), reasonExprCuddlingNonAssignedVar)
 			}
 		case *ast.RangeStmt:
 			if moreThanOneStatementAbove() {
-				p.addError(t.Pos(), "only one cuddle assignment allowed before range statement")
+				p.addError(t.Pos(), reasonOneCuddleBeforeRange)
 				continue
 			}
 
 			if !atLeastOneInListsMatch(rightAndLeftHandSide, assignedOnLineAbove) {
 				if !atLeastOneInListsMatch(assignedOnLineAbove, assignedFirstInBlock) {
-					p.addError(t.Pos(), "ranges should only be cuddled with assignments used in the iteration")
+					p.addError(t.Pos(), reasonRangeCuddledWithoutUse)
 				}
 			}
 		case *ast.DeferStmt:
@@ -469,7 +512,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			}
 
 			if moreThanOneStatementAbove() {
-				p.addError(t.Pos(), "only one cuddle assignment allowed before defer statement")
+				p.addError(t.Pos(), reasonOneCuddleBeforeDefer)
 
 				continue
 			}
@@ -483,17 +526,17 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			}
 
 			if !atLeastOneInListsMatch(rightAndLeftHandSide, assignedOnLineAbove) {
-				p.addError(t.Pos(), "defer statements should only be cuddled with expressions on same variable")
+				p.addError(t.Pos(), reasonDeferCuddledWithOtherVar)
 			}
 		case *ast.ForStmt:
 			if len(rightAndLeftHandSide) == 0 {
-				p.addError(t.Pos(), "for statement without condition should never be cuddled")
+				p.addError(t.Pos(), reasonForWithoutCondition)
 
 				continue
 			}
 
 			if moreThanOneStatementAbove() {
-				p.addError(t.Pos(), "only one cuddle assignment allowed before for statement")
+				p.addError(t.Pos(), reasonForWithMoreThanOneCuddle)
 
 				continue
 			}
@@ -503,7 +546,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			// first line in the block for details.
 			if !atLeastOneInListsMatch(rightAndLeftHandSide, assignedOnLineAbove) {
 				if !atLeastOneInListsMatch(assignedOnLineAbove, assignedFirstInBlock) {
-					p.addError(t.Pos(), "for statements should only be cuddled with assignments used in the iteration")
+					p.addError(t.Pos(), reasonForCuddledAssignWithoutUse)
 				}
 			}
 		case *ast.GoStmt:
@@ -512,31 +555,31 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			}
 
 			if moreThanOneStatementAbove() {
-				p.addError(t.Pos(), "only one cuddle assignment allowed before go statement")
+				p.addError(t.Pos(), reasonOneCuddleBeforeGo)
 
 				continue
 			}
 
 			if !atLeastOneInListsMatch(rightAndLeftHandSide, assignedOnLineAbove) {
-				p.addError(t.Pos(), "go statements can only invoke functions assigned on line above")
+				p.addError(t.Pos(), reasonGoFuncWithoutAssign)
 			}
 		case *ast.SwitchStmt:
 			if moreThanOneStatementAbove() {
-				p.addError(t.Pos(), "only one cuddle assignment allowed before switch statement")
+				p.addError(t.Pos(), reasonSwitchManyCuddles)
 
 				continue
 			}
 
 			if !atLeastOneInListsMatch(rightAndLeftHandSide, assignedOnLineAbove) {
 				if len(rightAndLeftHandSide) == 0 {
-					p.addError(t.Pos(), "anonymous switch statements should never be cuddled")
+					p.addError(t.Pos(), reasonAnonSwitchCuddled)
 				} else {
-					p.addError(t.Pos(), "switch statements should only be cuddled with variables switched")
+					p.addError(t.Pos(), reasonSwitchCuddledWithoutUse)
 				}
 			}
 		case *ast.TypeSwitchStmt:
 			if moreThanOneStatementAbove() {
-				p.addError(t.Pos(), "only one cuddle assignment allowed before type switch statement")
+				p.addError(t.Pos(), reasonTypeSwitchTooCuddled)
 
 				continue
 			}
@@ -546,7 +589,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 				// Allow type assertion on variables used in the first case
 				// immediately.
 				if !atLeastOneInListsMatch(assignedOnLineAbove, assignedFirstInBlock) {
-					p.addError(t.Pos(), "type switch statements should only be cuddled with variables switched")
+					p.addError(t.Pos(), reasonTypeSwitchCuddledWithoutUse)
 				}
 			}
 		case *ast.CaseClause, *ast.CommClause:
@@ -554,7 +597,7 @@ func (p *Processor) parseBlockStatements(statements []ast.Stmt) {
 			// whitespaces within the block. There's nothing in the case itself
 			// that may be cuddled.
 		default:
-			p.addWarning("stmt type not implemented", t.Pos(), t)
+			p.addWarning(warnStmtNotImplemented, t.Pos(), t)
 		}
 	}
 }
@@ -612,7 +655,7 @@ func (p *Processor) firstBodyStatement(i int, allStmt []ast.Stmt) ast.Node {
 		p.parseBlockStatements(statementBodyContent)
 	default:
 		p.addWarning(
-			"body statement type not implemented ",
+			warnBodyStmtTypeNotImplemented,
 			stmt.Pos(), statementBodyContent,
 		)
 	}
@@ -673,7 +716,7 @@ func (p *Processor) findLHS(node ast.Node) []string {
 			return p.findLHS(x)
 		}
 
-		p.addWarning("UNKNOWN LHS", t.Pos(), t)
+		p.addWarning(warnUnknownLHS, t.Pos(), t)
 	}
 
 	return lhs
@@ -755,7 +798,7 @@ func (p *Processor) findRHS(node ast.Node) []string {
 			return p.findRHS(x)
 		}
 
-		p.addWarning("UNKNOWN RHS", t.Pos(), t)
+		p.addWarning(warnUnknownRHS, t.Pos(), t)
 	}
 
 	return rhs
@@ -865,7 +908,7 @@ func (p *Processor) findLeadingAndTrailingWhitespaces(ident *ast.Ident, stmt, ne
 		blockStatements = t.Body
 		blockStartPos = t.Colon
 	default:
-		p.addWarning("whitespace node type not implemented ", stmt.Pos(), stmt)
+		p.addWarning(warnWSNodeTypeNotImplemented, stmt.Pos(), stmt)
 
 		return
 	}
@@ -915,7 +958,7 @@ func (p *Processor) findLeadingAndTrailingWhitespaces(ident *ast.Ident, stmt, ne
 	if p.nodeStart(firstStatement) != blockStartLine+allowedLinesBeforeFirstStatement {
 		p.addError(
 			blockStartPos,
-			"block should not start with a whitespace",
+			reasonBlockStartsWithWS,
 		)
 	}
 
@@ -939,7 +982,7 @@ func (p *Processor) findLeadingAndTrailingWhitespaces(ident *ast.Ident, stmt, ne
 		}
 
 		if p.nodeEnd(lastStatement) != blockEndLine-1 && !isExampleFunc(ident) {
-			p.addError(blockEndPos, "block should not end with a whitespace (or comment)")
+			p.addError(blockEndPos, reasonBlockEndsWithWS)
 		}
 
 		return
@@ -1003,7 +1046,7 @@ func (p *Processor) findLeadingAndTrailingWhitespaces(ident *ast.Ident, stmt, ne
 	if p.config.CaseForceTrailingWhitespaceLimit > 0 && !hasTrailingWhitespace {
 		// Check if the block size is too big to miss the newline.
 		if blockSize >= p.config.CaseForceTrailingWhitespaceLimit {
-			p.addError(lastStatement.Pos(), "case block should end with newline at this size")
+			p.addError(lastStatement.Pos(), reasonCaseBlockTooCuddly)
 		}
 	}
 }


Test patch:
diff --git a/wsl_test.go b/wsl_test.go
index bcac1ec..e4aaddf 100644
--- a/wsl_test.go
+++ b/wsl_test.go
@@ -97,7 +97,7 @@ func TestShouldRemoveEmptyLines(t *testing.T) {
 
 				}
 			}`),
-			expectedErrorStrings: []string{"block should not start with a whitespace", "block should not end with a whitespace (or comment)"},
+			expectedErrorStrings: []string{"block should not start with a whitespace", reasonBlockEndsWithWS},
 		},
 		{
 			description: "whitespaces parsed correct even with comments (whitespace found)",
@@ -111,7 +111,7 @@ func TestShouldRemoveEmptyLines(t *testing.T) {
 					// trailing comment, still too much whitespace
 				}
 			}`),
-			expectedErrorStrings: []string{"block should not start with a whitespace", "block should not end with a whitespace (or comment)"},
+			expectedErrorStrings: []string{"block should not start with a whitespace", reasonBlockEndsWithWS},
 		},
 		{
 			description: "whitespaces parsed correct even with comments (whitespace NOT found)",
@@ -155,7 +155,7 @@ func TestShouldRemoveEmptyLines(t *testing.T) {
 				}
 			}`),
 			expectedErrorStrings: []string{
-				"block should not end with a whitespace (or comment)",
+				reasonBlockEndsWithWS,
 				"block should not start with a whitespace",
 			},
 		},
@@ -184,7 +184,7 @@ func TestShouldRemoveEmptyLines(t *testing.T) {
 				}
 				var a = false
 			}`),
-			expectedErrorStrings: []string{"declarations should never be cuddled"},
+			expectedErrorStrings: []string{reasonNeverCuddleDeclare},
 		},
 		{
 			description: "nested if statements should not be seen as cuddled",
@@ -268,7 +268,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 					fmt.Println("I'm OK")
 				}
 			}`),
-			expectedErrorStrings: []string{"if statements should only be cuddled with assignments used in the if statement itself"},
+			expectedErrorStrings: []string{reasonOnlyCuddleWithUsedAssign},
 		},
 		{
 			description: "cannot cuddled with other things than assignments",
@@ -282,7 +282,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 					fmt.Println("I'm OK")
 				}
 			}`),
-			expectedErrorStrings: []string{"if statements should only be cuddled with assignments"},
+			expectedErrorStrings: []string{reasonOnlyCuddleIfWithAssign},
 		},
 		{
 			description: "if statement with multiple assignments above and multiple conditions",
@@ -301,7 +301,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 					return true
 				}
 			}`),
-			expectedErrorStrings: []string{"only one cuddle assignment allowed before if statement", "if statements should only be cuddled with assignments used in the if statement itself"},
+			expectedErrorStrings: []string{"only one cuddle assignment allowed before if statement", reasonOnlyCuddleWithUsedAssign},
 		},
 		{
 			description: "if statement with multiple assignments, at least one used",
@@ -329,7 +329,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}
 				return
 			}`),
-			expectedErrorStrings: []string{"return statements should not be cuddled if block has more than two lines"},
+			expectedErrorStrings: []string{reasonOnlyCuddle2LineReturn},
 		},
 		{
 			description: "assignments should only be cuddled with assignments (negative)",
@@ -341,7 +341,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}
 				foo := true
 			}`),
-			expectedErrorStrings: []string{"assignments should only be cuddled with other assignments"},
+			expectedErrorStrings: []string{reasonAssignsCuddleAssign},
 		},
 		{
 			description: "assignments should only be cuddled with assignments",
@@ -365,7 +365,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 
 				return
 			}`),
-			expectedErrorStrings: []string{"expressions should not be cuddled with declarations or returns"},
+			expectedErrorStrings: []string{reasonExpressionCuddledWithDeclOrRet},
 		},
 		{
 			description: "expressions can be cuddlede with assignments",
@@ -390,7 +390,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 					fmt.Println(i)
 				}
 			}`),
-			expectedErrorStrings: []string{"ranges should only be cuddled with assignments used in the iteration"},
+			expectedErrorStrings: []string{reasonRangeCuddledWithoutUse},
 		},
 		{
 			description: "ranges can be cuddled if iteration is of assignment above",
@@ -445,7 +445,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 					x = append(x, i)
 				}
 			}`),
-			expectedErrorStrings: []string{"ranges should only be cuddled with assignments used in the iteration"},
+			expectedErrorStrings: []string{reasonRangeCuddledWithoutUse},
 		},
 		{
 			description: "can cuddle only one assignment",
@@ -534,9 +534,9 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				defer thingTwo.Close()
 			}`),
 			expectedErrorStrings: []string{
-				"assignments should only be cuddled with other assignments",
-				"only one cuddle assignment allowed before defer statement",
-				"only one cuddle assignment allowed before defer statement",
+				reasonAssignsCuddleAssign,
+				reasonOneCuddleBeforeDefer,
+				reasonOneCuddleBeforeDefer,
 			},
 		},
 		{
@@ -558,7 +558,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}()
 			}`),
 			expectedErrorStrings: []string{
-				"defer statements should only be cuddled with expressions on same variable",
+				reasonDeferCuddledWithOtherVar,
 			},
 		},
 		{
@@ -617,7 +617,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 					}
 				}
 			}`),
-			expectedErrorStrings: []string{"for statement without condition should never be cuddled"},
+			expectedErrorStrings: []string{reasonForWithoutCondition},
 		},
 		{
 			description: "support usage if chained",
@@ -644,8 +644,8 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}()
 			}`),
 			expectedErrorStrings: []string{
-				"go statements can only invoke functions assigned on line above",
-				"go statements can only invoke functions assigned on line above",
+				reasonGoFuncWithoutAssign,
+				reasonGoFuncWithoutAssign,
 			},
 		},
 		{
@@ -691,8 +691,8 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}
 			}`),
 			expectedErrorStrings: []string{
-				"switch statements should only be cuddled with variables switched",
-				"anonymous switch statements should never be cuddled",
+				reasonSwitchCuddledWithoutUse,
+				reasonAnonSwitchCuddled,
 			},
 		},
 		{
@@ -730,7 +730,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}
 			}`),
 			expectedErrorStrings: []string{
-				"type switch statements should only be cuddled with variables switched",
+				reasonTypeSwitchCuddledWithoutUse,
 			},
 		},
 		{
@@ -750,7 +750,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				bar := "baz"
 				someList = append(someList, "notBar")
 			}`),
-			expectedErrorStrings: []string{"append only allowed to cuddle with appended value"},
+			expectedErrorStrings: []string{reasonAppendCuddledWithoutUse},
 		},
 		{
 			description: "cuddle expressions to assignments",
@@ -765,7 +765,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				foo := true
 				someFunc(false)
 			}`),
-			expectedErrorStrings: []string{"only cuddled expressions if assigning variable or using from line above"},
+			expectedErrorStrings: []string{reasonExprCuddlingNonAssignedVar},
 		},
 		{
 			description: "channels and select, no false positives",
@@ -884,7 +884,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				whatever := SoThisIsOK(biz)
 			}`),
 			expectedErrorStrings: []string{
-				"append only allowed to cuddle with appended value",
+				reasonAppendCuddledWithoutUse,
 			},
 		},
 		{
@@ -920,8 +920,8 @@ func TestShouldAddEmptyLines(t *testing.T) {
 			}`),
 			expectedErrorStrings: []string{
 				"block should not start with a whitespace",
-				"block should not end with a whitespace (or comment)",
-				"if statements should only be cuddled with assignments used in the if statement itself",
+				reasonBlockEndsWithWS,
+				reasonOnlyCuddleWithUsedAssign,
 			},
 		},
 		{
@@ -972,7 +972,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				x.Calling()
 			}`),
 			expectedErrorStrings: []string{
-				"expressions should not be cuddled with blocks",
+				reasonExpressionCuddledWithBlock,
 			},
 		},
 		{
@@ -1024,8 +1024,8 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}
 			}`),
 			expectedErrorStrings: []string{
-				"if statements should only be cuddled with assignments used in the if statement itself",
-				"if statements should only be cuddled with assignments used in the if statement itself",
+				reasonOnlyCuddleWithUsedAssign,
+				reasonOnlyCuddleWithUsedAssign,
 			},
 		},
 		{
@@ -1063,9 +1063,9 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}
 			}`),
 			expectedErrorStrings: []string{
-				"block should not end with a whitespace (or comment)",
-				"block should not start with a whitespace",
-				"block should not start with a whitespace",
+				reasonBlockEndsWithWS,
+				reasonBlockStartsWithWS,
+				reasonBlockStartsWithWS,
 			},
 		},
 		{
@@ -1106,9 +1106,9 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				go t4()
 			}`),
 			expectedErrorStrings: []string{
-				"only one cuddle assignment allowed before go statement",
-				"go statements can only invoke functions assigned on line above",
-				"only one cuddle assignment allowed before go statement",
+				reasonOneCuddleBeforeGo,
+				reasonGoFuncWithoutAssign,
+				reasonOneCuddleBeforeGo,
 			},
 		},
 		{
@@ -1132,7 +1132,7 @@ func TestShouldAddEmptyLines(t *testing.T) {
 				}
 			}`),
 			expectedErrorStrings: []string{
-				"if statements should only be cuddled with assignments used in the if statement itself",
+				reasonOnlyCuddleWithUsedAssign,
 			},
 		},
 		{
@@ -1185,14 +1185,14 @@ func TestShouldAddEmptyLines(t *testing.T) {
 					}()
 				}`),
 			expectedErrorStrings: []string{
-				"assignments should only be cuddled with other assignments",
-				"assignments should only be cuddled with other assignments",
-				"assignments should only be cuddled with other assignments",
-				"assignments should only be cuddled with other assignments",
-				"assignments should only be cuddled with other assignments",
-				"assignments should only be cuddled with other assignments",
-				"assignments should only be cuddled with other assignments",
-				"assignments should only be cuddled with other assignments",
+				reasonAssignsCuddleAssign,
+				reasonAssignsCuddleAssign,
+				reasonAssignsCuddleAssign,
+				reasonAssignsCuddleAssign,
+				reasonAssignsCuddleAssign,
+				reasonAssignsCuddleAssign,
+				reasonAssignsCuddleAssign,
+				reasonAssignsCuddleAssign,
 			},
 		},
 	}
@@ -1256,7 +1256,7 @@ func TestWithConfig(t *testing.T) {
 			customConfig: &Configuration{
 				AllowMultiLineAssignCuddle: false,
 			},
-			expectedErrorStrings: []string{"if statements should only be cuddled with assignments"},
+			expectedErrorStrings: []string{reasonOnlyCuddleIfWithAssign},
 		},
 		{
 			description: "multi line assignment not ok when disabled",
@@ -1285,7 +1285,7 @@ func TestWithConfig(t *testing.T) {
 			customConfig: &Configuration{
 				AllowMultiLineAssignCuddle: true,
 			},
-			expectedErrorStrings: []string{"if statements should only be cuddled with assignments used in the if statement itself"},
+			expectedErrorStrings: []string{reasonOnlyCuddleWithUsedAssign},
 		},
 		{
 			description: "strict append",
@@ -1305,7 +1305,7 @@ func TestWithConfig(t *testing.T) {
 			customConfig: &Configuration{
 				StrictAppend: true,
 			},
-			expectedErrorStrings: []string{"append only allowed to cuddle with appended value"},
+			expectedErrorStrings: []string{reasonAppendCuddledWithoutUse},
 		},
 		{
 			description: "allow cuddle var",
@@ -1379,8 +1379,8 @@ func TestWithConfig(t *testing.T) {
 				AllowTrailingComment: true,
 			},
 			expectedErrorStrings: []string{
-				"block should not end with a whitespace (or comment)",
-				"block should not end with a whitespace (or comment)",
+				reasonBlockEndsWithWS,
+				reasonBlockEndsWithWS,
 			},
 		},
 		{
@@ -1475,16 +1475,16 @@ func TestWithConfig(t *testing.T) {
 				AllowTrailingComment:             true,
 			},
 			expectedErrorStrings: []string{
-				"case block should end with newline at this size",
-				"case block should end with newline at this size",
-				"case block should end with newline at this size",
+				reasonCaseBlockTooCuddly,
+				reasonCaseBlockTooCuddly,
+				reasonCaseBlockTooCuddly,
 			},
 		},
 		{
-			description:         "must cuddle error checks with the error assignment",
+			description: "must cuddle error checks with the error assignment",
 			customConfig: &Configuration{
-				MustCuddleErrCheckAndAssign:      true,
-				ErrorVariableNames:               []string{"err"},
+				MustCuddleErrCheckAndAssign: true,
+				ErrorVariableNames:          []string{"err"},
 			},
 			code: []byte(`package main
 
@@ -1497,14 +1497,14 @@ func TestWithConfig(t *testing.T) {
 					fmt.Println("I'm OK")
 				}
 			}`),
-			expectedErrorStrings: []string{"if statements that check an error must be cuddled with the statement that assigned the error"},
+			expectedErrorStrings: []string{reasonMustCuddleErrCheck},
 		},
 		{
-			description:         "must cuddle error checks with the error assignment multivalue",
+			description: "must cuddle error checks with the error assignment multivalue",
 			customConfig: &Configuration{
-				AllowMultiLineAssignCuddle:       true,
-				MustCuddleErrCheckAndAssign:      true,
-				ErrorVariableNames:               []string{"err"},
+				AllowMultiLineAssignCuddle:  true,
+				MustCuddleErrCheckAndAssign: true,
+				ErrorVariableNames:          []string{"err"},
 			},
 			code: []byte(`package main
 
@@ -1517,13 +1517,13 @@ func TestWithConfig(t *testing.T) {
 					panic(err)
 				}
 			}`),
-			expectedErrorStrings: []string{"if statements that check an error must be cuddled with the statement that assigned the error"},
+			expectedErrorStrings: []string{reasonMustCuddleErrCheck},
 		},
 		{
-			description:         "must cuddle error checks with the error assignment only on assignment",
+			description: "must cuddle error checks with the error assignment only on assignment",
 			customConfig: &Configuration{
-				MustCuddleErrCheckAndAssign:      true,
-				ErrorVariableNames:               []string{"err"},
+				MustCuddleErrCheckAndAssign: true,
+				ErrorVariableNames:          []string{"err"},
 			},
 			code: []byte(`package main
 
@@ -1546,11 +1546,11 @@ func TestWithConfig(t *testing.T) {
 			expectedErrorStrings: []string{},
 		},
 		{
-			description:         "must cuddle error checks with the error assignment multivalue NoError",
+			description: "must cuddle error checks with the error assignment multivalue NoError",
 			customConfig: &Configuration{
-				AllowMultiLineAssignCuddle:       true,
-				MustCuddleErrCheckAndAssign:      true,
-				ErrorVariableNames:               []string{"err"},
+				AllowMultiLineAssignCuddle:  true,
+				MustCuddleErrCheckAndAssign: true,
+				ErrorVariableNames:          []string{"err"},
 			},
 			code: []byte(`package main
 
@@ -1565,11 +1565,11 @@ func TestWithConfig(t *testing.T) {
 			expectedErrorStrings: []string{},
 		},
 		{
-			description:         "must cuddle error checks with the error assignment known err",
+			description: "must cuddle error checks with the error assignment known err",
 			customConfig: &Configuration{
-				AllowMultiLineAssignCuddle:       true,
-				MustCuddleErrCheckAndAssign:      true,
-				ErrorVariableNames:               []string{"err"},
+				AllowMultiLineAssignCuddle:  true,
+				MustCuddleErrCheckAndAssign: true,
+				ErrorVariableNames:          []string{"err"},
 			},
 			code: []byte(`package main
 
@@ -1582,14 +1582,14 @@ func TestWithConfig(t *testing.T) {
 					return []Model{}
 				}
 			}`),
-			expectedErrorStrings: []string{"if statements that check an error must be cuddled with the statement that assigned the error"},
+			expectedErrorStrings: []string{reasonMustCuddleErrCheck},
 		},
 		{
-			description:         "err-check cuddle enforcement doesn't generate false-positives.",
+			description: "err-check cuddle enforcement doesn't generate false-positives.",
 			customConfig: &Configuration{
-				AllowMultiLineAssignCuddle:       true,
-				MustCuddleErrCheckAndAssign:      true,
-				ErrorVariableNames:               []string{"err"},
+				AllowMultiLineAssignCuddle:  true,
+				MustCuddleErrCheckAndAssign: true,
+				ErrorVariableNames:          []string{"err"},
 			},
 			code: []byte(`package main