Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
conf = ConfigurationParser()
setup_stream_handlers(conf.get_default_run_configuration())
try:
conf.parse()
except IllegalConfiguration:
return ReturnCode.invalid_options
run_conf = conf.get_user_run_configuration()
# Reset the logger according to the command line arguments
setup_stream_handlers(run_conf)
log.debug("starting in debug mode.")
Error.explain = run_conf.explain
Error.source = run_conf.source
errors = []
changed_files = get_relevant_files()
if not changed_files:
return []
all_files = conf.get_files_to_check()
all_files = [file for file in all_files if file[0] in changed_files]
try:
for filename, checked_codes, ignore_decorators in all_files:
errors.extend(check((filename,), select=checked_codes, ignore_decorators=ignore_decorators))
except IllegalConfiguration as error:
# An illegal configuration file was found during file generation.
log.error(error.args[0])
setup_stream_handlers(conf.get_default_run_configuration())
try:
conf.parse()
except IllegalConfiguration:
return ReturnCode.invalid_options
run_conf = conf.get_user_run_configuration()
# Reset the logger according to the command line arguments
setup_stream_handlers(run_conf)
log.debug("starting in debug mode.")
Error.explain = run_conf.explain
Error.source = run_conf.source
errors = []
changed_files = get_relevant_files()
if not changed_files:
return []
all_files = conf.get_files_to_check()
all_files = [file for file in all_files if file[0] in changed_files]
try:
for filename, checked_codes, ignore_decorators in all_files:
errors.extend(check((filename,), select=checked_codes, ignore_decorators=ignore_decorators))
except IllegalConfiguration as error:
# An illegal configuration file was found during file generation.
log.error(error.args[0])
return ReturnCode.invalid_options
def make_issue(self, error, filename):
if isinstance(error, Error):
return PyDocStyleIssue(
error.code,
error.short_desc,
filename,
error.line,
)
if isinstance(error, EnvironmentError):
return AccessIssue(error, filename)
if isinstance(error, (AllError, ParseError, SyntaxError)):
return ParseIssue(error, filename)
return UnknownIssue(error, filename)