Completed
Pull Request — master (#1073)
by Lasse
01:56
created

bears.linters.IndentBear.run()   A

Complexity

Conditions 2

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 2
dl 0
loc 17
rs 9.4286
1
import platform
2
from bears.linters.CorrectionBasedBear import CorrectionBasedBear
3
4
5
class IndentBear(CorrectionBasedBear):
6
    BINARY = "indent" if platform.system() != "Darwin" else "gindent"
7
    RESULT_MESSAGE = "Indentation can be improved."
8
9
    def run(self,
10
            filename,
11
            file,
12
            indent_cli_options: str='--k-and-r-style'):
13
        """
14
        This bear checks and corrects spacing and indentation via the well
15
        known Indent utility. It is designed to work with the C programming
16
        language but may work reasonably with syntactically similar languages.
17
18
        :param indent_cli_options: Any command line options the indent binary
19
                                   understands. They will be simply passed
20
                                   through.
21
        """
22
        for result in self.retrieve_results(filename,
23
                                            file,
24
                                            cli_options=indent_cli_options):
25
            yield result
26