Skip to content

Commit

Permalink
[fix] Eliminate __call__() from SkiplistHandler
Browse files Browse the repository at this point in the history
SkiplistHandler class had a __call__() function which forwarded to
should_skip(), so it didn't really had a real purpose. There was
also a "TODO" in the code to eliminate this function.
  • Loading branch information
bruntib committed Dec 4, 2023
1 parent 1e1825b commit de9eb46
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
14 changes: 0 additions & 14 deletions codechecker_common/skiplist_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,10 @@ def should_skip(self, source):
return sign == '-'
return False

def __call__(self, source_file_path: str) -> bool:
"""
Check if the given source should be skipped.
"""
return self.should_skip(source_file_path)

class SkipListHandlers(list):
def should_skip(self, file_path: str):
"""
True if the given source should be skipped by any of the skip list
handler.
"""
return any(handler.should_skip(file_path) for handler in self)

# FIXME: eliminate this function and use should_skip instead of this.
# Do the same in the SkipListHandler class above.
def __call__(self, file_path: str) -> bool:
"""
Check if the given source should be skipped.
"""
return self.should_skip(file_path)
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
import logging
import os

from typing import Callable, Dict, List, Optional, Set
from typing import Callable, Dict, List, Optional, Protocol, Set

from .. import util


LOG = logging.getLogger('report-converter')


SkipListHandlers = Callable[[str], bool]
class SkipListHandlers(Protocol):
should_skip: Callable[[str], bool]


InvalidFileContentMsg: str = \
Expand Down Expand Up @@ -473,7 +474,7 @@ def skip(self, skip_handlers: Optional[SkipListHandlers]) -> bool:
if not skip_handlers:
return False

return skip_handlers(self.file.original_path)
return skip_handlers.should_skip(self.file.original_path)

def to_json(self) -> Dict:
""" Creates a JSON dictionary. """
Expand Down

0 comments on commit de9eb46

Please sign in to comment.