prospector/ranking/rules.py
def apply_rule_code_token_in_paths(
    candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
    """
    This rule matches commits that modify paths that correspond to a code token extracted
    from the advisory.
    """

    explanation_template = "The commit modifies the following paths: {}"

    matches = set(
        [
            (p, token)
            for p in candidate.changed_files
            for token in advisory_record.code_tokens
            if token in p
        ]
    )

    if len(matches) > 0:
        explained_matches = []

        for m in matches:
            explained_matches.append("{} ({})".format(m[0], m[1]))

        return explanation_template.format(", ".join(explained_matches))

    return None

    This rule matches commits that modify paths that correspond to a code token extracted
    from the advisory.
    
This rule matches commits that modify paths that correspond to a code token extracted
from the advisory.
This rule matches commits that modify paths that correspond to a code token extracted from the advisory .
def apply_rule_code_token_in_paths(
    candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
    explanation_template = "The commit modifies the following paths: {}"
    matches = set(
        [
            (p, token)
            for p in candidate.changed_files
            for token in advisory_record.code_tokens
            if token in p
        ]
    )
    if len(matches) > 0:
        explained_matches = []
        for m in matches:
            explained_matches.append("{} ({})".format(m[0], m[1]))
        return explanation_template.format(", ".join(explained_matches))
    return None
def apply_rule_code_token_in_paths ( candidate : Commit , advisory_record : AdvisoryRecord ) -> str : explanation_template = "The commit modifies the following paths: {}" matches = set ( [ ( p , token ) for p in candidate . changed_files for token in advisory_record . code_tokens if token in p ] ) if len ( matches ) > 0 : explained_matches = [ ] for m in matches : explained_matches . append ( "{} ({})" . format ( m [ 0 ] , m [ 1 ] ) ) return explanation_template . format ( ", " . join ( explained_matches ) ) return None
This rule matches commits that modify paths that correspond to a code token extracted
from the advisory.
This rule matches commits that modify paths that correspond to a code token extracted from the advisory .
"""
    This rule matches commits that modify paths that correspond to a code token extracted
    from the advisory.
    """
candidate
Commit
advisory_record
AdvisoryRecord