-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Pylint alerts corrections as part of an intervention experiment 1230 #1231
Open
evidencebp
wants to merge
87
commits into
sukeesh:master
Choose a base branch
from
evidencebp:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,220
−1,218
Conversation
This file contains 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
Removed unneeded parentheses
Replace if with direct assignment of the condition into the output variable
Function write_agenda had 56 statements while Pylint recommends having at most 50. I extracted the methods check_agenda_file, get_valid_date, and get_valid_time to make the code more structured and solve that.
Function hangman had 67 statements while Pylint recommends having at most 50. I extracted methods to make the code more structured and solve that.
Many returns make the code more complex. Added a score variable in the first case, merged the conditions in the second.
Method organise of class File_Organise had 6 nested-blocks while Pylint recommends having at most 5. I extracted orgnise_directory to make the code more structured and solve that.
Simplified the code by replacing the if in direct assignment of the condition to the result variable.
Catching BaseException might hide unexpected exceptions (e.g., due to new code that will be added). Method get_data of class Memory catches BaseException (line 61) The try section is return self.data[key] BaseException was changed to AttributeError (if there is no member data) and KeyError(if the key is not in data) For details see https://docs.python.org/3/library/exceptions.html#KeyError
Removed unneeded parentheses
Function move had 13 branches while Pylint recommends having at most 12. I extracted methods for the long enough user choices to make the code more structured and solve that.
Catching Exception might hide unexpected exceptions (e.g., due to new code that will be added). Function fruit_nutrition catches Exception (line 59) Exception was changed to ValueError (e.g., in converting age to a number), KeyError (e.g., nutritions['sugar'] if there is no key 'sugar') For details see https://docs.python.org/3/library/exceptions.html#ValueError https://docs.python.org/3/library/exceptions.html#KeyError
The condition had many expressions that made it unclear. Instead, there is a dictionary for winning moves, simplifying and clarifying the condition.
Wildcard imports (import *) make it harder to understand what is imported from where. Removing it is also a defensive programming act, lowering the probability of collisions due to future new imports or objects.
Removed unneeded parentheses
Catching Exception might hide unexpected exceptions (e.g., due to new code that will be added). Method _get_data of class TasteDive catches Exception (line 139) The try section gets a request, formats as json and looks up properties. Exception was changed to requests.RequestException, KeyError, ValueError, json.JSONDecodeError For details see https://docs.python.org/3/library/exceptions.html https://requests.readthedocs.io/en/latest/_modules/requests/exceptions/ https://docs.python.org/3/library/json.html
The if is equivalent to the condition, so it can be removed
Function helloworld had 18 branches while Pylint recommends having at most 12. I extracted methods to make the code more structured and solve that.
Removed unneeded parentheses
Removed unneeded parentheses
Function main had 20 branches while Pylint recommends having at most 12. I extracted methods to make the code more structured and solve that.
"Return output", in the try section, cannot raise exceptions (output was already computed). The exception handling section will not be reached so it is better to remove it.
The return value is the Boolean of the condition so the if can be removed.
Catching Exception might hide unexpected exceptions (e.g., due to new code that will be added). The code catches BaseException (line 23) The try section mainly imports and change a directory Exception was changed to ImportError, OSError For details see https://docs.python.org/3/library/exceptions.html#ImportError, https://docs.python.org/3/library/exceptions.html#OSError
Removed unneeded parentheses
Function flightradar had 6 nested-blocks while Pylint recommends having at most 5. I extracted check_flight_between_destinations to make the code more structured and solve that.
Removed unneeded parentheses
Function main had 14 branches while Pylint recommends having at most 12. I extracted methods to make the code more structured and solve that.
The ifs are not needed. It is simpler to return the condition directly.
Removed unneeded parentheses
Function expression_checker had 23 branches while Pylint recommends having at most 12. Now there are functions for contains_invalid_characters, check_character_progression, and check_bracket_pairs
Method hexToAssembly of class MipsConverter had 63 statements while Pylint recommends having at most 50. ]Method assemblyToHex of class MipsConverter had 114 statements. I extracted methods for handling types in various activities to make the code more structured and solve that.
Made unreadable line shorter
made long line more readable
made long lines more readable
made a long line more readable
made long line more readable
made long line more readable
made long lines shorter
made long lines shorter
made long lines shorter
made long line shorter
made long line more readable
made long line more readable
made long line shorter
made long line more readable
made long lines shorter
made long line more readable
made long lines more readable
made long line more readable
made long line shorter
made long line more readable
made long line more readable
made long line more readable
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.