parent
4756217787
commit
025bd2afd2
@ -1,174 +0,0 @@ |
|||||||
[build] |
|
||||||
rustflags = [ |
|
||||||
"-Wclippy::allow-attributes", |
|
||||||
"-Wclippy::allow-attributes-without-reason", |
|
||||||
"-Wclippy::as-underscore", |
|
||||||
"-Wclippy::assertions-on-result-states", |
|
||||||
"-Wclippy::bool-to-int-with-if", |
|
||||||
"-Wclippy::borrow-as-ptr", |
|
||||||
"-Wclippy::case-sensitive-file-extension-comparisons", |
|
||||||
"-Wclippy::cast-lossless", |
|
||||||
"-Wclippy::cast-possible-truncation", |
|
||||||
"-Wclippy::cast-possible-wrap", |
|
||||||
"-Wclippy::cast-precision-loss", |
|
||||||
"-Wclippy::cast-ptr-alignment", |
|
||||||
"-Wclippy::cast-sign-loss", |
|
||||||
"-Wclippy::checked-conversions", |
|
||||||
"-Wclippy::clone-on-ref-ptr", |
|
||||||
"-Wclippy::cloned-instead-of-copied", |
|
||||||
"-Wclippy::copy-iterator", |
|
||||||
"-Wclippy::create-dir", |
|
||||||
"-Wclippy::dbg-macro", |
|
||||||
"-Wclippy::decimal-literal-representation", |
|
||||||
"-Wclippy::default-trait-access", |
|
||||||
"-Wclippy::default-union-representation", |
|
||||||
"-Wclippy::deref-by-slicing", |
|
||||||
"-Wclippy::disallowed-script-idents", |
|
||||||
"-Wclippy::doc-link-with-quotes", |
|
||||||
"-Wclippy::empty-drop", |
|
||||||
"-Wclippy::empty-enum", |
|
||||||
"-Wclippy::empty-structs-with-brackets", |
|
||||||
"-Wclippy::enum-glob-use", |
|
||||||
"-Wclippy::error-impl-error", |
|
||||||
"-Wclippy::exit", |
|
||||||
"-Wclippy::expect-used", |
|
||||||
"-Wclippy::expl-impl-clone-on-copy", |
|
||||||
"-Wclippy::explicit-deref-methods", |
|
||||||
"-Wclippy::explicit-into-iter-loop", |
|
||||||
"-Wclippy::explicit-iter-loop", |
|
||||||
"-Wclippy::filetype-is-file", |
|
||||||
"-Wclippy::filter-map-next", |
|
||||||
"-Wclippy::flat-map-option", |
|
||||||
"-Wclippy::fn-params-excessive-bools", |
|
||||||
"-Wclippy::fn-to-numeric-cast-any", |
|
||||||
"-Wclippy::format-push-string", |
|
||||||
"-Wclippy::from-iter-instead-of-collect", |
|
||||||
"-Wclippy::get-unwrap", |
|
||||||
"-Wclippy::host-endian-bytes", |
|
||||||
"-Wclippy::if-not-else", |
|
||||||
"-Wclippy::if-then-some-else-none", |
|
||||||
"-Wclippy::ignored-unit-patterns", |
|
||||||
"-Wclippy::implicit-clone", |
|
||||||
"-Wclippy::implicit-hasher", |
|
||||||
"-Wclippy::inconsistent-struct-constructor", |
|
||||||
"-Wclippy::index-refutable-slice", |
|
||||||
"-Wclippy::inefficient-to-string", |
|
||||||
"-Wclippy::inline-always", |
|
||||||
"-Wclippy::inline-asm-x86-att-syntax", |
|
||||||
"-Wclippy::inline-asm-x86-intel-syntax", |
|
||||||
"-Wclippy::invalid-upcast-comparisons", |
|
||||||
"-Wclippy::items-after-statements", |
|
||||||
"-Wclippy::iter-not-returning-iterator", |
|
||||||
"-Wclippy::large-digit-groups", |
|
||||||
"-Wclippy::large-futures", |
|
||||||
"-Wclippy::large-include-file", |
|
||||||
"-Wclippy::large-stack-arrays", |
|
||||||
"-Wclippy::large-types-passed-by-value", |
|
||||||
"-Wclippy::let-underscore-must-use", |
|
||||||
"-Wclippy::let-underscore-untyped", |
|
||||||
"-Wclippy::linkedlist", |
|
||||||
"-Wclippy::lossy-float-literal", |
|
||||||
"-Wclippy::macro-use-imports", |
|
||||||
"-Wclippy::manual-assert", |
|
||||||
"-Wclippy::manual-instant-elapsed", |
|
||||||
"-Wclippy::manual-let-else", |
|
||||||
"-Wclippy::manual-ok-or", |
|
||||||
"-Wclippy::manual-string-new", |
|
||||||
"-Wclippy::many-single-char-names", |
|
||||||
"-Wclippy::map-unwrap-or", |
|
||||||
"-Wclippy::match-bool", |
|
||||||
"-Wclippy::match-on-vec-items", |
|
||||||
"-Wclippy::match-same-arms", |
|
||||||
"-Wclippy::match-wild-err-arm", |
|
||||||
"-Wclippy::match-wildcard-for-single-variants", |
|
||||||
"-Wclippy::maybe-infinite-iter", |
|
||||||
"-Wclippy::mem-forget", |
|
||||||
"-Wclippy::mismatching-type-param-order", |
|
||||||
"-Wclippy::missing-assert-message", |
|
||||||
"-Wclippy::missing-asserts-for-indexing", |
|
||||||
"-Wclippy::missing-enforced-import-renames", |
|
||||||
"-Wclippy::missing-fields-in-debug", |
|
||||||
"-Wclippy::multiple-inherent-impl", |
|
||||||
"-Wclippy::mut-mut", |
|
||||||
"-Wclippy::mutex-atomic", |
|
||||||
"-Wclippy::naive-bytecount", |
|
||||||
"-Wclippy::needless-bitwise-bool", |
|
||||||
"-Wclippy::needless-continue", |
|
||||||
"-Wclippy::needless-for-each", |
|
||||||
"-Wclippy::needless-pass-by-value", |
|
||||||
"-Wclippy::needless-raw-strings", |
|
||||||
"-Wclippy::negative-feature-names", |
|
||||||
"-Wclippy::no-effect-underscore-binding", |
|
||||||
"-Wclippy::no-mangle-with-rust-abi", |
|
||||||
"-Wclippy::non-ascii-literal", |
|
||||||
"-Wclippy::panic", |
|
||||||
"-Wclippy::panic-in-result-fn", |
|
||||||
"-Wclippy::partial-pub-fields", |
|
||||||
"-Wclippy::print-stderr", |
|
||||||
"-Wclippy::print-stdout", |
|
||||||
"-Wclippy::ptr-as-ptr", |
|
||||||
"-Wclippy::ptr-cast-constness", |
|
||||||
"-Wclippy::pub-without-shorthand", |
|
||||||
"-Wclippy::range-minus-one", |
|
||||||
"-Wclippy::range-plus-one", |
|
||||||
"-Wclippy::rc-buffer", |
|
||||||
"-Wclippy::rc-mutex", |
|
||||||
"-Wclippy::redundant-closure-for-method-calls", |
|
||||||
"-Wclippy::redundant-else", |
|
||||||
"-Wclippy::redundant-feature-names", |
|
||||||
"-Wclippy::redundant-type-annotations", |
|
||||||
"-Wclippy::ref-binding-to-reference", |
|
||||||
"-Wclippy::ref-option-ref", |
|
||||||
"-Wclippy::ref-patterns", |
|
||||||
"-Wclippy::rest-pat-in-fully-bound-structs", |
|
||||||
"-Wclippy::return-self-not-must-use", |
|
||||||
"-Wclippy::same-functions-in-if-condition", |
|
||||||
"-Wclippy::same-name-method", |
|
||||||
"-Wclippy::semicolon-inside-block", |
|
||||||
"-Wclippy::shadow-same", |
|
||||||
"-Wclippy::should-panic-without-expect", |
|
||||||
"-Wclippy::single-match-else", |
|
||||||
"-Wclippy::stable-sort-primitive", |
|
||||||
"-Wclippy::str-to-string", |
|
||||||
"-Wclippy::string-add", |
|
||||||
"-Wclippy::string-add-assign", |
|
||||||
"-Wclippy::string-lit-chars-any", |
|
||||||
"-Wclippy::string-to-string", |
|
||||||
"-Wclippy::struct-excessive-bools", |
|
||||||
"-Wclippy::suspicious-xor-used-as-pow", |
|
||||||
"-Wclippy::tests-outside-test-module", |
|
||||||
"-Wclippy::todo", |
|
||||||
"-Wclippy::transmute-ptr-to-ptr", |
|
||||||
"-Wclippy::trivially-copy-pass-by-ref", |
|
||||||
"-Wclippy::try-err", |
|
||||||
"-Wclippy::unchecked-duration-subtraction", |
|
||||||
"-Wclippy::undocumented-unsafe-blocks", |
|
||||||
"-Wclippy::unicode-not-nfc", |
|
||||||
"-Wclippy::unimplemented", |
|
||||||
"-Wclippy::uninlined-format-args", |
|
||||||
"-Wclippy::unnecessary-box-returns", |
|
||||||
"-Wclippy::unnecessary-join", |
|
||||||
"-Wclippy::unnecessary-safety-comment", |
|
||||||
"-Wclippy::unnecessary-safety-doc", |
|
||||||
"-Wclippy::unnecessary-self-imports", |
|
||||||
"-Wclippy::unnecessary-wraps", |
|
||||||
"-Wclippy::unneeded-field-pattern", |
|
||||||
"-Wclippy::unnested-or-patterns", |
|
||||||
"-Wclippy::unreadable-literal", |
|
||||||
"-Wclippy::unsafe-derive-deserialize", |
|
||||||
"-Wclippy::unseparated-literal-suffix", |
|
||||||
"-Wclippy::unused-async", |
|
||||||
"-Wclippy::unused-self", |
|
||||||
"-Wclippy::unwrap-in-result", |
|
||||||
"-Wclippy::use-debug", |
|
||||||
"-Wclippy::used-underscore-binding", |
|
||||||
"-Wclippy::verbose-bit-mask", |
|
||||||
"-Wclippy::verbose-file-reads", |
|
||||||
"-Wclippy::wildcard-dependencies", |
|
||||||
"-Wclippy::zero-sized-map-values", |
|
||||||
"-Wtrivial-casts", |
|
||||||
"-Wtrivial-numeric-casts", |
|
||||||
"-Wunsafe-code", |
|
||||||
"-Wunused-lifetimes", |
|
||||||
"-Wunused-qualifications", |
|
||||||
] |
|
@ -0,0 +1,83 @@ |
|||||||
|
import json |
||||||
|
from pathlib import Path |
||||||
|
from urllib.request import urlopen |
||||||
|
|
||||||
|
import tomlkit |
||||||
|
|
||||||
|
MSRV = "1.74.0" |
||||||
|
LINT_BLACKLIST = { |
||||||
|
"absolute_paths", # TODO: might be nice |
||||||
|
"alloc_instead_of_core", |
||||||
|
"arithmetic_side_effects", # TODO: might be nice |
||||||
|
"as_conversions", |
||||||
|
"big_endian_bytes", |
||||||
|
"cargo_common_metadata", # TODO: might be nice |
||||||
|
"doc_markdown", # Too many false positives |
||||||
|
"default_numeric_fallback", |
||||||
|
"else_if_without_else", |
||||||
|
"exhaustive_enums", |
||||||
|
"exhaustive_structs", |
||||||
|
"float_arithmetic", |
||||||
|
"float_cmp", |
||||||
|
"float_cmp_const", |
||||||
|
"impl_trait_in_params", |
||||||
|
"implicit_return", |
||||||
|
"indexing_slicing", |
||||||
|
"integer_division", |
||||||
|
"little_endian_bytes", |
||||||
|
"map_err_ignore", |
||||||
|
"min_ident_chars", |
||||||
|
"missing_docs_in_private_items", |
||||||
|
"missing_errors_doc", |
||||||
|
"missing_inline_in_public_items", |
||||||
|
"missing_panics_doc", |
||||||
|
"missing_trait_methods", |
||||||
|
"mixed_read_write_in_expression", |
||||||
|
"mod_module_files", |
||||||
|
"module_name_repetitions", |
||||||
|
"modulo_arithmetic", |
||||||
|
"multiple_crate_versions", |
||||||
|
"multiple_unsafe_ops_per_block", |
||||||
|
"must_use_candidate", # TODO: might be nice |
||||||
|
"option_option", |
||||||
|
"pattern_type_mismatch", |
||||||
|
"pub_use", |
||||||
|
"pub_with_shorthand", |
||||||
|
"question_mark_used", |
||||||
|
"self_named_module_files", # TODO: might be nice |
||||||
|
"semicolon_if_nothing_returned", # TODO: might be nice |
||||||
|
"semicolon_outside_block", |
||||||
|
"similar_names", |
||||||
|
"single_call_fn", |
||||||
|
"single_char_lifetime_names", |
||||||
|
"std_instead_of_alloc", |
||||||
|
"std_instead_of_core", |
||||||
|
"shadow_reuse", |
||||||
|
"shadow_unrelated", |
||||||
|
"string_slice", # TODO: might be nice |
||||||
|
"too_many_lines", |
||||||
|
"separated_literal_suffix", |
||||||
|
"unreachable", # TODO: might be nice |
||||||
|
"unwrap_used", # TODO: might be nice to use expect instead |
||||||
|
"wildcard_enum_match_arm", # TODO: might be nice |
||||||
|
"wildcard_imports", # TODO: might be nice |
||||||
|
} |
||||||
|
|
||||||
|
lints = set() |
||||||
|
with urlopen( |
||||||
|
f"https://rust-lang.github.io/rust-clippy/rust-{MSRV}/lints.json" |
||||||
|
) as response: |
||||||
|
for lint in json.load(response): |
||||||
|
if lint["level"] == "allow" and lint["group"] != "nursery": |
||||||
|
lints.add(lint["id"]) |
||||||
|
|
||||||
|
for flag in LINT_BLACKLIST: |
||||||
|
if flag in lints: |
||||||
|
lints.remove(flag) |
||||||
|
else: |
||||||
|
print(f"Unused blacklisted flag: {flag}") |
||||||
|
|
||||||
|
cargo_path = Path(__file__).parent.parent / "Cargo.toml" |
||||||
|
cargo_toml = tomlkit.parse(cargo_path.read_text()) |
||||||
|
cargo_toml["workspace"]["lints"]["clippy"] = {lint: "warn" for lint in sorted(lints)} |
||||||
|
cargo_path.write_text(tomlkit.dumps(cargo_toml)) |
@ -1,90 +0,0 @@ |
|||||||
import json |
|
||||||
from pathlib import Path |
|
||||||
from urllib.request import urlopen |
|
||||||
|
|
||||||
MSRV = "1.74.0" |
|
||||||
DEFAULT_BUILD_FLAGS = { |
|
||||||
"-Wtrivial-casts", |
|
||||||
"-Wtrivial-numeric-casts", |
|
||||||
"-Wunsafe-code", |
|
||||||
"-Wunused-lifetimes", |
|
||||||
"-Wunused-qualifications", |
|
||||||
} |
|
||||||
FLAGS_BLACKLIST = { |
|
||||||
"-Wclippy::absolute-paths", # TODO: might be nice |
|
||||||
"-Wclippy::alloc-instead-of-core", |
|
||||||
"-Wclippy::arithmetic-side-effects", # TODO: might be nice |
|
||||||
"-Wclippy::as-conversions", |
|
||||||
"-Wclippy::big-endian-bytes", |
|
||||||
"-Wclippy::cargo-common-metadata", # TODO: might be nice |
|
||||||
"-Wclippy::doc-markdown", # Too many false positives |
|
||||||
"-Wclippy::default-numeric-fallback", |
|
||||||
"-Wclippy::else-if-without-else", |
|
||||||
"-Wclippy::exhaustive-enums", |
|
||||||
"-Wclippy::exhaustive-structs", |
|
||||||
"-Wclippy::float-arithmetic", |
|
||||||
"-Wclippy::float-cmp", |
|
||||||
"-Wclippy::float-cmp-const", |
|
||||||
"-Wclippy::impl-trait-in-params", |
|
||||||
"-Wclippy::implicit-return", |
|
||||||
"-Wclippy::indexing-slicing", |
|
||||||
"-Wclippy::integer-division", |
|
||||||
"-Wclippy::little-endian-bytes", |
|
||||||
"-Wclippy::map-err-ignore", |
|
||||||
"-Wclippy::min-ident-chars", |
|
||||||
"-Wclippy::missing-docs-in-private-items", |
|
||||||
"-Wclippy::missing-errors-doc", |
|
||||||
"-Wclippy::missing-inline-in-public-items", |
|
||||||
"-Wclippy::missing-panics-doc", |
|
||||||
"-Wclippy::missing-trait-methods", |
|
||||||
"-Wclippy::mixed-read-write-in-expression", |
|
||||||
"-Wclippy::mod-module-files", |
|
||||||
"-Wclippy::module-name-repetitions", |
|
||||||
"-Wclippy::modulo-arithmetic", |
|
||||||
"-Wclippy::multiple-crate-versions", |
|
||||||
"-Wclippy::multiple-unsafe-ops-per-block", |
|
||||||
"-Wclippy::must-use-candidate", # TODO: might be nice |
|
||||||
"-Wclippy::option-option", |
|
||||||
"-Wclippy::pattern-type-mismatch", |
|
||||||
"-Wclippy::pub-use", |
|
||||||
"-Wclippy::pub-with-shorthand", |
|
||||||
"-Wclippy::question-mark-used", |
|
||||||
"-Wclippy::self-named-module-files", # TODO: might be nice |
|
||||||
"-Wclippy::semicolon-if-nothing-returned", # TODO: might be nice |
|
||||||
"-Wclippy::semicolon-outside-block", |
|
||||||
"-Wclippy::similar-names", |
|
||||||
"-Wclippy::single-call-fn", |
|
||||||
"-Wclippy::single-char-lifetime-names", |
|
||||||
"-Wclippy::std-instead-of-alloc", |
|
||||||
"-Wclippy::std-instead-of-core", |
|
||||||
"-Wclippy::shadow-reuse", |
|
||||||
"-Wclippy::shadow-unrelated", |
|
||||||
"-Wclippy::string-slice", # TODO: might be nice |
|
||||||
"-Wclippy::too-many-lines", |
|
||||||
"-Wclippy::separated-literal-suffix", |
|
||||||
"-Wclippy::unreachable", # TODO: might be nice |
|
||||||
"-Wclippy::unwrap-used", # TODO: might be nice to use expect instead |
|
||||||
"-Wclippy::wildcard-enum-match-arm", # TODO: might be nice |
|
||||||
"-Wclippy::wildcard-imports", # TODO: might be nice |
|
||||||
} |
|
||||||
|
|
||||||
build_flags = set(DEFAULT_BUILD_FLAGS) |
|
||||||
with urlopen( |
|
||||||
f"https://rust-lang.github.io/rust-clippy/rust-{MSRV}/lints.json" |
|
||||||
) as response: |
|
||||||
for lint in json.load(response): |
|
||||||
if lint["level"] == "allow" and lint["group"] != "nursery": |
|
||||||
build_flags.add(f"-Wclippy::{lint['id'].replace('_', '-')}") |
|
||||||
|
|
||||||
for flag in FLAGS_BLACKLIST: |
|
||||||
if flag in build_flags: |
|
||||||
build_flags.remove(flag) |
|
||||||
else: |
|
||||||
print(f"Unused blacklisted flag: {flag}") |
|
||||||
|
|
||||||
with (Path(__file__).parent.parent / ".cargo" / "config.toml").open("wt") as fp: |
|
||||||
fp.write("[build]\n") |
|
||||||
fp.write("rustflags = [\n") |
|
||||||
for flag in sorted(build_flags): |
|
||||||
fp.write(f' "{flag}",\n') |
|
||||||
fp.write("]\n") |
|
Loading…
Reference in new issue