Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if found_config_file_path is None:
logging.info("""No 'gdlintrc' nor '.gdlintrc' found. Using default config...""")
config = DEFAULT_CONFIG
else:
logging.info("Config file found: '%s'", found_config_file_path)
with open(found_config_file_path, "r") as fh:
config = yaml.load(fh.read(), Loader=yaml.Loader)
logging.info("Loaded config:")
for entry in config.items():
logging.info(entry)
for key in DEFAULT_CONFIG:
if key not in config:
logging.info(
"Adding missing entry from defaults: %s", (key, DEFAULT_CONFIG[key])
)
config[key] = DEFAULT_CONFIG[key]
problems_total = 0
for file_path in arguments[""]:
with open(file_path, "r") as fh: # TODO: handle exception
content = fh.read()
problems = lint_code(content, config)
problems_total += len(problems)
if len(problems) > 0: # TODO: friendly frontend like in halint
for problem in problems:
print_problem(problem, file_path)
if problems_total > 0:
print(
"Failure: {} problem{} found".format(
search_dir = Path(os.getcwd())
found_config_file_path = None
while search_dir != Path(os.path.abspath(os.sep)):
file_path = os.path.join(search_dir, CONFIG_FILE_NAME)
if os.path.isfile(file_path):
found_config_file_path = file_path
break
file_path = os.path.join(search_dir, ".{}".format(CONFIG_FILE_NAME))
if os.path.isfile(file_path):
found_config_file_path = file_path
break
search_dir = search_dir.parent
if found_config_file_path is None:
logging.info("""No 'gdlintrc' nor '.gdlintrc' found. Using default config...""")
config = DEFAULT_CONFIG
else:
logging.info("Config file found: '%s'", found_config_file_path)
with open(found_config_file_path, "r") as fh:
config = yaml.load(fh.read(), Loader=yaml.Loader)
logging.info("Loaded config:")
for entry in config.items():
logging.info(entry)
for key in DEFAULT_CONFIG:
if key not in config:
logging.info(
"Adding missing entry from defaults: %s", (key, DEFAULT_CONFIG[key])
)
config[key] = DEFAULT_CONFIG[key]
break
search_dir = search_dir.parent
if found_config_file_path is None:
logging.info("""No 'gdlintrc' nor '.gdlintrc' found. Using default config...""")
config = DEFAULT_CONFIG
else:
logging.info("Config file found: '%s'", found_config_file_path)
with open(found_config_file_path, "r") as fh:
config = yaml.load(fh.read(), Loader=yaml.Loader)
logging.info("Loaded config:")
for entry in config.items():
logging.info(entry)
for key in DEFAULT_CONFIG:
if key not in config:
logging.info(
"Adding missing entry from defaults: %s", (key, DEFAULT_CONFIG[key])
)
config[key] = DEFAULT_CONFIG[key]
problems_total = 0
for file_path in arguments[""]:
with open(file_path, "r") as fh: # TODO: handle exception
content = fh.read()
problems = lint_code(content, config)
problems_total += len(problems)
if len(problems) > 0: # TODO: friendly frontend like in halint
for problem in problems:
print_problem(problem, file_path)