Add support for non-standard rule 'ignore'.

This commit is contained in:
Amy Boyd
2016-12-22 14:20:41 +00:00
parent 67e51c079a
commit 6a2c768176
4 changed files with 20 additions and 2 deletions

View File

@@ -2,8 +2,6 @@
* Add a fixer for the 'indent_style' rule. * Add a fixer for the 'indent_style' rule.
* Add a non-standard rule to ignore directories.
* Optimize speed and memory usage. * Optimize speed and memory usage.
* Document how to install. * Document how to install.

View File

@@ -26,6 +26,10 @@ func GetRulesToApplyToSourcePath(sourcePath string, cfs []ConfigFile) map[string
} }
} }
if isIgnored, _ := rules["ignore"]; isIgnored == "true" {
return make(map[string]string)
}
delete(rules, "root") delete(rules, "root")
if indentStyleValue, _ := rules["indent_style"]; indentStyleValue == "tab" { if indentStyleValue, _ := rules["indent_style"]; indentStyleValue == "tab" {

View File

@@ -32,3 +32,16 @@ func TestGetRulesToApplyToSourcePathWhenNoRulesShouldApply(t *testing.T) {
t.Error("No rules should be applied for the file") t.Error("No rules should be applied for the file")
} }
} }
func TestGetRulesToApplyToSourcePathWhenPathShouldBeIgnored(t *testing.T) {
result := GetRulesToApplyToSourcePath(
"some-file-to-ignore.ignored",
[]ConfigFile{
CreateConfigFileStruct("tests/.editorconfig"),
},
)
if len(result) != 0 {
t.Error("No rules should be applied for the file")
}
}

View File

@@ -13,3 +13,6 @@ trim_trailing_whitespace = false
[**.go] [**.go]
indent_style = tabs indent_style = tabs
[**.ignored]
ignore = true