Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrades pt 5: Rails 5.2 #866

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
49fa422
Replace poltergeist with apparition; fix failing tests
esoterik Feb 3, 2021
18200f0
Upgrade to ruby 2.7.2
esoterik Feb 6, 2021
2a07151
Upgrade gems to fix deprecation errors; fix failing tests
esoterik Feb 6, 2021
51ac505
Upgrade rubocop to v0.82
esoterik Feb 9, 2021
a47c358
Remove old tasks
esoterik Feb 11, 2021
bea1fe3
Fix rubocop errors
esoterik Feb 11, 2021
a2bf91d
Disable some naming cops inline
esoterik Feb 11, 2021
e245d5a
Disable some rails cops inline
esoterik Feb 11, 2021
44366a8
Disable some Style cops inline
esoterik Feb 11, 2021
bacaafe
Swap paperclip for kt-paperclip; upgrade aws gems
esoterik Feb 9, 2021
ff713fe
Upgrade from factory_bot to factory_girl
esoterik Feb 9, 2021
22be908
Upgrade jbuilder
esoterik Feb 16, 2021
175671d
Remove descriptive statistics gem
esoterik Feb 16, 2021
001705c
Continue FactoryBot upgrade
esoterik Feb 16, 2021
d2ec3f5
Fix pgsearch deprecations
esoterik Feb 16, 2021
db28908
Remove user percentile rank tracking
esoterik Feb 16, 2021
fb47478
Fix failing tests
esoterik Feb 17, 2021
9ecfc7d
More rubocop autofixes
esoterik Feb 18, 2021
1b33d8d
Remove webshims-rails
esoterik Feb 18, 2021
69be899
Remove rails_12factor
esoterik Feb 18, 2021
46306b9
Remove very old image compressor gem
esoterik Feb 18, 2021
3c38c8e
Add missing gem version specifier
esoterik Feb 18, 2021
30eb4ef
Cleanup Gemfile
esoterik Feb 19, 2021
26aba5c
Disable new rubocop cops for now
esoterik Feb 19, 2021
db2c61e
Fix some deprecations
esoterik Feb 20, 2021
11154ac
Initial Rails 5.1 install
esoterik Feb 26, 2021
b1b51a0
Fix image tags, rename CongressMember.filter to .search
esoterik Feb 27, 2021
57c7b84
Fix failing tests
esoterik Feb 27, 2021
bf64835
Finish Rails 5.2 upgrade
esoterik Mar 11, 2021
0cfc10d
Rubocop fixes
esoterik Mar 11, 2021
283f955
Fix asset compilation in dockerfile
esoterik Mar 12, 2021
95efcec
Fix docker entrypoint
esoterik Mar 12, 2021
9ce20e2
Fix rebase error
esoterik Mar 26, 2021
bd6a8a6
Merge branch 'master' into 494_rails_51
esoterik Feb 23, 2022
7fed138
Update mimemagic
esoterik Feb 23, 2022
d075622
Update to rails 5.2.6
esoterik Feb 23, 2022
40434f8
Update node version for Docker
esoterik Feb 23, 2022
e0ef999
Get docker container to build again
esoterik Feb 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
89 changes: 83 additions & 6 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,70 @@
inherit_from: .rubocop_todo.yml

inherit_gem:
rubocop-github:
- config/default.yml
- config/rails.yml
- config/default_edge.yml
- config/rails_edge.yml

AllCops:
TargetRailsVersion: 4.2
TargetRubyVersion: 2.3
TargetRailsVersion: 5.0
TargetRubyVersion: 2.7
NewCops: disable
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'bin/**/*'
- 'vendor/**/*'
- 'features/**/*'

# Handle cops not enabled by default
# Should probably be checked on rubocop version upgrades
# Last checked 02/09/21
# Disables cops marked as unsafe in docs

Layout/SpaceAroundMethodCallOperator:
Enabled: true

Lint/RaiseException:
Enabled: true

Lint/StructNewOverride:
Enabled: true

Style/ExponentialNotation:
Enabled: true

Style/HashEachMethods:
Enabled: false

Style/HashTransformKeys:
Enabled: false

Style/HashTransformValues:
Enabled: false

Performance/AncestorsInclude:
Enabled: false

Performance/BigDecimalWithNumericArgument:
Enabled: true

