Repository: roaldnefs/salt-lint

Issue:
Check #210 triggers on more than filerights
Currently, check `#210` (in [YamlHasOctalValueRule](https://github.com/roaldnefs/salt-lint/blob/master/lib/saltlint/rules/YamlHasOctalValueRule.py)) has a regex set too wide, and triggers on all numbers starting with a zero.

Proposed solutions:

* Match regex on leading colon + space (`: 0123`)
* Match regex on `mode: 0123`

Discussion:

Patch:
diff --git a/lib/saltlint/rules/YamlHasOctalValueRule.py b/lib/saltlint/rules/YamlHasOctalValueRule.py
index 541a9b9..c91b4f8 100644
--- a/lib/saltlint/rules/YamlHasOctalValueRule.py
+++ b/lib/saltlint/rules/YamlHasOctalValueRule.py
@@ -14,7 +14,7 @@ class YamlHasOctalValueRule(SaltLintRule):
     tags = ['formatting']
     version_added = 'v0.0.6'
 
-    bracket_regex = re.compile(r"(?<!['\"])0+[1-9]\d*(?!['\"])")
+    bracket_regex = re.compile(r": (?<!['\"])0+[1-9]\d*(?!['\"])")
 
     def match(self, file, line):
         return self.bracket_regex.search(line)


Test patch:
diff --git a/tests/unit/TestYamlHasOctalValueRule.py b/tests/unit/TestYamlHasOctalValueRule.py
index 996fa63..640aab8 100644
--- a/tests/unit/TestYamlHasOctalValueRule.py
+++ b/tests/unit/TestYamlHasOctalValueRule.py
@@ -16,9 +16,9 @@ testdirectory:
     - file_mode: 700
     - dir_mode: '0775'
 
-testdirectory2:
+testdirectory02:
   file.recurse:
-    - name: /tmp/directory2
+    - name: /tmp/directory02
     - file_mode: 0
     - dir_mode: "0775"
 '''