mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Implement copyright notice detection (#4701)
## Summary Add copyright notice detection to enforce the presence of copyright headers in Python files. Configurable settings include: the relevant regular expression, the author name, and the minimum file size, similar to [flake8-copyright](https://github.com/savoirfairelinux/flake8-copyright). Closes https://github.com/charliermarsh/ruff/issues/3579 --------- Signed-off-by: ryan <ryang@waabi.ai> Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
parent
9f7cc86a22
commit
ab3c02342b
26 changed files with 465 additions and 24 deletions
|
@ -15,9 +15,9 @@ pub(crate) fn derive_impl(input: DeriveInput) -> syn::Result<proc_macro2::TokenS
|
|||
let mut parsed = Vec::new();
|
||||
|
||||
let mut common_prefix_match_arms = quote!();
|
||||
let mut name_match_arms =
|
||||
quote!(Self::Ruff => "Ruff-specific rules", Self::Numpy => "NumPy-specific rules", );
|
||||
let mut url_match_arms = quote!(Self::Ruff => None, Self::Numpy => None, );
|
||||
let mut name_match_arms = quote!(Self::Ruff => "Ruff-specific rules", Self::Numpy => "NumPy-specific rules", Self::Copyright => "Copyright-related rules", );
|
||||
let mut url_match_arms =
|
||||
quote!(Self::Ruff => None, Self::Numpy => None, Self::Copyright => None, );
|
||||
|
||||
let mut all_prefixes = HashSet::new();
|
||||
|
||||
|
@ -59,7 +59,7 @@ pub(crate) fn derive_impl(input: DeriveInput) -> syn::Result<proc_macro2::TokenS
|
|||
|
||||
let variant_ident = variant.ident;
|
||||
|
||||
if variant_ident != "Ruff" && variant_ident != "Numpy" {
|
||||
if variant_ident != "Ruff" && variant_ident != "Numpy" && variant_ident != "Copyright" {
|
||||
let (name, url) = parse_doc_attr(doc_attr)?;
|
||||
name_match_arms.extend(quote! {Self::#variant_ident => #name,});
|
||||
url_match_arms.extend(quote! {Self::#variant_ident => Some(#url),});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue