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

434 Pylint alerts corrections as part of intervention experiment #439

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

evidencebp
Copy link

Makes the interventions describe in intervention issue.
The experiment is described here.

Each intervention was done in a dedicated commit with a message explaining it.

The PR is still work in progress and created now to present the changes and consult.

The method write_log had 6 nesting levels, while the recommendation is at most 5.
I extracted two nested methods,  _log_entries and in it _handle_source.
The methods extraction also fixed too-many-branches and too-many-statements in that method.
The constructors, that handles many format values, had too many branches.
I extracting handling format 4 into a dedicated method.
Method children had many branches computing the text variable.
I extracted those base on the type value into _handle_type and replaces these branches with a single one, checking if the type is relevant.
Method __new__ of the class WithAttributes had too many branches.
I extracted a static method _handle_bases handing base classes logic.
The function main had 116 statements (more than the recommended limit of 50).
Most code handle different unrelated args so I extracted methods for them.
Remove two unneeded parenthesis
Made two readable line shorter
Function run_length_encoder had 14 branches (limit is 12).
Extracted the _handle_byte function
remove unneeded parenthesis
Function check_time had 7 returns
I kept the return value and return it in the end of the function, avoiding too many point of exit.
Other than the return there is also an exception in case the the type is not supported.
Method render of class LabeledFlowable had 14 branches.
Extracted the method _compute_spillover to structure and reduce branches
 __all__ = ("Hyphenator") while it should be a list (e.g. __all__ = ["Hyphenator"]). Seems like a bug.
https://stackoverflow.com/questions/44834/what-does-all-mean-in-python
Method _spans_to_words of class ParagraphState had 7 nesting levels.
I extracted _process_groups that goes over the groups to reduce that.
Method read_dictionary_or_stream of class PDFObjectReader had 6 nesting levels.
I extracted _handle_filter that takes only the dictionary as a parameter and encapsulates the creation of the stream_filter.
The constructor of AdobeFontMetricsParser had 14 branches.
I extracted _process_line with the content of the loop going over lines.
Code uses from rinoh.styleds import *
This hides the imoported objects and might lead to collisions in the future if objects of the same name are imported with wildcards.

styleds is a collection of imports, aimed to ease related imports.
I copied the used imports from there and deleted the unused ones.

This adds many imports and does not  benefits from styleds, so this is a downside of fixing this alert.
@CLAassistant
Copy link

CLAassistant commented Oct 28, 2024

CLA assistant check
All committers have signed the CLA.

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.

2 participants