Commit Graph

19 Commits

Author SHA1 Message Date
Javi Martín
28aafbd4bc Add and apply Style/InvertibleUnlessCondition rule
This rule was added in rubocop 1.44.0. It's useful to avoid accidental
`unless !condition` clauses.

Note we aren't replacing `unless zero?` with `if nonzero?` because we
never use `nonzero?`; using it sounds like `if !zero?`.

Replacing `unless any?` with `if none?` is only consistent if we also replace
`unless present?` with `if blank?`, so we're also adding this case. For
consistency, we're also replacing `unless blank?` with `if present?`.

We're also simplifying code dealing with `> 0` conditions in order to
make the code (hopefully) easier to understand.

Also for consistency, we're enabling the `Style/InverseMethods` rule,
which follows a similar idea.
2023-09-07 19:14:03 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
aace7aea02 Apply Layout/SpaceAroundOperators rubocop rule
We were a bit inconsistent when aligning equal signs vertically.
2019-10-22 17:37:51 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Javi Martín
53abc57578 Fix Infinity exceptions in hot score calculator
There was a rare case we've found on some Travis builds where the system
time suddenly moved back to the past a couple of tenths of a second,
meaning `Time.current - resource.created_at` returned a negative number,
which lead to a division by zero.
2019-09-10 16:00:21 +02:00
Javi Martín
852d3b0ed6 Extract methods to calculate hot score period 2019-09-10 16:00:21 +02:00
Julian Herrero
002e16ce30 Use double quotes in lib/ 2019-03-15 10:29:07 +01:00
Julian Herrero
ef835bef1c new algorithm for filter 'most active' 2018-12-13 11:42:22 +01:00
Bertocq
f6fe9cc7d2 Fix all Layout/SpaceAroundOperators rubocop issues and remove file list from rubocop_todo list 2017-06-26 18:04:20 +02:00
Bertocq
d759aca522 Fix all Rails/TimeZone rubocop issues and remove files from rubocop_todo list 2017-06-25 15:46:46 +02:00
kikito
f0b8cfd4a2 Time.now -> Time.current 2016-11-23 19:19:19 +01:00
Daniel Baena
f8e1fc70a1 #670 2015-12-11 21:06:27 +01:00
rgarcia
0557300c73 decreases time unit for score calculations 2015-11-18 14:38:51 +01:00
rgarcia
883b9f80b0 increases time unit in score calculations 2015-11-17 10:06:31 +01:00
rgarcia
f7d8b28378 decreases time unit in hot score calculations 2015-11-17 10:02:35 +01:00
rgarcia
c1c9ed6340 increases comment weight on hot scores 2015-11-17 09:57:47 +01:00
rgarcia
d502a64507 increases time units for hot scores 2015-11-17 09:50:50 +01:00
kikito
8f8afdfd62 Proposals hot_score 2015-09-14 20:37:32 +02:00
kikito
47c95078f2 Extract score calculation to a module 2015-09-14 20:36:04 +02:00