Code scanning rules prevent pull requests with potential vulnerabilities from being merged.
A ruleset is a named list of rules that control how people can interact with branches and tags in your repositories. You can add code scanning rules to rulesets to prevent pull requests from being merged when any of the following conditions are met:
Typically, you should use code scanning merge protection on long-lived feature branches, where you want to guarantee code has been analyzed before pull requests can be merged.
Configuring a code scanning rule will not automatically enable code scanning. To learn how to enable code scanning, see Configuring default setup for code scanning.
Note
You can set code scanning merge protection with rulesets:
Merge protection with rulesets will not apply to:
Additionally, all the lines of code identified by an alert must exist in the pull request diff. For more information, see SARIF support for code scanning.
To configure a ruleset that requires code scanning results, see Set code scanning merge protection.