Git Product home page Git Product logo

relaxed.ruby.style's Introduction

A more liberal style guide for RuboCop. It comes with a config file that deactivates some of RuboCop's features. It is meant as a less restrictive foundation that you can use directly or base your style discussions on.

Motivation

RuboCop is an amazing tool, still some of its default rules feel overly strict. This might distract you from the helpful messages.

Warning: Does include opinionated style advice.

How to Read this Style Guide

This is not a stand-alone style guide, but a patch applied to bbatsov/ruby-style-guide (the style guide RuboCop is based on).

Usage

Use, copy or inherit from rubocop.yml.

Disabled Cops & Relaxed Style Recommendations

Style/Alias

Disabled rule. Feel free to use the alias keyword when appropriate.

Style/BeginBlock

Disabled rule. Use BEGIN blocks when it makes sense.

Style/BlockDelimiters

Disabled rule. Consider using {} for multi-line blocks.

Style/Documentation

Document your code and/or write a good ReadMe. And good specs. Choose descriptive method and variable names!

Style/DotPosition

Disabled rule. When chaining methods on multiple lines, it is a good idea to put the dots at the end of the lines to indicate that the expression continues on the next line.

Style/DoubleNegation

Disabled rule. Use !!variable to get the boolean value of a variable.

Style/EndBlock

Disabled rule. Use END blocks or `Kernel#at_exit' for code that should be executed when the program quits.

Style/FormatString

Disabled rule. Creating format string can be done using the String#% method.

Style/IfUnlessModifier

Disabled rule. Use or don't use if/unless in modifier style whenever you think it improves code readability.

Style/Lambda

Disabled rule. Use ->(){} or lambda{} to create lambdas.

Style/ModuleFunction

Disabled rule. Prefer extend self over module_function. It uses Ruby's inheritance chain, instead of copying all methods. Less magic! More Info

Style/MultilineBlockChain

Disabled rule. Chain multiple blocks when it makes sense, this promotes a functional programming mindset.

Style/NegatedIf

Disabled rule. Always use if !condition for complex conditions with negations. For simple conditions, for which it also unlikely that an else clause will be added at some later point, it is also OK to use unless condition.

Style/NegatedWhile

Disabled rule. Always use while !condition for complex conditions with negations. For simple conditions, it is also OK to use until condition.

Style/ParallelAssignment

Disabled rule. Parallel assignment can sometimes express the intented logic better than sequential assignment. It is also faster.

Style/PercentLiteralDelimiters

Disabled rule. When creating literals with the % syntax, choose any delimiters that don't interfere with the literal's content.

Style/PerlBackrefs

Disabled rule. It is fine to use the special local variables $1 - $9 to access the contents of your last matched regex groups.

Style/Semicolon

Disabled rule. Usage of semicolons to separate multiple statements is OK.

Style/SignalException

Disabled rule. You are free to choose if you want to raise exceptions with raise or fail.

Style/SingleLineBlockParams

Disabled rule. Don't give your block parameters bad names.

Style/SingleLineMethods

Disabled rule. Single-line methods can be useful for short getter- or setter-like methods, when attr_reader / attr_accessor / attr_writer are not enough anymore.

Style/SpaceBeforeBlockBraces

It is not important if there is a space between a method call and a passed block.

Style/SpaceInsideParens

Disabled rule. Avoid putting spaces inside parentheses, but do it when it improves readability. For example, when using RSpec's expect method.

Style/SpecialGlobalVars

Disabled rule. Refering to two-letter version of special global variables is OK, although not very polite.

Style/StringLiterals

Disabled rule. Deliberately use single or double quoted strings!

Style/TrailingComma

Disabled rule. Use trailing commas in multi-line literals. It makes manipulating the literal easier (reordering, appending, removing) and leads to smaller git diffs. Consider using RuboCop's EnforcedStyleForMultiline: consistent_comma option.

Style/WhileUntilModifier

Disabled rule. Use or don't use while/until in modifier style whenever you think it improves code readability.

Lint/AmbiguousRegexpLiteral

Use regex normally.

Lint/AssignmentInCondition

Disabled rule. Use = for assignments in conditions. Use == for comparisons in conditions.

Metrics

RuboCop's code complexity metrics can be very useful indications, however, they should be discussed, tweaked and activated individually.

Discussion

Other Ruby Style Guides

relaxed.ruby.style's People

Contributors

janlelis avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.