diff --git a/.pylintrc b/.pylintrc index 7b83e0de19b..a0c8aeecc17 100644 --- a/.pylintrc +++ b/.pylintrc @@ -19,7 +19,6 @@ disable = dangerous-default-value, duplicate-code, fixme, - missing-function-docstring, no-member, not-callable, protected-access, diff --git a/src/ansiblelint/formatters/__init__.py b/src/ansiblelint/formatters/__init__.py index b8aae743693..ab5926fb153 100644 --- a/src/ansiblelint/formatters/__init__.py +++ b/src/ansiblelint/formatters/__init__.py @@ -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 @@ -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( diff --git a/src/ansiblelint/rules/__init__.py b/src/ansiblelint/rules/__init__.py index 23ab741d2a5..982b0a0bbae 100644 --- a/src/ansiblelint/rules/__init__.py +++ b/src/ansiblelint/rules/__init__.py @@ -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() @@ -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) @@ -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, @@ -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) @@ -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(): @@ -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", diff --git a/src/ansiblelint/rules/risky_octal.py b/src/ansiblelint/rules/risky_octal.py index faf0aa5fdff..1cae0b7e68f 100644 --- a/src/ansiblelint/rules/risky_octal.py +++ b/src/ansiblelint/rules/risky_octal.py @@ -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)