Skip to content
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

Improve B015 message #8295

Merged
merged 3 commits into from Oct 28, 2023
Merged

Conversation

harupy
Copy link
Contributor

@harupy harupy commented Oct 28, 2023

Summary

Close #8069

Test Plan

cargo test

@@ -32,7 +32,7 @@ impl Violation for UselessComparison {
#[derive_message_formats]
fn message(&self) -> String {
format!(
"Pointless comparison. This comparison does nothing but waste CPU instructions. \
"Pointless comparison. This comparison does nothing. Did you mean to assign a value? \
Either prepend `assert` or remove it."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should now be Otherwise, prepend...

@@ -32,7 +32,7 @@ impl Violation for UselessComparison {
#[derive_message_formats]
fn message(&self) -> String {
format!(
"Pointless comparison. This comparison does nothing but waste CPU instructions. \
"Pointless comparison. This comparison does nothing. Did you mean to assign a value? \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd suggest removing "This comparison does nothing.", it feels redundant.

@charliermarsh
Copy link
Member

Thanks @harupy!

@github-actions
Copy link

github-actions bot commented Oct 28, 2023

PR Check Results

Ecosystem

ℹ️ ecosystem check detected linter changes. (+67 -67 violations, +0 -0 fixes in 41 projects)

apache/airflow (+35 -35 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --select ALL

+ tests/core/test_otel_logger.py:179:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/core/test_otel_logger.py:179:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/core/test_otel_logger.py:198:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/core/test_otel_logger.py:198:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/core/test_otel_logger.py:253:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/core/test_otel_logger.py:253:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/decorators/test_mapped.py:37:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/decorators/test_mapped.py:37:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/decorators/test_mapped.py:38:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/decorators/test_mapped.py:38:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/jobs/test_backfill_job.py:1999:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/jobs/test_backfill_job.py:1999:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/jobs/test_backfill_job.py:2000:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/jobs/test_backfill_job.py:2000:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/jobs/test_backfill_job.py:2001:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/jobs/test_backfill_job.py:2001:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/jobs/test_scheduler_job.py:1906:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/jobs/test_scheduler_job.py:1906:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/jobs/test_scheduler_job.py:3946:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/jobs/test_scheduler_job.py:3946:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/models/test_baseoperator.py:648:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/models/test_baseoperator.py:648:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/models/test_baseoperator.py:656:13: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/models/test_baseoperator.py:656:13: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/models/test_baseoperator.py:658:13: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/models/test_baseoperator.py:658:13: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
... 44 additional changes omitted for project

bokeh/bokeh (+3 -3 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --select ALL

+ tests/unit/bokeh/document/test_callbacks__document.py:314:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/unit/bokeh/document/test_callbacks__document.py:314:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/unit/bokeh/document/test_callbacks__document.py:317:9: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/unit/bokeh/document/test_callbacks__document.py:317:9: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ tests/unit/bokeh/models/test_plots.py:485:13: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- tests/unit/bokeh/models/test_plots.py:485:13: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.

demisto/content (+29 -29 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero

+ Packs/AzureSecurityCenter/Integrations/MicrosoftDefenderForCloudEventCollector/MicrosoftDefenderForCloudEventCollector_test.py:188:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/AzureSecurityCenter/Integrations/MicrosoftDefenderForCloudEventCollector/MicrosoftDefenderForCloudEventCollector_test.py:188:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:434:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:434:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:503:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/AzureWAF/Integrations/AzureWAF/AzureWAF_test.py:503:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:157:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:157:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:159:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:159:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:165:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:165:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:166:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:166:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:167:5: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/Base/Scripts/DBotSuggestClassifierMapping/dbot_suggest_classifier_mapping_test.py:167:5: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/CTIX/Integrations/CTIX/CTIX.py:492:17: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/CTIX/Integrations/CTIX/CTIX.py:492:17: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/CTIX/Integrations/CTIX/CTIX.py:520:17: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
- Packs/CTIX/Integrations/CTIX/CTIX.py:520:17: B015 Pointless comparison. This comparison does nothing but waste CPU instructions. Either prepend `assert` or remove it.
+ Packs/CTIX/Integrations/CTIXv3/CTIXv3.py:808:21: B015 Pointless comparison. Did you mean to assign a value? Otherwise, prepend `assert` or remove it.
... 37 additional changes omitted for project

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
B015 134 67 67 0 0

@charliermarsh charliermarsh merged commit aa90a42 into astral-sh:main Oct 28, 2023
17 checks passed
@charliermarsh charliermarsh added the documentation Improvements or additions to documentation label Oct 28, 2023
@harupy harupy deleted the improve-B015-message branch October 28, 2023 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve message on "useless-comparison" (B015)
2 participants