Updates for issue #90
1) Moved _is_single_space_after and _is_single_space_before to check.py
This commit is contained in:
parent
3aec9ca446
commit
cdd8543428
|
|
@ -78,3 +78,12 @@ def is_uppercase(self, sString, iLineNumber):
|
|||
def is_lowercase(self, sString, iLineNumber):
|
||||
if not sString == sString.lower():
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def is_single_space_after(self, sString, oLine, iLineNumber):
|
||||
if not re.match('^.*\s+' + sString + '\s\S', oLine.lineLower):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def is_single_space_before(self, sString, oLine, iLineNumber):
|
||||
if not re.match('^.*\S\s' + sString + '\s', oLine.lineLower) and \
|
||||
not re.match('^.*\S\s' + sString + '$', oLine.lineLower):
|
||||
self.add_violation(iLineNumber)
|
||||
|
|
|
|||
10
vsg/rule.py
10
vsg/rule.py
|
|
@ -75,16 +75,6 @@ class rule():
|
|||
def _get_first_word(self, oLine):
|
||||
return self._get_word(oLine, 0)
|
||||
|
||||
def _is_single_space_after(self, sString, oLine, iLineNumber):
|
||||
if not re.match('^.*\s+' + sString + '\s\S', oLine.lineLower):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def _is_single_space_before(self, sString, oLine, iLineNumber):
|
||||
if not re.match('^.*\S\s' + sString + '\s', oLine.lineLower) and \
|
||||
not re.match('^.*\S\s' + sString + '$', oLine.lineLower):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
|
||||
def _fix_keyword_alignment(self, oFile):
|
||||
for sKey in self.dFix['violations']:
|
||||
iMaximumKeywordColumn = self.dFix['violations'][sKey]['maximumKeywordColumn']
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.case import case_rule
|
||||
from vsg import check
|
||||
import re
|
||||
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ class rule_002(case_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isCaseKeyword:
|
||||
self._is_single_space_after('case', oLine, iLineNumber)
|
||||
check.is_single_space_after(self, 'case', oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.case import case_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_003(case_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_003(case_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isCaseIsKeyword:
|
||||
self._is_single_space_before('is', oLine, iLineNumber)
|
||||
check.is_single_space_before(self, 'is', oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.case import case_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_004(case_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_004(case_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isCaseWhenKeyword:
|
||||
self._is_single_space_after('when', oLine, iLineNumber)
|
||||
check.is_single_space_after(self, 'when', oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.case import case_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_005(case_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_005(case_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isCaseWhenEnd:
|
||||
self._is_single_space_before('=>', oLine, iLineNumber)
|
||||
check.is_single_space_before(self, '=>', oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.case import case_rule
|
||||
from vsg import check
|
||||
import re
|
||||
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ class rule_006(case_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isEndCaseKeyword:
|
||||
self._is_single_space_after('end', oLine, iLineNumber)
|
||||
check.is_single_space_after(self, 'end', oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.component import component_rule
|
||||
from vsg import check
|
||||
|
||||
import re
|
||||
|
||||
|
|
@ -17,7 +18,7 @@ class rule_007(component_rule):
|
|||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isComponentDeclaration:
|
||||
if len(oLine.line.split()) > 2:
|
||||
self._is_single_space_before('is', oLine, iLineNumber)
|
||||
check.is_single_space_before(self, 'is', oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.component import component_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_013(component_rule):
|
||||
|
|
@ -15,7 +16,7 @@ class rule_013(component_rule):
|
|||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isComponentEnd:
|
||||
if len(oLine.line.split()) >= 3:
|
||||
self._is_single_space_after('component', oLine, iLineNumber)
|
||||
check.is_single_space_after(self, 'component', oLine, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations:
|
||||
|
|
|
|||
Loading…
Reference in New Issue