Skip to content

improve maintainability index mi 55.888 -> 91.1844 #2783

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

Conversation

ronnydw
Copy link

@ronnydw ronnydw commented Oct 4, 2020

Describe your change:

This is a POC to demonstrate measuring and improving maintainability (#2128 (comment))

Measured with wily:
Ronnys-MacBook-Pro:Python ronny$ wily diff strings/lower.py
Using default metrics ['maintainability.mi', 'halstead.h1', 'cyclomatic.complexity', 'raw.loc']
Comparing current with b934da4 by Dhruv on 2020-10-04.

╒═══════════════════════════════════════╤═════════════════════════╤═══════════════════╤═════════════════════════╤═════════════════╕
│ File                                  │ Maintainability Index   │ Unique Operands   │ Cyclomatic Complexity   │ Lines of Code   │
╞═══════════════════════════════════════╪═════════════════════════╪═══════════════════╪═════════════════════════╪═════════════════╡
│ strings/lower.py                      │ 55.888 -> 91.1844       │ 3 -> 3            │ 3 -> 7                  │ 26 -> 30        │
├───────────────────────────────────────┼─────────────────────────┼───────────────────┼─────────────────────────┼─────────────────┤

The following changes improved the maintainability index from 55.888 to 91.1844:

  • extracted method for chr(ord(capital) + 32)
  • replace if operator with 2x '<=' by a const CAPITALS and 'in' operator
  • rename 'word' to 'string'
  • remove redundant comments
  • replace doctest comments by real test code

For manacher.py:

  • fix bug: should return '' for input ''
  • add some more tests
  • type-hinting
  • better naming
  • ref to wikipedia
  • maintainability 59.4401 -> 74.4849

@poyea poyea added the hacktoberfest-accepted Accepted to be counted towards Hacktoberfest label Oct 5, 2020
@stale
Copy link

stale bot commented Nov 21, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Nov 21, 2020
@stale
Copy link

stale bot commented Dec 10, 2020

Please reopen this pull request once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to seek help from our Gitter or ping one of the reviewers. Thank you for your contributions!

@stale stale bot closed this Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Accepted to be counted towards Hacktoberfest stale Used to mark an issue or pull request stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants