Skip to content

Commit 4f90075

Browse files
authored
Merge pull request #1106 from denny/fix/new-cops
Fix new cops
2 parents 740ba4d + 3bd7c9d commit 4f90075

File tree

9 files changed

+46
-28
lines changed

9 files changed

+46
-28
lines changed

Gemfile.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -612,24 +612,24 @@ GEM
612612
rspec-core (>= 2, < 4, != 2.12.0)
613613
rss (0.2.9)
614614
rexml
615-
rubocop (1.13.0)
615+
rubocop (1.14.0)
616616
parallel (~> 1.10)
617617
parser (>= 3.0.0.0)
618618
rainbow (>= 2.2.2, < 4.0)
619619
regexp_parser (>= 1.8, < 3.0)
620620
rexml
621-
rubocop-ast (>= 1.2.0, < 2.0)
621+
rubocop-ast (>= 1.5.0, < 2.0)
622622
ruby-progressbar (~> 1.7)
623623
unicode-display_width (>= 1.4.0, < 3.0)
624624
rubocop-ast (1.5.0)
625625
parser (>= 3.0.1.1)
626626
rubocop-performance (1.11.3)
627627
rubocop (>= 1.7.0, < 2.0)
628628
rubocop-ast (>= 0.4.0)
629-
rubocop-rails (2.9.1)
629+
rubocop-rails (2.10.1)
630630
activesupport (>= 4.2.0)
631631
rack (>= 1.1)
632-
rubocop (>= 0.90.0, < 2.0)
632+
rubocop (>= 1.7.0, < 2.0)
633633
rubocop-rspec (2.3.0)
634634
rubocop (~> 1.0)
635635
rubocop-ast (>= 1.1.0)

lib/generators/shiny/plugin/plugin_generator.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def wrap_in_modules( unwrapped_code )
7878
unwrapped_code = unwrapped_code.to_s.strip.gsub( /\s$\n/, '' )
7979
modules.reverse.reduce( unwrapped_code ) do |content, mod|
8080
str = +"module #{mod}\n"
81-
str << content.lines.collect { |line| " #{line}" }.join
81+
str << content.lines.collect { |line| " #{line}" }
82+
.join
8283
str << ( content.present? ? "\nend" : 'end' )
8384
end
8485
end

plugins/ShinyCMS/.rubocop.yml

+26-14
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,31 @@ AllCops:
1717
NewCops: enable
1818
Exclude:
1919
# Not Ruby files (skipping these makes Rubocop run faster)
20-
- ../../app/assets/**/* # main_app
21-
- ../*/app/assets/**/* # plugins
20+
## Main app
2221
- ../../bin/*
2322
- ../../coverage/**/*
2423
- ../../docs/**/*
2524
- ../../log/*
2625
- ../../node_modules/**/*
2726
- ../../public/**/*
28-
- ../../themes/**/*
2927
- ../../tmp/**/*
3028
- ../../tools/*
29+
## Plugins and Themes
30+
- ../*/app/assets/**/*
31+
- ../*/bin/*
32+
- ../*/vendor/**/*
33+
- ../../themes/**/*
3134
# Code autogenerated by ActiveRecord spectacularly fails RuboCop
32-
- ../../db/schema.rb
33-
- ../../db/archived-migrations/*
34-
- ../../db/migrate/* # main_app
35-
- ../*/db/migrate/*.rb # plugins
35+
- ../../db/**/* # main_app
36+
- ../*/db/migrate/* # plugins
3637
# RuboCop also hates this autogenerated data file
3738
- db/demo_site_data.rb
3839

40+
# Turning this off for now; ideally this Gemfile would be mostly empty anyway
41+
Bundler/GemVersion:
42+
Exclude:
43+
- ../../Gemfile
44+
3945
# These are mostly expected to contain long blocks due to their DSLs
4046
Metrics/BlockLength:
4147
Exclude:
@@ -50,14 +56,18 @@ Metrics/BlockLength:
5056
# Spec files with I18n.t calls have long lines. I can live with that.
5157
Layout/LineLength:
5258
Exclude:
53-
- ../../spec/**/*.rb # main_app
54-
- ../*/spec/**/*.rb # plugins
59+
- ../*/spec/**/*.rb
5560

5661
# This config file is easier to understand laid out as it is, not as this cop wants it
5762
Layout/MultilineArrayLineBreaks:
5863
Exclude:
5964
- config/initializers/html_sanitizer.rb
6065

66+
# This looks really inconsistent next to `expect().to`
67+
Layout/SingleLineBlockChain:
68+
Exclude:
69+
- ../*/spec/**/*
70+
6171
# This method is not useless - it allows user registrations to be feature-flagged
6272
Lint/UselessMethodDefinition:
6373
Exclude:
@@ -118,6 +128,10 @@ Rails/ApplicationController:
118128
Exclude:
119129
- app/public/controllers/shinycms/admin/tools/base_controller.rb
120130

