Skip to content

Commit

Permalink
Improve max-errors help message, remove get_fail_after
Browse files Browse the repository at this point in the history
Ref. #748
  • Loading branch information
Alexander Senier committed Aug 24, 2021
1 parent b9d53de commit 121176b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion rflx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def main(argv: List[str]) -> Union[int, str]:
type=int,
default=0,
metavar=("NUM"),
help="Maximum number of errors to report",
help="exit after at most NUM errors",
)

subparsers = parser.add_subparsers(dest="subcommand")
Expand Down
14 changes: 5 additions & 9 deletions rflx/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ def set_fail_after(count: int) -> None:
FAIL_AFTER_VALUE = count


def get_fail_after() -> int:
# pylint: disable = global-statement
global FAIL_AFTER_VALUE
return FAIL_AFTER_VALUE


class Location(Base):
def __init__(
self,
Expand Down Expand Up @@ -152,17 +146,19 @@ def extend(
self,
entries: Union[List[Tuple[str, Subsystem, Severity, Optional[Location]]], "BaseError"],
) -> None:
# pylint: disable = global-statement
global FAIL_AFTER_VALUE
if isinstance(entries, BaseError):
self.__errors.extend(entries.errors)
else:
for message, subsystem, severity, location in entries:
self.__errors.append(BaseError.Entry(message, subsystem, severity, location))
if (
get_fail_after() > 0
and len(
0
> FAIL_AFTER_VALUE
>= len(
list(e for e in self.__errors if e.severity in (Severity.WARNING, Severity.ERROR))
)
>= get_fail_after()
):
raise self

Expand Down

0 comments on commit 121176b

Please sign in to comment.