Skip to content

Commit

Permalink
Address pylint missing-function-docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Mar 14, 2022
1 parent 5c8668b commit a7e79ed
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ disable =
dangerous-default-value,
duplicate-code,
fixme,
missing-function-docstring,
no-member,
not-callable,
protected-access,
Expand Down
2 changes: 2 additions & 0 deletions src/ansiblelint/formatters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _format_path(self, path: Union[str, Path]) -> str:

# pylint: disable=no-self-use
def format(self, match: "MatchError") -> str:
"""Format a match error."""
return str(match)

@staticmethod
Expand Down Expand Up @@ -154,6 +155,7 @@ class CodeclimateJSONFormatter(BaseFormatter[Any]):
"""

def format_result(self, matches: List["MatchError"]) -> str:
"""Format a list of match errors as a JSON string."""

if not isinstance(matches, list):
raise RuntimeError(
Expand Down
7 changes: 7 additions & 0 deletions src/ansiblelint/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class AnsibleLintRule(BaseRule):

@property
def rule_config(self) -> Dict[str, Any]:
"""Retrieve rule specific configuration."""
return get_rule_config(self.id)

@lru_cache()
Expand All @@ -57,6 +58,7 @@ def __repr__(self) -> str:

@staticmethod
def unjinja(text: str) -> str:
"""Remove jinja2 bits from a string."""
text = re.sub(r"{{.+?}}", "JINJA_EXPRESSION", text)
text = re.sub(r"{%.+?%}", "JINJA_STATEMENT", text)
text = re.sub(r"{#.+?#}", "JINJA_COMMENT", text)
Expand All @@ -71,6 +73,7 @@ def create_matcherror(
filename: Optional[Union[str, Lintable]] = None,
tag: str = "",
) -> MatchError:
"""Instantiate a new MatchError."""
match = MatchError(
message=message,
linenumber=linenumber,
Expand Down Expand Up @@ -251,6 +254,7 @@ def __init__(
self.rules = sorted(self.rules)

def register(self, obj: AnsibleLintRule) -> None:
"""Register a rule."""
# We skip opt-in rules which were not manually enabled
if "opt-in" not in obj.tags or obj.id in self.options.enable_list:
self.rules.append(obj)
Expand All @@ -264,11 +268,13 @@ def __len__(self) -> int:
return len(self.rules)

def extend(self, more: List[AnsibleLintRule]) -> None:
"""Combine rules."""
self.rules.extend(more)

def run(
self, file: Lintable, tags: Set[str] = set(), skip_list: List[str] = []
) -> List[MatchError]:
"""Run all the rules against the given lintable."""
matches: List[MatchError] = []

if not file.path.is_dir():
Expand Down Expand Up @@ -309,6 +315,7 @@ def __repr__(self) -> str:
)

def listtags(self) -> str:
"""Return a string with all the tags in the RulesCollection."""
tag_desc = {
"command-shell": "Specific to use of command and shell modules",
"core": "Related to internal implementation of the linter",
Expand Down
16 changes: 9 additions & 7 deletions src/ansiblelint/rules/risky_octal.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ class OctalPermissionsRule(AnsibleLintRule):

@staticmethod
def is_invalid_permission(mode: int) -> bool:
# sensible file permission modes don't
# have write bit set when read bit is
# not set and don't have execute bit set
# when user execute bit is not set.
# also, user permissions are more generous than
# group permissions and user and group permissions
# are more generous than world permissions
"""Check if permissions are valid.
Sensible file permission modes don't have write bit set when read bit
is not set and don't have execute bit set when user execute bit is
not set.
Also, user permissions are more generous than group permissions and
user and group permissions are more generous than world permissions
"""

other_write_without_read = (
mode % 8 and mode % 8 < 4 and not (mode % 8 == 1 and (mode >> 6) % 2 == 1)
Expand Down

0 comments on commit a7e79ed

Please sign in to comment.