prospector/ranking/rules.py
def apply_rule_code_tokens_in_diff(
    candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
    """
    This rule matches commits whose diff contain some of the special "code tokens"
    extracted from the advisory.
    """

    explanation_template = "The commit diff includes the following keywords: {}"

    matching_keywords = set(
        [
            kw
            for kw in advisory_record.code_tokens
            for diff_line in candidate.diff
            if kw in diff_line
        ]
    )

    if len(matching_keywords) > 0:
        return explanation_template.format(", ".join(matching_keywords))

    return None

    This rule matches commits whose diff contain some of the special "code tokens"
    extracted from the advisory.
    
This rule matches commits whose diff contain some of the special "code tokens"
extracted from the advisory.
This rule matches commits whose diff contain some of the special " code tokens " extracted from the advisory .
def apply_rule_code_tokens_in_diff(
    candidate: Commit, advisory_record: AdvisoryRecord
) -> str:
    explanation_template = "The commit diff includes the following keywords: {}"
    matching_keywords = set(
        [
            kw
            for kw in advisory_record.code_tokens
            for diff_line in candidate.diff
            if kw in diff_line
        ]
    )
    if len(matching_keywords) > 0:
        return explanation_template.format(", ".join(matching_keywords))
    return None
def apply_rule_code_tokens_in_diff ( candidate : Commit , advisory_record : AdvisoryRecord ) -> str : explanation_template = "The commit diff includes the following keywords: {}" matching_keywords = set ( [ kw for kw in advisory_record . code_tokens for diff_line in candidate . diff if kw in diff_line ] ) if len ( matching_keywords ) > 0 : return explanation_template . format ( ", " . join ( matching_keywords ) ) return None
This rule matches commits whose diff contain some of the special "code tokens"
extracted from the advisory.
This rule matches commits whose diff contain some of the special " code tokens " extracted from the advisory .
"""
    This rule matches commits whose diff contain some of the special "code tokens"
    extracted from the advisory.
    """
candidate
Commit
advisory_record
AdvisoryRecord