Updates for code climate:
1) Refactored _ist_no_blank_line_* from rule.py into check.py
This commit is contained in:
parent
a4304575fc
commit
7b1b4e64ab
13
vsg/check.py
13
vsg/check.py
|
|
@ -5,3 +5,16 @@ def indent(self, oLine, iLineNumber):
|
|||
'''Adds a violation if the indent of the line does not match the desired level.'''
|
||||
if not re.match('^\s{' + str(self.indentSize * oLine.indentLevel) + '}\S', oLine.line):
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def is_no_blank_line_after(self, oFile, iLineNumber):
|
||||
'''Adds a violation if the line after iLineNumber is blank.
|
||||
This is typically used to compress lines together.'''
|
||||
if oFile.lines[iLineNumber + 1].isBlank:
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def is_no_blank_line_before(self, oFile, iLineNumber):
|
||||
'''Adds a violation if the line before iLineNumber is blank.
|
||||
This is typically used to compress lines together.'''
|
||||
if oFile.lines[iLineNumber - 1].isBlank:
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
|
|
|
|||
12
vsg/rule.py
12
vsg/rule.py
|
|
@ -73,18 +73,6 @@ class rule():
|
|||
'''Fixes indent violations.'''
|
||||
oLine.update_line(' '*oLine.indentLevel*self.indentSize + oLine.line.lstrip())
|
||||
|
||||
def _is_no_blank_line_after(self, oFile, iLineNumber):
|
||||
'''Adds a violation if the line after iLineNumber is blank.
|
||||
This is typically used to compress lines together.'''
|
||||
if oFile.lines[iLineNumber + 1].isBlank:
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def _is_no_blank_line_before(self, oFile, iLineNumber):
|
||||
'''Adds a violation if the line before iLineNumber is blank.
|
||||
This is typically used to compress lines together.'''
|
||||
if oFile.lines[iLineNumber - 1].isBlank:
|
||||
self.add_violation(iLineNumber)
|
||||
|
||||
def _is_blank_line_after(self, oFile, iLineNumber):
|
||||
'''Adds a violation if the line after iLineNumber is not blank.
|
||||
This is typically used to compress lines together.'''
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.component import component_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_016(component_rule):
|
||||
|
|
@ -16,7 +17,7 @@ class rule_016(component_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isComponentEnd:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.entity import entity_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_016(entity_rule):
|
||||
|
|
@ -16,7 +17,7 @@ class rule_016(entity_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isEndEntityDeclaration:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.generic import generic_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_001(generic_rule):
|
||||
|
|
@ -15,7 +16,7 @@ class rule_001(generic_rule):
|
|||
lFailureLines = []
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isGenericKeyword:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.if_statement import if_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_006(if_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_006(if_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isThenKeyword and not oFile.lines[iLineNumber + 2].isCaseKeyword and not oLine.isEndIfKeyword:
|
||||
self._is_no_blank_line_after(oFile, iLineNumber)
|
||||
check.is_no_blank_line_after(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.if_statement import if_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_007(if_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_007(if_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isElseIfKeyword:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.if_statement import if_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_008(if_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_008(if_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isEndIfKeyword and not oFile.lines[iLineNumber - 2].isEndCaseKeyword and not oLine.isIfKeyword:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.if_statement import if_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_010(if_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_010(if_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isElseKeyword and not oFile.lines[iLineNumber - 2].isEndCaseKeyword and not oLine.isIfKeyword:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.if_statement import if_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_011(if_rule):
|
||||
|
|
@ -14,7 +15,7 @@ class rule_011(if_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isElseKeyword and not oFile.lines[iLineNumber + 2].isCaseKeyword and not oLine.isEndIfKeyword:
|
||||
self._is_no_blank_line_after(oFile, iLineNumber)
|
||||
check.is_no_blank_line_after(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.library import library_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_007(library_rule):
|
||||
|
|
@ -16,7 +17,7 @@ class rule_007(library_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isLibraryUse:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
from vsg.rules.port import port_rule
|
||||
from vsg import check
|
||||
|
||||
|
||||
class rule_001(port_rule):
|
||||
|
|
@ -16,7 +17,7 @@ class rule_001(port_rule):
|
|||
def analyze(self, oFile):
|
||||
for iLineNumber, oLine in enumerate(oFile.lines):
|
||||
if oLine.isPortKeyword:
|
||||
self._is_no_blank_line_before(oFile, iLineNumber)
|
||||
check.is_no_blank_line_before(self, oFile, iLineNumber)
|
||||
|
||||
def _fix_violations(self, oFile):
|
||||
for iLineNumber in self.violations[::-1]:
|
||||
|
|
|
|||
Loading…
Reference in New Issue