Commit Graph

29 Commits

Author SHA1 Message Date
Jared Beck 49397aca6f Set rubocop TargetRubyVersion: 2.3 2017-12-10 23:01:21 -05:00
Jared Beck 293bc462f7 Drop support for ruby 2.1
Ruby 2.1 reached EoL on 2017-04-01.
https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/

PT continued to support it for 6 months after EoL.
2017-09-20 04:35:11 -04:00
Jared Beck 33c9285f40 rubocop 0.50.0 (was 0.48.1) 2017-09-18 23:17:13 -04:00
Jared Beck 94b9306647 Finish the conversion to RSpec
- Convert serializers/mixin_json_test.rb to rspec
- Convert functional/thread_safety_test.rb to rspec
- Convert functional/controller_test.rb to rspec
- Move the dummy app from test to spec, delete test dir
2017-06-10 01:45:46 -04:00
Jared Beck 042b69e24f Lint: Disable RSpec/ExampleLength 2017-04-01 01:55:48 -04:00
Jared Beck c9161129c3 Lint: Set TargetRubyVersion to 2.1 2017-03-31 21:45:06 -04:00
Jared Beck e185ae989f Lint: rubocop 0.48.0 (was 0.41.2) 2017-03-31 21:45:02 -04:00
Jared Beck d3a40d9e68 Uninstall rubocop-thread_safety temporarily
It breaks the build because it requires rubocop 0.47, which
we have not upgraded to yet.

I'm not sure how the addition of rubocop-thread_safety passed CI.

I want to try it out, but don't want to upgrade rubocop right now.
2017-03-07 13:27:31 -05:00
Dorian Marié addf066093
adds rutbocop-rspec and rubocop-thread_safety 2017-03-03 13:09:24 -08:00
Jared Beck 9611ca3135 Lint: Disable ClassLength, ModuleLength 2016-11-11 15:28:21 -05:00
Jared Beck bfd5a44de9 Update CI and linter configuration
- ruby 2.3.1 (was 2.3.0)
- Update AR5 gemfile now that rails 5 is out
- Enable travis bundler cache. Hopefully this will speed up travis a bit.
  https://docs.travis-ci.com/user/caching/
- set TargetRubyVersion: 1.9
2016-08-09 01:11:27 -04:00
Jared Beck ad3806fcbb An idea to combat model pollution
Problem
-------

`has_paper_trail` adds too many methods to the ActiveRecord model.

> If I'm counting correctly, installing the paper_trail gem adds 36 instance
> methods and 10 class methods to all of your active record models. Of those
> 46, 13 have a prefix, either "pt_" or "paper_trail_". I don't know what the
> best way to deal with this is. Ideally, we'd add far fewer methods to
> people's models. If we were able to add fewer methods to models, then I
> wouldn't mind prefixing all of them.
> https://github.com/airblade/paper_trail/issues/703

Solution
--------

Add only two methods to the AR model.

1. An instance method `#paper_trail`
2. A class method `.paper_trail`

The instance method would return a `RecordTrail` and the class method would
return a `ClassTrail`. Those names are totally up for debate.

Advantages
----------

- Plain ruby, easy to understand
- Adding new methods to e.g. the `RecordTrail` does not add any methods to
  the AR model.
- Methods privacy is more strongly enforced.
- Enables isolated testing of e.g. `RecordTrail`; it can be constructed with a
  mock AR instance.

Disadvantages
-------------

- Two new classes, though they are simple.
2016-06-06 01:18:31 -04:00
Jared Beck e7b73cc4ba Lint: SpaceAroundOperators: AllowForAlignment: false 2016-04-09 00:31:44 -04:00
Jared Beck 0bb765289e Fix unnecessary lexical scoping
The registration of these two modules does not need to occur,
lexically, within the PaperTrail module.

The only lexical contents of a module should be methods, constants,
and statements which require that specific lexical scope.
2016-04-09 00:21:46 -04:00
Jared Beck 3b73566ef7 Lint: We will not fix Style/ModuleFunction
[ci skip]
2016-04-08 18:16:37 -04:00
Paul Padier bd98129a5b Exclude migration file from Metrics/AbcSize check 2016-04-05 13:03:08 +09:00
Jared Beck 38c4193b4a Lint: Disable Metrics/MethodLength
The number of lines in a method is not a useful metric compared to `AbcSize`.
It's common to have very long methods (> 50 lines) which are quite simple. For
example, a method that returns a long string with only a few interpolations.

[ci skip]
2016-04-01 12:33:22 -04:00
Paul Padier a0b735af61 Only exclude test/ from Metrics/ClassLength check 2016-04-01 11:22:08 -04:00
Jared Beck b14e7719aa Extract private method: reify_associations 2016-03-13 19:27:31 -04:00
Jared Beck 6e2fd6130e Fix indentation in conditionals 2016-03-05 17:30:53 -05:00
Jared Beck b8c9663e33 Configure Style/PredicateName 2016-03-05 17:21:36 -05:00
Jared Beck 8980f08d0e Fix Style/StringLiterals: Use double quotes 2016-03-05 17:07:32 -05:00
Jared Beck ee0b7a6709 Lint: Permit double negation
[ci skip]
2016-02-21 23:12:09 -05:00
Jared Beck 0d7e33eb2e Break long lines in `test` dir 2016-02-15 18:13:45 -05:00
Jared Beck ddf7f45ff4 rubocop 0.37.2 (was 0.35.1) 2016-02-15 16:50:25 -05:00
Jared Beck c97eb17045 Lint: Disable Style/BlockDelimiters 2016-01-18 14:28:12 -05:00
Jared Beck 3a72b7f7c7 Code style: Break long lines 2015-12-13 00:01:40 -05:00
Jared Beck cbce4d361f Run rubocop linter before test suite
Most of the "cops" are wholly or partially disabled at this point.
As offenses are fixed, cops will move from `.rubocop_todo.yml` to
`.rubocop.yml`.

See
https://github.com/bbatsov/rubocop#automatically-generated-configuration
for details.
2015-11-27 21:25:41 -05:00
Jared Beck 7d8775feae Install rubocop 2015-11-01 23:56:15 -05:00