Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ RUN chown -R app:app /usr/src/app

USER app

RUN cd /usr/src/app && \
rake docs:scrape

VOLUME /code
WORKDIR /code

Expand Down
1 change: 0 additions & 1 deletion config/contents/.gitignore

This file was deleted.

12 changes: 12 additions & 0 deletions config/contents/lint/ambiguous_operator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This cop checks for ambiguous operators in the first argument of a
method invocation without parentheses.

### Example:
array = [1, 2, 3]

# The `*` is interpreted as a splat operator but it could possibly be
# a `*` method invocation (i.e. `do_something.*(array)`).
do_something *array

# With parentheses, there's no ambiguity.
do_something(*array)
11 changes: 11 additions & 0 deletions config/contents/lint/ambiguous_regexp_literal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This cop checks for ambiguous regexp literals in the first argument of
a method invocation without parentheses.

### Example:
# This is interpreted as a method invocation with a regexp literal,
# but it could possibly be `/` method invocations.
# (i.e. `do_something./(pattern)./(i)`)
do_something /pattern/i

# With parentheses, there's no ambiguity.
do_something(/pattern/i)
8 changes: 8 additions & 0 deletions config/contents/lint/block_alignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
This cop checks whether the end keywords are aligned properly for do
end blocks.

### Example:

variable = lambda do |i|
i
end
30 changes: 30 additions & 0 deletions config/contents/lint/circular_argument_reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
This cop checks for circular argument references in optional keyword
arguments and optional ordinal arguments.

This cop mirrors a warning produced by MRI since 2.2.

### Example:
# bad
def bake(pie: pie)
pie.heat_up
end

# good
def bake(pie:)
pie.refrigerate
end

# good
def bake(pie: self.pie)
pie.feed_to(user)
end

# bad
def cook(dry_ingredients = dry_ingredients)
dry_ingredients.reduce(&:+)
end

# good
def cook(dry_ingredients = self.dry_ingredients)
dry_ingredients.combine
end
9 changes: 9 additions & 0 deletions config/contents/lint/condition_position.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This cop checks for conditions that are not on the same line as
if/while/until.

### Example:

if
some_condition
do_something
end
13 changes: 13 additions & 0 deletions config/contents/lint/def_end_alignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This cop checks whether the end keywords of method definitions are
aligned properly.

Two modes are supported through the AlignWith configuration
parameter. If it's set to `start_of_line` (which is the default), the
`end` shall be aligned with the start of the line where the `def`
keyword is. If it's set to `def`, the `end` shall be aligned with the
`def` keyword.

### Example:

private def foo
end
12 changes: 12 additions & 0 deletions config/contents/lint/duplicate_methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This cop checks for duplicated instance (or singleton) method
definitions.

### Example:
# bad
def duplicated
1
end

def duplicated
2
end
6 changes: 6 additions & 0 deletions config/contents/lint/duplicated_key.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This cop checks for duplicated keys in hash literals.

This cop mirrors a warning in Ruby 2.2.

### Example:
hash = { food: 'apple', food: 'orange' }
9 changes: 9 additions & 0 deletions config/contents/lint/each_with_object_argument.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This cop checks if each_with_object is called with an immutable
argument. Since the argument is the object that the given block shall
make calls on to build something based on the enumerable that
each_with_object iterates over, an immutable argument makes no sense.
It's definitely a bug.

### Example:

sum = numbers.each_with_object(0) { |e, a| a += e }
11 changes: 11 additions & 0 deletions config/contents/lint/else_layout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This cop checks for odd else block layout - like
having an expression on the same line as the else keyword,
which is usually a mistake.

### Example:

if something
...
else do_this
do_that
end
5 changes: 5 additions & 0 deletions config/contents/lint/empty_interpolation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This cop checks for empty interpolation.

### Example:

"result is #{}"
27 changes: 27 additions & 0 deletions config/contents/lint/end_alignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This cop checks whether the end keywords are aligned properly.

Three modes are supported through the `AlignWith` configuration
parameter:

If it's set to `keyword` (which is the default), the `end`
shall be aligned with the start of the keyword (if, class, etc.).

If it's set to `variable` the `end` shall be aligned with the
left-hand-side of the variable assignment, if there is one.

If it's set to `start_of_line`, the `end` shall be aligned with the
start of the line where the matching keyword appears.

### Example:
# good
# keyword style
variable = if true
end

# variable style
variable = if true
end

# start_of_line style
puts(if true
end)
10 changes: 10 additions & 0 deletions config/contents/lint/float_out_of_range.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This cop identifies Float literals which are, like, really really really
really really really really really big. Too big. No-one needs Floats
that big. If you need a float that big, something is wrong with you.