Performance/RedundantSortBlock:
Enabled: true

Performance/RedundantStringChars:
Enabled: true

Performance/ReverseFirst:
Enabled: true

Performance/SortReverse:
Enabled: true

Performance/Squeeze:
Enabled: true

Performance/StringInclude:
Enabled: true

### Override rubcop-github ###

Expand All @@ -31,7 +85,7 @@ GitHub/RailsControllerRenderPathsExist:
Enabled: false

GitHub/RailsApplicationRecord:
# Doesn't apply to < Rails 5.0, and ignores TargetRailsVersion
# Rails/ApplicationRecord does the same thing
Enabled: false

Lint/Void:
Expand All @@ -43,7 +97,7 @@ Lint/Debugger:
Exclude:
- 'features/step_definitions/debug_steps.rb'

Style/BlockComments:
Lint/AmbiguousBlockAssociation:
Exclude:
- 'spec/**/*'

Expand All @@ -65,7 +119,30 @@ Layout/MultilineHashBraceLayout:
Layout/SpaceAroundOperators:
Enabled: true

Naming/PredicateName:
Exclude:
- 'spec/**/*'

Security/JSONLoad:
Enabled: true
Exclude:
- 'spec/**/*'

Rails/HttpStatus:
EnforcedStyle: 'numeric'

Style/Alias:
Enabled: false

Style/BlockComments:
Exclude:
- 'spec/**/*'

Style/ClassAndModuleChildren:
EnforcedStyle: 'compact'

Style/Documentation:
Enabled: false

