<commit_before>import platform

from coalib.bearlib.abstractions.Lint import Lint
from coalib.bearlib.spacing.SpacingHelper import SpacingHelper
from coalib.bears.LocalBear import LocalBear


class GNUIndentBear(Lint, LocalBear):
    executable = "indent" if platform.system() != "Darwin" else "gindent"
    diff_message = "Indentation can be improved."
    use_stdin = True
    gives_corrected = True

    def run(self,
            filename,
            file,
            max_line_length: int=80,
            use_spaces: bool=True,
            tab_width: int=SpacingHelper.DEFAULT_TAB_WIDTH,
            indent_cli_options: str=''):
        """
        This bear checks and corrects spacing and indentation via the well
        known Indent utility. It is designed to work with the C programming
        language but may work reasonably with syntactically similar languages.

        :param max_line_length:    Maximum number of characters for a line.
        :param use_spaces:         True if spaces are to be used, else tabs.
        :param tab_width:          Number of spaces per indent level.
        :param indent_cli_options: Any command line options the indent binary
                                   understands. They will be simply passed
                                   through.
        """
        self.arguments = "--no-tabs" if use_spaces else "--use-tabs"
        self.arguments += (" --line-length {0} --indent-level {1} "
                           "--tab-size {1} {2}".format(max_line_length,
                                                       tab_width,
                                                       indent_cli_options))
        return self.lint(filename, file)<commit_msg>GNUIndentBear: Refactor to Linter v2 API<commit_after>import platform
from shlex import split

from coalib.bearlib.abstractions.Linter import linter
from coalib.bearlib.spacing.SpacingHelper import SpacingHelper


@linter(executable="indent" if platform.system() != "Darwin" else "gindent",
        use_stdin=True,
        output_format='corrected',
        diff_message="Indentation can be improved.")
class GNUIndentBear:
    """
    This bear checks and corrects spacing and indentation via the well known
    Indent utility. It is designed to work with the C programming language but
    may work reasonably with syntactically similar languages.
    """

    @staticmethod
    def create_arguments(filename, file, config_file,
                         max_line_length: int=80,
                         use_spaces: bool=True,
                         tab_width: int=SpacingHelper.DEFAULT_TAB_WIDTH,
                         indent_cli_options: str=''):
        """
        :param max_line_length:    Maximum number of characters for a line.
        :param use_spaces:         True if spaces are to be used, else tabs.
        :param tab_width:          Number of spaces per indent level.
        :param indent_cli_options: Any command line options the indent binary
                                   understands. They will be simply passed
                                   through.
        """
        return ("--no-tabs" if use_spaces else "--use-tabs",
                "--line-length", str(max_line_length),
                "--indent-level", str(tab_width),
                "--tab-size", str(tab_width)) + tuple(split(indent_cli_options))
{'fraction_non_alphanumeric': 0.07504466944609887, 'fraction_numerical': 0.0026801667659321023, 'mean_word_length': 1.9751992914083258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7371500', 'n_tokens_mistral': 876, 'n_tokens_neox': 836, 'n_words': 274}