Skip to content

Add --max-conditions option#3495

Merged
sobolevn merged 8 commits intowemake-services:masterfrom
makridenko:issue-3493
Jul 25, 2025
Merged

Add --max-conditions option#3495
sobolevn merged 8 commits intowemake-services:masterfrom
makridenko:issue-3493

Conversation

@makridenko
Copy link
Copy Markdown
Contributor

@makridenko makridenko commented Jul 23, 2025

Add --max-conditions option

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

closes #3493

Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment thread CHANGELOG.md Outdated

### Features

- Adds `--max-conditions` option
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- Adds `--max-conditions` option
- Adds `--max-conditions` option, #3493

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +162 to +163
- ``max-conditions`` - Maximum number of conditions in a single ``if`` or
``while`` statement.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
- ``max-conditions`` - Maximum number of conditions in a single ``if`` or
``while`` statement.
- ``max-conditions`` - Maximum number of conditions in a single boolop expression.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

This rule is configurable with ``--max-conditions``.
Default:
:str:`wemake_python_styleguide.options.defaults.MAX_CONDITIONS`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add .. versionchanged:: 1.4.0 with a description that we made it configurable.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ede8951) to head (2521dcf).
⚠️ Report is 43 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #3495   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          363       363           
  Lines        12021     12029    +8     
  Branches       819       819           
=========================================
+ Hits         12021     12029    +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Oh, one last thing: please add a test with options(max_conditions=5) to test that it works. You can find many other similar tests.

@makridenko makridenko requested a review from sobolevn July 24, 2025 09:30
Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks!


.. versionadded:: 0.1.0
.. versionchanged:: 0.5.0
.. versionchanged:: 1.4.0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
.. versionchanged:: 1.4.0
.. versionchanged:: 0.5.0
.. versionchanged:: 1.4.0
Added ``--max-conditions`` configuration option.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

"""Testing that expressions counted correctly with custom options."""
tree = parse_ast_tree(mode(code))

option_values = options(max_expressions=5)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This test is a good edition :)
But, it does not test what we do here. Please one more test with max_conditions to the visitor that we are testing.

Copy link
Copy Markdown
Contributor Author

@makridenko makridenko Jul 25, 2025

Choose a reason for hiding this comment

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

@sobolevn thank you for your comment. I also noticed that this test is not working correctly (it should not I gueess), so I removed it and added right test

@makridenko makridenko requested a review from sobolevn July 25, 2025 09:07
Copy link
Copy Markdown
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks!

@sobolevn sobolevn merged commit adc0f0f into wemake-services:master Jul 25, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make WPS222 configurable

2 participants