131+
# Allow read access to ENV, for now (but better config handling is on the TODO list)
132+
Rails/EnvironmentVariableAccess:
133+
AllowReads: true
134+
121135
# Unused/demo controller in main_app, and 'no content' fallbacks in ShinyPages
122136
Rails/RenderInline:
123137
Exclude:
@@ -141,10 +155,6 @@ RSpec/BeforeAfterAll:
141155
- spec/models/shinycms/theme_spec.rb
142156
- spec/support/faker.rb
143157

144-
# Currently inclined to keep this approach, for readability etc
145-
RSpec/DescribedClassModuleWrapping:
146-
Enabled: false
147-
148158
# This is ignoring config/initializers/inflections.rb (as about half of Rails does)
149159
RSpec/FilePath:
150160
Exclude:
@@ -153,6 +163,8 @@ RSpec/FilePath:
153163
# Disabling these two for now (but open to discussion/persuasion on their merits)
154164
RSpec/ExampleLength:
155165
Enabled: false
166+
167+
# A test should test one thing; it may take more than one expectation to do so (thoroughly)
156168
RSpec/MultipleExpectations:
157169
Enabled: false
158170

@@ -238,6 +250,6 @@ Style/MissingElse:
238250
Style/Copyright:
239251
Enabled: false
240252

241-
# Not every method needs a comment explaining what it does
253+
# Most methods already have names that explain what they do, they don't need a comment as well
242254
Style/DocumentationMethod:
243255
Enabled: false

plugins/ShinyCMS/.rubocop_todo.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
#
55
# ShinyCMS is free software; you can redistribute it and/or modify it under the terms of the GPL (version 2 or later)
66

7-
# File created with `rubocop --auto-gen-config` on 2021-04-08 using RuboCop version 1.12.1
7+
# File created with `rubocop --auto-gen-config` on 2021-05-07 using RuboCop version 1.14.0
88
#
99
# Entries in this file should be removed as the offenses are removed from the code.
1010
#
1111
# This file should be regenerated whenever Rubocop is updated.
1212

13+
# Offense count: 27
14+
RSpec/DescribedClassModuleWrapping:
15+
Enabled: false
16+
1317
# Offense count: 22
1418
RSpec/AnyInstance:
1519
Exclude:
@@ -19,7 +23,7 @@ RSpec/AnyInstance:
1923
- '../ShinyForms/spec/requests/shiny_forms/forms_controller_spec.rb'
2024
- '../ShinyLists/spec/requests/shiny_lists/subscriptions_controller_spec.rb'
2125

22-
# Offense count: 129
26+
# Offense count: 140
2327
# Configuration parameters: AssignmentOnly.
2428
RSpec/InstanceVariable:
2529
Exclude:

plugins/ShinyCMS/app/models/concerns/shinycms/plugins_components.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ def models_with_sitemap_items
3131
end
3232

3333
def models_that_are( method )
34-
💎ify[ with_models.collect { |plugin| plugin.models_that_are method }.flatten.sort_by( &:name ) ]
34+
💎ify[ with_models.collect { |plugin| plugin.models_that_are method }
35+
.flatten.sort_by( &:name ) ]
3536
end
3637

3738
def models_that_include( concern )
38-
💎ify[ with_models.collect { |plugin| plugin.models_that_include concern }.flatten.sort_by( &:name ) ]
39+
💎ify[ with_models.collect { |plugin| plugin.models_that_include concern }
40+
.flatten.sort_by( &:name ) ]
3941
end
4042
end
4143
end

plugins/ShinyCMS/app/models/shinycms/plugin.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def models_that_are( method )
5454
end
5555

5656
def models_that_include( concern )
57-
base_model.descendants.select { |model| model.include?( concern ) }.sort_by( &:name )
57+
base_model.descendants.select { |model| model.include?( concern ) }
58+
.sort_by( &:name )
5859
end
5960

6061
def view_path

plugins/ShinyCMS/app/public/models/concerns/shinycms/has_template.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def add_elements
3232

3333
# Returns a hash of all the elements for this item, to feed to render as local params
3434
def elements_hash
35-
elements.collect { |element| [ element.name.to_sym, ( element.image.presence || element.content ) ] }.to_h
35+
elements.collect { |element| [ element.name.to_sym, ( element.image.presence || element.content ) ] }
36+
.to_h
3637
end
3738
end
3839

plugins/ShinyForms/app/controllers/shiny_forms/admin/forms_controller.rb

-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#
77
# ShinyCMS is free software; you can redistribute it and/or modify it under the terms of the GPL (version 2 or later)
88

9-
require_dependency 'shiny_forms/application_controller'
10-
119
module ShinyForms
1210
# Admin area controller for ShinyForms plugin for ShinyCMS
1311
class Admin::FormsController < AdminController

plugins/ShinySEO/app/assets/config/shiny_seo_manifest.js

-1
This file was deleted.

0 commit comments

Comments
 (0)