DEV Community

Reek - Find your Code Smells!

Andy Zhao (he/him) on December 28, 2018

I recently found out about Reek from watching Sandi Metz's talk from RailsConf 2016 (great intro to code smells btw). ...
Collapse
 
dstull profile image
Doug Stull

I use it on all my work projects in concert with rubocop. I feel that reek and rubocop are complimentary for the most part; where rubocop cares more about style, and reek cares more about how you code. Where they overlap, I disable one or the other. I also use them during CI for static code analysis through the pre-commit framework, here: pre-commit.com

Collapse
 
sergio profile image
deleteme deleteme

I think there's a bug, it highlighted my entire ~/Work folder...

Collapse
 
ben profile image
Ben Halpern

Looks nice. How does this compare/contrast with other static analysis tools in Ruby?

Collapse
 
rhymes profile image
rhymes

Reek is quite opinionated because it focuses on code smells. It's going to flag lots of stuff in a big codebase like dev.to's but it doesn't hurt :-D

There are overlaps with Rubocop IIRC

See the list of code smells. You're probably going to disable Uncommunicative Name for a while because usually it's a high frequency violation.

It might help getting to fewer issues on codeclimate 🤞🏾

Collapse
 
ozzyogkush profile image
Derek Rosenzweig

I haven't done Ruby in a bit but when I do I'll add this for sure next time I use it in a project.

Collapse
 
chenge profile image
chenge • Edited

Fun, it can be viewed as an expert to learn from. Thanks for share.

Collapse
 
tadaboody profile image
Tomer

Would you look at that.
I'm currently working on a similar tool for python

Tadaboody / good_smell

A linting/refactoring library for python best practices and lesser-known tricks

Good Smell - it makes your code smell good!

A linting/refactoring library for python best practices and lesser-known tricks

Build Status Code style: black PyPi version

Installing:

pip install good_smell 

Usage:

good_smell warn - Print warnings about smells in the code

good_smell warn PATH
good_smell warn --path PATH

Alternativly you can run it through flake8. Smells will be with the code SMLxxx

good_smell fix - Print a fixed version of the code

good_smell fix PATH [STARTING_LINE] [END_LINE]
good_smell fix --path PATH [--starting-line STARTING_LINE] [--end-line END_LINE]

Supported code smells:

Range(len(sequence))

for i in range(len(sequence))
    x = sequence[i]
    do_thing(x,i)

will be fixed to

for i, x in enumerate(sequence)
    do_thing(x,i)

Directly nested for loops

for i in seq_a
    for j in seq_b:
        print(i, j)

to

import itertools
for i, j in itertools.product(seq_a, seq_b):
    print(i, j)

Developing

Clone the repository and run inside it

pip install -e .[dev]

This will install the requirements and…


I'll be looking at this for inspiration. Thanks!