Skip to content

Commit c62d16a

Browse files
committed
Refactoring complete
Signed-off-by: Ole Herman Schumacher Elgesem <ole@northern.tech>
1 parent 96b44c2 commit c62d16a

File tree

3 files changed

+502
-286
lines changed

3 files changed

+502
-286
lines changed

src/cfengine_cli/commands.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import json
55
from cfengine_cli.profile import profile_cfengine, generate_callstack
66
from cfengine_cli.dev import dispatch_dev_subcommand
7-
from cfengine_cli.lint import lint_folder, lint_single_arg
7+
from cfengine_cli.lint import lint_args
88
from cfengine_cli.shell import user_command
99
from cfengine_cli.paths import bin
1010
from cfengine_cli.version import cfengine_cli_version_string
@@ -96,20 +96,16 @@ def format(names, line_length) -> int:
9696

9797
def _lint(files, strict) -> int:
9898
if not files:
99-
return lint_folder(".", strict)
100-
101-
errors = 0
102-
103-
for file in files:
104-
errors += lint_single_arg(file, strict)
105-
106-
return errors
99+
return lint_args(["."], strict)
100+
return lint_args(files, strict)
107101

108102

109103
def lint(files, strict) -> int:
110104
errors = _lint(files, strict)
111105
if errors == 0:
112106
print("Success, no errors found.")
107+
elif errors == 1:
108+
print("Failure, 1 error in total.")
113109
else:
114110
print(f"Failure, {errors} errors in total.")
115111
return errors

src/cfengine_cli/docs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from cfbs.pretty import pretty_file
1717
from cfbs.utils import find
1818

19-
from cfengine_cli.lint import lint_folder, lint_policy_file
19+
from cfengine_cli.lint import lint_args, lint_policy_file_snippet
2020
from cfengine_cli.utils import UserError
2121

2222
IGNORED_DIRS = [".git"]
@@ -138,7 +138,7 @@ def fn_check_syntax(
138138

139139
match language:
140140
case "cf":
141-
r = lint_policy_file(
141+
r = lint_policy_file_snippet(
142142
snippet_abs_path, origin_path, first_line + 1, snippet_number, prefix
143143
)
144144
if r != 0:
@@ -409,7 +409,7 @@ def check_docs() -> int:
409409
410410
Run by the command:
411411
cfengine dev lint-docs"""
412-
r = lint_folder(".", strict=False)
412+
r = lint_args(["."], strict=False)
413413
if r != 0:
414414
return r
415415
_process_markdown_code_blocks(

0 commit comments

Comments
 (0)