def filter_issue_types()

in src/advisor/reports/issues/issue_type_config.py [0:0]


    def filter_issue_types(self, issue_types):
        """Filters the given dictionary of issue types.

        This function is careful to preserve the order of issue types given on
        the command line if the user passed an explicit list.

        For example, if the user passed:
            --issue-types=PreprocessorIssue,ConfigGuessIssue
        on the command line, this function will return:
            [PreprocessorIssue, ConfigGuessIssue].

        This is to allow the user direct control over the order of the column
        headings for the CSV output format.

        If no explicit list was passed (i.e. the user specified only non-default
        inclusions or exclusions prefixed by + or -) the function returns a list
        of issue type classes sorted in order of their display name.
        """

        # A list of issue type classes, sorted by the display name. This is used
        # to keep the results in display name order where the order is otherwise
        # not specified.
        sorted_issue_types = [cls for _, cls in sorted(issue_types.items(), key=itemgetter(0))]
        if not self._include_by_default:
            # Preserve the order of issue types given on the command line.
            source_list = []
            for (cls, _) in self.klasses:
                for issue_type in sorted_issue_types:
                    if (issue_type == cls or issubclass(issue_type, cls)) and not issue_type in source_list:
                        source_list.append(issue_type)
        else:
            source_list = sorted_issue_types
        ret = []
        for klass_a in source_list:
            want_this_class = self._include_by_default
            for (klass_b, want_this_issue_type) in self.klasses:
                if klass_a == klass_b or issubclass(klass_a, klass_b):
                    want_this_class = want_this_issue_type
            if want_this_class:
                ret.append(klass_a)
        return ret