-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Collect preview lint behaviors in separate module #17646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| //! Helpers to test if a specific preview style is enabled or not. | ||
| //! | ||
| //! The motivation for these functions isn't to avoid code duplication but to ease promoting preview behavior | ||
| //! to stable. The challenge with directly checking the `preview` attribute of [`LinterSettings`] is that it is unclear | ||
| //! which specific feature this preview check is for. Having named functions simplifies the promotion: | ||
| //! Simply delete the function and let Rust tell you which checks you have to remove. | ||
|
|
||
| use crate::settings::LinterSettings; | ||
|
|
||
| // https://github.com/astral-sh/ruff/issues/17412 | ||
| // https://github.com/astral-sh/ruff/issues/11934 | ||
| pub(crate) const fn is_semantic_errors_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/16429 | ||
| pub(crate) const fn is_unsupported_syntax_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // Rule-specific behavior | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/17136 | ||
| pub(crate) const fn is_shell_injection_only_trusted_input_enabled( | ||
| settings: &LinterSettings, | ||
| ) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/15541 | ||
| pub(crate) const fn is_suspicious_function_reference_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/7501 | ||
| pub(crate) const fn is_bool_subtype_of_annotation_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/10759 | ||
| pub(crate) const fn is_comprehension_with_min_max_sum_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/12657 | ||
| pub(crate) const fn is_check_comprehensions_in_tuple_call_enabled( | ||
| settings: &LinterSettings, | ||
| ) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/issues/15347 | ||
| pub(crate) const fn is_bad_version_info_in_non_stub_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/12676 | ||
| pub(crate) const fn is_fix_future_annotations_in_stub_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/11074 | ||
| pub(crate) const fn is_only_add_return_none_at_end_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/12796 | ||
| pub(crate) const fn is_simplify_ternary_to_binary_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/16719 | ||
| pub(crate) const fn is_fix_manual_dict_comprehension_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/13919 | ||
| pub(crate) const fn is_fix_manual_list_comprehension_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/11436 | ||
| // https://github.com/astral-sh/ruff/pull/11168 | ||
| pub(crate) const fn is_dunder_init_fix_unused_import_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/15313 | ||
| pub(crate) const fn is_defer_optional_to_up045_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/8473 | ||
| pub(crate) const fn is_unicode_to_unicode_confusables_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/17078 | ||
| pub(crate) const fn is_support_slices_in_literal_concatenation_enabled( | ||
| settings: &LinterSettings, | ||
| ) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/11370 | ||
| pub(crate) const fn is_undefined_export_in_dunder_init_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/14236 | ||
| pub(crate) const fn is_allow_nested_roots_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
|
|
||
| // https://github.com/astral-sh/ruff/pull/17061 | ||
| pub(crate) const fn is_check_file_level_directives_enabled(settings: &LinterSettings) -> bool { | ||
| settings.preview.is_enabled() | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.