"""Run a check on a line of an ebuild."""
"""A regular expression to determine whether to ignore the line"""
ignore_line = False
+ """True if lines containing nothing more than comments with optional
+ leading whitespace should be ignored"""
+ ignore_comment = True
def new(self, pkg):
pass
class PhaseCheck(LineCheck):
""" basic class for function detection """
- ignore_line = re.compile(r'(^\s*#)')
func_end_re = re.compile(r'^\}$')
phases_re = re.compile('(%s)' % '|'.join((
'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare',
repoman_check_name = 'ebuild.minorsyn'
ignore_line = re.compile(r'(^$)|(^(\t)*#)')
+ ignore_comment = False
leading_spaces = re.compile(r'^[\S\t]')
trailing_whitespace = re.compile(r'.*([\S]$)')
class EbuildBlankLine(LineCheck):
repoman_check_name = 'ebuild.minorsyn'
+ ignore_comment = False
blank_line = re.compile(r'^$')
def new(self, pkg):
_ignored_commands = ["local", "export"] + _message_commands
ignore_line = re.compile(r'(^$)|(^\s*#.*)|(^\s*\w+=.*)' + \
r'|(^\s*(' + "|".join(_ignored_commands) + r')\s+)')
+ ignore_comment = False
var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"]
# EAPI=3/Prefix vars
readonly_assignment = re.compile(r'^\s*(export\s+)?(A|CATEGORY|P|PV|PN|PR|PVR|PF|D|WORKDIR|FILESDIR|FEATURES|USE)=')
line_continuation = re.compile(r'([^#]*\S)(\s+|\t)\\$')
ignore_line = re.compile(r'(^$)|(^(\t)*#)')
+ ignore_comment = False
def __init__(self):
self.previous_line = None
"""
repoman_check_name = 'inherit.autotools'
- ignore_line = re.compile(r'(^|\s*)#')
_inherit_autotools_re = re.compile(r'^\s*inherit\s(.*\s)?autotools(\s|$)')
_autotools_funcs = (
"eaclocal", "eautoconf", "eautoheader",
class BuiltWithUse(LineCheck):
repoman_check_name = 'ebuild.minorsyn'
- ignore_line = re.compile(r'^\s*#')
re = re.compile('^.*built_with_use')
error = errors.BUILT_WITH_USE
# EAPI-3 checks
class Eapi3DeprecatedFuncs(LineCheck):
repoman_check_name = 'EAPI.deprecated'
- ignore_line = re.compile(r'(^\s*#)')
deprecated_commands_re = re.compile(r'^\s*(check_license)\b')
def check_eapi(self, eapi):
# EAPI-4 checks
class Eapi4IncompatibleFuncs(LineCheck):
repoman_check_name = 'EAPI.incompatible'
- ignore_line = re.compile(r'(^\s*#)')
banned_commands_re = re.compile(r'^\s*(dosed|dohard)')
def check_eapi(self, eapi):
class Eapi4GoneVars(LineCheck):
repoman_check_name = 'EAPI.incompatible'
- ignore_line = re.compile(r'(^\s*#)')
undefined_vars_re = re.compile(r'.*\$(\{(AA|KV|EMERGE_FROM)\}|(AA|KV|EMERGE_FROM))')
def check_eapi(self, eapi):
DeprecatedUseq, DeprecatedHasq)))
_here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')
+_ignore_comment_re = re.compile(r'^\s*#')
def run_checks(contents, pkg):
checks = _constant_checks
if here_doc_delim is None:
# We're not in a here-document.
+ is_comment = _ignore_comment_re.match(line) is not None
for lc in checks:
+ if is_comment and lc.ignore_comment:
+ continue
if lc.check_eapi(pkg.metadata['EAPI']):
ignore = lc.ignore_line
if not ignore or not ignore.match(line):