Style/NumericLiterals:
MinDigits: 6
186 changes: 186 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 100`
# on 2021-02-11 14:07:46 -0800 using RuboCop version 0.82.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 3
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
# NamePrefix: is_, has_, have_
# ForbiddenPrefixes: is_, has_, have_
# AllowedMethods: is_a?
# MethodDefinitionMacros: define_method, define_singleton_method
Naming/PredicateName:
Exclude:
- 'spec/**/*'

# Offense count: 45
# Configuration parameters: EnforcedStyle.
# SupportedStyles: snake_case, camelCase
Naming/VariableName:
Exclude:
- 'app/controllers/action_page_controller.rb'
- 'app/controllers/admin/action_pages_controller.rb'
- 'app/controllers/admin/mailer_controller.rb'
- 'app/controllers/admin/petitions_controller.rb'
- 'app/controllers/congress_messages_controller.rb'
- 'app/controllers/tools_controller.rb'
- 'app/controllers/users_controller.rb'
- 'app/controllers/welcome_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/devise_helper.rb'
- 'app/mailers/user_mailer.rb'
- 'app/models/markdown_renderer.rb'
- 'app/views/action_page/index.atom.builder'
- 'app/views/action_page/index.json.jbuilder'
- 'spec/controllers/action_page_controller_spec.rb'
- 'spec/controllers/admin/institutions_controller_spec.rb'

# Offense count: 2
# Cop supports --auto-correct.
Rails/ApplicationController:
Exclude:
- 'app/controllers/exceptions_controller.rb'
- 'spec/controllers/concerns/request_origin_validation_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Rails/ApplicationMailer:
Exclude:
- 'app/mailers/user_mailer.rb'

# Offense count: 29
# Cop supports --auto-correct.
Rails/ApplicationRecord:
Exclude:
- 'app/models/action_institution.rb'
- 'app/models/action_page.rb'
- 'app/models/affiliation.rb'
- 'app/models/affiliation_type.rb'
- 'app/models/ahoy/event.rb'
- 'app/models/bounce.rb'
- 'app/models/call_campaign.rb'
- 'app/models/category.rb'
- 'app/models/complaint.rb'
- 'app/models/congress_member.rb'
- 'app/models/congress_message_campaign.rb'
- 'app/models/congress_scorecard.rb'
- 'app/models/email_campaign.rb'
- 'app/models/featured_action_page.rb'
- 'app/models/institution.rb'
- 'app/models/partner.rb'
- 'app/models/partnership.rb'
- 'app/models/petition.rb'
- 'app/models/signature.rb'
- 'app/models/source_file.rb'
- 'app/models/subscription.rb'
- 'app/models/topic.rb'
- 'app/models/topic_category.rb'
- 'app/models/topic_set.rb'
- 'app/models/tweet.rb'
- 'app/models/tweet_target.rb'
- 'app/models/user.rb'
- 'app/models/user_preference.rb'
- 'app/models/visit.rb'

# Offense count: 2
# Configuration parameters: EnforcedStyle.
# SupportedStyles: slashes, arguments
Rails/FilePath:
Exclude:
- 'lib/tasks/webshims_asset_compile.rake'

# Offense count: 25
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/HasManyOrHasOneDependent:
Exclude:
- 'app/models/action_page.rb'
- 'app/models/affiliation_type.rb'
- 'app/models/call_campaign.rb'
- 'app/models/congress_message_campaign.rb'
- 'app/models/email_campaign.rb'
- 'app/models/institution.rb'
- 'app/models/partner.rb'
- 'app/models/petition.rb'
- 'app/models/signature.rb'
- 'app/models/topic_category.rb'
- 'app/models/tweet.rb'
- 'app/models/user.rb'
- 'app/models/visit.rb'

# Offense count: 15
# Configuration parameters: Include.
# Include: app/helpers/**/*.rb
Rails/HelperInstanceVariable:
Exclude:
- 'app/helpers/action_page_helper.rb'
- 'app/helpers/application_helper.rb'
- 'app/helpers/devise_helper.rb'
- 'app/helpers/petition_helper.rb'

# Offense count: 6
# Configuration parameters: Include.
# Include: app/controllers/**/*.rb
Rails/LexicallyScopedActionFilter:
Exclude:
- 'app/controllers/admin/action_pages_controller.rb'
- 'app/controllers/admin/partners_controller.rb'
- 'app/controllers/petition_controller.rb'
- 'app/controllers/sessions_controller.rb'
- 'app/controllers/tools_controller.rb'

# Offense count: 3
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/UniqueValidationWithoutIndex:
Exclude:
- 'app/models/congress_member.rb'
- 'app/models/institution.rb'
- 'app/models/partner.rb'

# Offense count: 1
Security/Open:
Exclude:
- 'lib/related_content.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'app/models/ahoy/event.rb'
- 'lib/monkey_patches/octet_stream_override.rb'

# Offense count: 17
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'app/controllers/action_page_controller.rb'
- 'app/controllers/admin/action_pages_controller.rb'
- 'app/controllers/application_controller.rb'
- 'app/controllers/concerns/action_page_display.rb'
- 'app/controllers/concerns/request_origin_validation.rb'
- 'app/controllers/congress_messages_controller.rb'
- 'app/controllers/partners_controller.rb'
- 'app/controllers/registrations_controller.rb'
- 'app/controllers/sessions_controller.rb'
- 'app/controllers/tools_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/models/ahoy/event.rb'
- 'lib/call_tool.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
# SupportedStyles: predicate, comparison
Style/NumericPredicate:
Exclude:
- 'spec/**/*'
- 'app/controllers/tools_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/models/action_page.rb'
- 'app/models/petition.rb'
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.5
2.7.2
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ before_script:
- npm install
- cp config/database.yml.travis config/database.yml
- psql -c 'create database travis_ci_test;' -U postgres
- RAILS_ENV=test bundle exec rails webdrivers:chromedriver:update
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
script:
- bundle exec rubocop
- $(npm bin)/sass-lint -vq
Expand Down
13 changes: 6 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:2.5-stretch
FROM ruby:2.7-slim

RUN mkdir /opt/actioncenter
WORKDIR /opt/actioncenter
Expand All @@ -13,16 +13,15 @@ RUN apt-get update && \
postgresql-client \
cron \
gnupg \
libssl-dev
libssl-dev \
shared-mime-info

RUN set -x; \
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh \
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh \
&& chmod +x nodesource_setup.sh \
&& ./nodesource_setup.sh \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
nodejs \
npm \
&& apt-get install -y nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Expand Down Expand Up @@ -65,8 +64,8 @@ RUN bundle exec rake assets:precompile \
SECRET_KEY_BASE=noop \
devise_secret_key=noop \
amazon_region=noop \
amazon_bucket=noop \
DATABASE_URL=postgres://noop
RUN bundle exec rake webshims:update_public

RUN mkdir /opt/actioncenter/log \
/var/www
Expand Down
Loading