### Example:
# bad
float = 3.0e400

# good
float = 42.9
7 changes: 7 additions & 0 deletions config/contents/lint/format_parameter_mismatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
This lint sees if there is a mismatch between the number of
expected fields for format/sprintf/#% and what is actually
passed as arguments.

### Example:

format('A value: %s and another: %i', a_value)
14 changes: 14 additions & 0 deletions config/contents/lint/implicit_string_concatenation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This cop checks for implicit string concatenation of string literals
which are on the same line.

### Example:
# bad
array = ['Item 1' 'Item 2']

# good
array = ['Item 1Item 2']
array = ['Item 1' + 'Item 2']
array = [
'Item 1' \
'Item 2'
]
33 changes: 33 additions & 0 deletions config/contents/lint/ineffective_access_modifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
This cop checks for `private` or `protected` access modifiers which are
applied to a singleton method. These access modifiers do not make
singleton methods private/protected. `private_class_method` can be
used for that.

### Example:
# bad
class C
private

def self.method
puts 'hi'
end
end

# good
class C
def self.method
puts 'hi'
end

private_class_method :method
end

class C
class << self
private

def method
puts 'hi'
end
end
end
14 changes: 14 additions & 0 deletions config/contents/lint/invalid_character_literal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This cop checks for invalid character literals with a non-escaped
whitespace character (e.g. `? `).
However, currently it's unclear whether there's a way to emit this
warning without syntax errors.

$ ruby -w
p(? )
-:1: warning: invalid character syntax; use ?\s
-:1: syntax error, unexpected '?', expecting ')'
p(? )
^

### Example:
p(? )
13 changes: 13 additions & 0 deletions config/contents/lint/literal_in_condition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This cop checks for literals used as the conditions or as
operands in and/or expressions serving as the conditions of
if/while/until.

### Example:

if 20
do_something
end

if some_var && true
do_something
end
5 changes: 5 additions & 0 deletions config/contents/lint/literal_in_interpolation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This cop checks for interpolated literals.

### Example:

"result is #{10}"
10 changes: 10 additions & 0 deletions config/contents/lint/nested_method_definition.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This cop checks for nested method definitions.

### Example:
# `bar` definition actually produces methods in the same scope
# as the outer `foo` method. Furthermore, the `bar` method
# will be redefined every time `foo` is invoked.
def foo
def bar
end
end
14 changes: 14 additions & 0 deletions config/contents/lint/next_without_accumulator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Don't omit the accumulator when calling `next` in a `reduce` block.

### Example:
# bad
result = (1..4).reduce(0) do |acc, i|
next if i.odd?
acc + i
end

# good
result = (1..4).reduce(0) do |acc, i|
next acc if i.odd?
acc + i
end
28 changes: 28 additions & 0 deletions config/contents/lint/non_local_exit_from_iterator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
This cop checks for non-local exit from iterator, without return value.
It warns only when satisfies all of these: `return` doesn't have return
value, the block is preceded by a method chain, the block has arguments,
and the method which receives the block is not `define_method`.

### Example:

class ItemApi
rescue_from ValidationError do |e| # non-iteration block with arg
return message: 'validation error' unless e.errors # allowed
error_array = e.errors.map do |error| # block with method chain
return if error.suppress? # warned
return "#{error.param}: invalid" unless error.message # allowed
"#{error.param}: #{error.message}"
end
message: 'validation error', errors: error_array
end

def update_items
transaction do # block without arguments
return unless update_necessary? # allowed
find_each do |item| # block without method chain
return if item.stock == 0 # false-negative...
item.update!(foobar: true)
end
end
end
end
6 changes: 6 additions & 0 deletions config/contents/lint/parentheses_as_grouped_expression.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Checks for space between a the name of a called method and a left
parenthesis.

### Example:

puts (x + y)
13 changes: 13 additions & 0 deletions config/contents/lint/rand_one.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
This cop checks for `rand(1)` calls.
Such calls always return `0`.

### Example:

# bad
rand 1
Kernel.rand(-1)
rand 1.0
rand(-1.0)

# good
0
14 changes: 14 additions & 0 deletions config/contents/lint/require_parentheses.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This cop checks for expressions where there is a call to a predicate
method with at least one argument, where no parentheses are used around
the parameter list, and a boolean operator, && or ||, is used in the
last argument.

The idea behind warning for these constructs is that the user might
be under the impression that the return value from the method call is
an operand of &&/||.

### Example:

if day.is? :tuesday && month == :jan
...
end
6 changes: 6 additions & 0 deletions config/contents/lint/string_conversion_in_interpolation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
This cop checks for string conversion in string interpolation,
which is redundant.

### Example:

"result is #{something.to_s}"
Loading