Code Challenge 35 - Improve Your Python Code With BetterCodeHub - Review

Posted by PyBites on Mon 11 September 2017 in Challenges • 2 min read

In this article we review last week's Improve Your Python Code With BetterCodeHub code challenge.

Submissions

  • hobojoe1848 submitted his Generic Emailer Script:

    This is a simple script I wrote to automate sending emails from my Gmail account. It’s generic such that I use it in various different programs. When I had BCH analyse the repo I received a score of 7, meaning it failed 3 points. The most obvious to me was the “Write Short Units of Code” test:

    Better Code Hub Score of 7

    The original script that resulted in this score is here

    Tackling this issue had me refactor the entire script after which, BCH gave me a pass and my score jumped to 8:

    Better Code Hub Score of 8

    What a great tool! I’m a big fan of BCH after this!!

  • bbelderbos ran BCH on his small codetips Django REST Framework submission of last week: wow I was amazed to see it got a 9 right off the bat. DRF / Django lets you write quality code!

    I did have to ignore the settings file adding a .bettercodehub.yml file to get to a 10. I also opened another issue to add tests (as the project is < 200 LOC BCH did not complain yet):

    codetips final score

    I also refactored Julian's timezone-list project improving the already nice score of 8 to a 10

    • Before: tzlist begin score

    • Seperating tz conversion into own module, separate from Flask app: tzlist comp balance

    • Added some unittests: tzlist tests

    • Final score: tzlist final score

    I also like BCH: it makes you think about your code and improve it. The tool has a nice design and performs well. I also like the GitHub workflow we learned during this challenge.

  • If you did some work for this challenge, PR it or message us with the details and we'll include it here.


As there is no deadline to these challenges, we will update here when we get more cool submissions for this challenge ...

Just follow our instructions and start coding!

Stay tuned for our next challenge ...


Keep Calm and Code in Python!

-- Bob and Julian

>>> next(PyBites)

Get our 'Become a Better Python Developer' cheat sheet sent straight to your inbox by signing up for our Newsletter: