Move reusable regexp constants to utils.go.

This commit is contained in:
Amy Boyd
2016-07-04 13:49:43 +01:00
parent 26cdc12f86
commit 03eddbde0c
3 changed files with 13 additions and 15 deletions

View File

@@ -2,7 +2,6 @@ package editorconfig
import (
"github.com/saintfish/chardet"
"regexp"
"strings"
)
@@ -20,10 +19,6 @@ type FullFileCheckResult struct {
messageIfNotOk string
}
var lfRegexp = regexp.MustCompile(`\n`)
var crRegexp = regexp.MustCompile(`\r`)
var crlfRegexp = regexp.MustCompile(`\r\n`)
func CheckEndOfLineRule(ruleValue string, fileContent string) *FullFileCheckResult {
// Valid rules values are "lf", "cr", or "crlf". The values are case insensitive.
ruleValueLowercase := strings.ToLower(ruleValue)
@@ -63,8 +58,6 @@ func CheckEndOfLineRule(ruleValue string, fileContent string) *FullFileCheckResu
return &FullFileCheckResult{isOk: true}
}
var endsWithFinalNewLineRegexp = regexp.MustCompile(`(\n|\r|\r\n)$`)
func CheckInsertFinalNewLineRule(ruleValue string, fileContent string) *FullFileCheckResult {
// Valid rules values are "true" or "false". The values are case insensitive.
ruleValueLowercase := strings.ToLower(ruleValue)