Ejemplo n.º 1
0
    def process_files(self, files):
        """
        Run code checks with mypy.
        Only a single process is made for all files
        to save resources.
        """
        log.debug('Processing %s files with %s', files, self.name)

        command = ['mypy', '--no-error-summary', '--show-absolute-path']
        if 'config' in self.options:
            command += ['--config-file', stringify(self.options.get('config'))]
        command += files

        output = docker.run('python3', command, source_dir=self.base_path)
        if not output:
            log.debug('No mypy errors found.')
            return False
        output = output.strip().split("\n")
        if len(output) and output[-1].startswith('mypy: error:'):
            msg = (
                u'Your `mypy` configuration file caused `mypy` to fail with:'
                '\n'
                '```\n'
                '{}\n'
                '```\n'
                'Please correct the error in your configuration file.')
            self.problems.add(IssueComment(msg.format(output[-1])))
            return

        process_quickfix(self.problems, output, docker.strip_base)
Ejemplo n.º 2
0
    def _apply_options(self, command):
        standard = 'PSR2'
        if self.options.get('standard'):
            standard = self.apply_base(self.options['standard'])
        command.append('--standard=' + stringify(standard))

        if self.options.get('ignore'):
            ignore = self.options['ignore']
            command.append('--ignore=' + stringify(ignore))
        if self.options.get('exclude'):
            exclude = self.options['exclude']
            command.append('--exclude=' + stringify(exclude))
        extension = 'php'
        if self.options.get('extensions'):
            extension = self.options['extensions']
        command.append('--extensions=' + stringify(extension))
        if self.options.get('tab_width'):
            command += ['--tab-width=' + stringify(self.options['tab_width'])]
        return command
Ejemplo n.º 3
0
    def _apply_options(self, command):
        standard = 'PSR2'
        if self.options.get('standard'):
            standard = self.apply_base(self.options['standard'])
        command.append('--standard=' + stringify(standard))

        if self.options.get('ignore'):
            ignore = self.options['ignore']
            command.append('--ignore=' + stringify(ignore))
        if self.options.get('exclude'):
            exclude = self.options['exclude']
            command.append('--exclude=' + stringify(exclude))
        extension = 'php'
        if self.options.get('extensions'):
            extension = self.options['extensions']
        command.append('--extensions=' + stringify(extension))
        if self.options.get('tab_width'):
            command += ['--tab-width=' + stringify(self.options['tab_width'])]
        return command
Ejemplo n.º 4
0
    def process_files(self, files):
        """
        Run code checks with csslint.
        Only a single process is made for all files
        to save resources.
        """
        cmd = 'csslint'
        command = [cmd, '--format=compact']

        if self.options.get('ignore'):
            command += ['--ignore=' + stringify(self.options.get('ignore'))]
        command += files

        output = docker.run('nodejs', command, source_dir=self.base_path)
        self._process_output(output)
Ejemplo n.º 5
0
    def make_command(self, files):
        msg_template = '{path}:{line}:{column}:{msg_id} {msg}'
        command = [
            'pylint',
            '--py3k',
            '--reports=n',
            '--msg-template',
            msg_template,
        ]
        accepted_options = ('ignore')
        if 'ignore' in self.options:
            command.extend(['-d', stringify(self.options['ignore'])])

        for option in self.options:
            if option in accepted_options:
                continue
            log.warning('Set non-existent py3k option: %s', option)
        command.extend(files)
        return command
Ejemplo n.º 6
0
    def apply_ignores(self, patterns, files):
        matchers = []
        for pattern in stringify(patterns).split(','):
            try:
                matcher = re.compile(pattern)
            except Exception:
                continue
            else:
                matchers.append(matcher)

        def has_match(name):
            return any([
                True
                for matcher in matchers
                if matcher.search(name)
            ])

        keepers = []
        for name in files:
            if not has_match(name):
                keepers.append(name)
        return keepers
Ejemplo n.º 7
0
    def make_command(self, files):
        msg_template = '{path}:{line}:{column}:{msg_id} {msg}'
        command = [
            'pylint',
            '--py3k',
            '--reports=n',
            '--msg-template',
            msg_template,
        ]
        accepted_options = ('ignore')
        if 'ignore' in self.options:
            command.extend(['-d', stringify(self.options['ignore'])])

        # Pylint's ignore-patterns option is unable to ignore
        # paths, so we have to do that ourselves.
        if 'ignore-patterns' in self.options:
            files = self.apply_ignores(self.options['ignore-patterns'], files)

        for option in self.options:
            if option in accepted_options:
                continue
            log.warning('Set non-existent py3k option: %s', option)
        command.extend(files)
        return command