Skip to content
loading...

Reek - Find your Code Smells!

twitter logo github logo ・1 min read  

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

GitHub logo troessner / reek

Code smell detector for Ruby

reek logo

Code smell detector for Ruby

Table of Contents

Overview

  • Build Status
  • Gem Version
  • Inline docs
  • Code Climate
  • codebeat

Reek 5 is out!

Reek 5 is out and with it a bunch of breaking changes. If you're a new user you can just continue with the quickstart below. If you're a Reek 4 user and would like to upgrade to 5, don't worry, this shouldn't take you more than 10 minutes. Check out our Upgrade Guide.

Quickstart

Reek is a tool that examines Ruby classes, modules and methods and reports any Code Smells it finds.

For an…

I love tools like these, because you can run them and have the computer tell you what code might be problematic. Also:

  • works with Ruby 2.3, 2.4, 2.5
  • little configuration required for Rails
  • easy config in general
  • has a thorough README

I haven't used it much yet, and it seems to be a fairly popular gem. Have you heard of it? What are your thoughts on it?

twitter logo DISCUSS (8)
markdown guide
 

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

 

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.

 

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

 

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

 

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

 

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 🀞🏾

 

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!
 

There is a rule of thumb for ruby professionals: if anything is recommended by Sandy Metz you’d better never ever use it.

Classic DEV Post from Jun 20 '19

Do you use time-tracking for work or for your personal time?

Andy Zhao (he/him) profile image

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

(You can also change font to sans serif, which a lot of folks prefer.) πŸ’–