Пример #1
0
    def get_nits(self, python_file):
        """Iterate over the instances style checker and yield Nits

    :param python_file: PythonFile Object
    """
        if noqa_file_filter(python_file):
            return

        if self.options.suppress:
            # Filter out any suppressed plugins
            excluder = FileExcluder(self.options.suppress, self.context.log)
            check_plugins = [
                plugin for plugin in self._plugins
                if excluder.should_include(python_file.filename, plugin.name)
            ]
        else:
            check_plugins = self._plugins

        for plugin in check_plugins:
            for nit in plugin.checker(python_file):
                if nit._line_number is None:
                    yield nit
                    continue

                nit_slice = python_file.line_range(nit._line_number)
                for line_number in range(nit_slice.start, nit_slice.stop):
                    if noqa_line_filter(python_file, line_number):
                        break
                    else:
                        yield nit
Пример #2
0
    def setUp(self, *args, **kwargs):
        super(TestExcluder, self).setUp(*args, **kwargs)
        excludes_text = textwrap.dedent('''
      # ignore C++
      .*\.cpp::.*

      # ignore python
      .*\.py::Flake8''')
        self.excluder = FileExcluder(
            self._create_scalastyle_excludes_file([excludes_text]), logger)
Пример #3
0
    def setUp(self):
        super(TestExcluder, self).setUp()
        excludes_text = textwrap.dedent("""
      # ignore C++
      .*\.cpp::.*

      # ignore python
      .*\.py::Flake8
    """)
        self.excluder = FileExcluder(
            self._create_scalastyle_excludes_file([excludes_text]), logger)