mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
reached 100% testing cover
This commit is contained in:
parent
a9d54a63fc
commit
8e79502b8a
10 changed files with 13 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ from pre_commit_hooks.loaderon_hooks.util.template_methods.lines_checker_templat
|
|||
|
||||
class ClassDocstringChecker(LinesCheckerTemplateMethod):
|
||||
def _check_line(self):
|
||||
super(ClassDocstringChecker, self)._check_line()
|
||||
regular_expression = r'^(\t| )*class .+\(.*\):'
|
||||
pattern = re.compile(regular_expression)
|
||||
if pattern.match(self._file_line):
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ class LinesChecker(LinesCheckerTemplateMethod):
|
|||
self.check_arguments_size_match(self.args.line_to_check, self.args.regexp_to_match)
|
||||
|
||||
def _check_line(self):
|
||||
super(LinesChecker, self)._check_line()
|
||||
for line_index, line_to_check in enumerate(self.args.line_to_check):
|
||||
line_to_check_pattern = re.compile(line_to_check)
|
||||
if line_to_check_pattern.match(self._file_line):
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ class LocationChecker(FileCheckerTemplateMethod):
|
|||
|
||||
def _check_file(self):
|
||||
"""Check filename location against enabled directories and their enabled files."""
|
||||
super(LocationChecker, self)._check_file()
|
||||
self.check_arguments_size_match(self.args.directories, self.args.files)
|
||||
file_directory_path = os.path.dirname(self.filename)
|
||||
file_name = os.path.basename(self.filename)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ class PylintChecker(FileCheckerTemplateMethod):
|
|||
self.parser.add_argument('-e', '--exclude', help='Excluded files to check.')
|
||||
|
||||
def _check_file(self):
|
||||
super(PylintChecker, self)._check_file()
|
||||
try:
|
||||
self.run_pylint_except_in_excluded_files()
|
||||
except SystemExit as exception:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class XMLEncodingChecker(FileCheckerTemplateMethod):
|
|||
self.parser.add_argument('-e', '--encoding', help='Desired encoding.')
|
||||
|
||||
def _check_file(self):
|
||||
super(XMLEncodingChecker, self)._check_file()
|
||||
first_line = read_file_line(self.filename)
|
||||
desired_encoding = self.args.encoding.rstrip()
|
||||
first_line = first_line.rstrip('\n')
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class ModelNameAttributeChecker(FileBunchesLinesCheckerTemplateMethod):
|
|||
self.__inherit_line = ''
|
||||
|
||||
def _get_regexp(self):
|
||||
super(ModelNameAttributeChecker, self)._get_regexp()
|
||||
return r'^(\t| )*class.+'
|
||||
|
||||
def _check_file(self):
|
||||
|
|
@ -39,6 +40,7 @@ class ModelNameAttributeChecker(FileBunchesLinesCheckerTemplateMethod):
|
|||
We will use this inherited method (which runs through all file lines) in order to gather lines that are required
|
||||
to perform the lines bunch check.
|
||||
"""
|
||||
super(ModelNameAttributeChecker, self)._check_line()
|
||||
if self.__name_pattern.match(self._file_line):
|
||||
self.__name_line = self._file_line.strip('_name = ')
|
||||
if self.__inherit_pattern.match(self._file_line):
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@ class ViewFieldsOrderChecker(FileBunchesCheckerTemplateMethod):
|
|||
self._model_line = None
|
||||
|
||||
def _get_regexp(self):
|
||||
super(ViewFieldsOrderChecker, self)._get_regexp()
|
||||
return r'^(\t| )*<record id=.+ model="ir.ui.view">(\t| )*'
|
||||
|
||||
def _check_bunch(self):
|
||||
super(ViewFieldsOrderChecker, self)._check_bunch()
|
||||
self._record_line = self._bunch_of_lines[0].strip()
|
||||
self._name_line = self._bunch_of_lines[1]
|
||||
self._model_line = self._bunch_of_lines[2]
|
||||
|
|
|
|||
|
|
@ -17,9 +17,11 @@ class FileBunchesLinesCheckerTemplateMethod(FileBunchesCheckerTemplateMethod, Li
|
|||
This method uses LinesCheckerTemplateMethod's _check_lines. Which receives self._file_lines. In this case, our
|
||||
'file lines' will be the bunches of lines got by split_by_classes.
|
||||
"""
|
||||
super(FileBunchesLinesCheckerTemplateMethod, self)._check_bunch()
|
||||
self._file_lines = self._bunch_of_lines
|
||||
self._check_lines()
|
||||
|
||||
@abstractmethod
|
||||
def _check_line(self):
|
||||
super(FileBunchesLinesCheckerTemplateMethod, self)._check_line()
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ class FileBunchesCheckerTemplateMethod(FileCheckerTemplateMethod):
|
|||
self._bunch_of_lines = []
|
||||
|
||||
def _check_file(self):
|
||||
super(FileBunchesCheckerTemplateMethod, self)._check_file()
|
||||
regexp = self._get_regexp()
|
||||
bunches_of_lines = split_by_regexp(self.filename, regexp)
|
||||
for self._bunch_of_lines in bunches_of_lines:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ class LinesCheckerTemplateMethod(FileCheckerTemplateMethod):
|
|||
self._file_line_index = 0
|
||||
|
||||
def _check_file(self):
|
||||
super(LinesCheckerTemplateMethod, self)._check_file()
|
||||
self._file_lines = read_file_lines(self.filename)
|
||||
self._check_lines()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue