Skip to content

Commit

Permalink
Merge branch 'master' into freeze-string-literal
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jan 5, 2018
2 parents 0fd10d6 + 3b164d4 commit ac7e731
Show file tree
Hide file tree
Showing 24 changed files with 54 additions and 92 deletions.
4 changes: 0 additions & 4 deletions .rubocop.yml
Expand Up @@ -22,10 +22,6 @@ Style/EmptyMethod:
Style/MutableConstant:
Enabled: false

# See #647
Style/SafeNavigation:
Enabled: false

Style/WordArray:
Exclude:
- 'db/schema.rb'
Expand Down
73 changes: 18 additions & 55 deletions .rubocop_todo.yml
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2017-12-17 21:03:01 +0900 using RuboCop version 0.52.0.
# on 2018-01-05 15:35:35 +1030 using RuboCop version 0.52.1.
# 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
Expand All @@ -14,13 +14,6 @@ Gemspec/OrderedDependencies:
Exclude:
- 'fat_free_crm.gemspec'

# Offense count: 1
# Configuration parameters: Include.
# Include: **/*.gemspec
Gemspec/RequiredRubyVersion:
Exclude:
- 'fat_free_crm.gemspec'

# Offense count: 27
# Cop supports --auto-correct.
Layout/ClosingParenthesisIndentation:
Expand All @@ -35,12 +28,12 @@ Layout/ClosingParenthesisIndentation:
- 'spec/models/polymorphic/version_spec.rb'
- 'spec/views/comments/edit.js.haml_spec.rb'

# Offense count: 21
# Offense count: 16
# Cop supports --auto-correct.
Layout/EmptyLinesAroundArguments:
Exclude:
- 'config/initializers/views.rb'
- 'db/seeds/fields.rb'
- 'app/helpers/accounts_helper.rb'
- 'lib/fat_free_crm/permissions.rb'
- 'spec/features/accounts_spec.rb'
- 'spec/features/admin/groups_spec.rb'
- 'spec/features/admin/users_spec.rb'
Expand Down Expand Up @@ -131,15 +124,6 @@ Layout/SpaceAroundOperators:
- 'app/views/application/show.rss.builder'
- 'app/views/campaigns/index.xls.builder'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: .
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceBeforeBlockBraces:
EnforcedStyle: space
EnforcedStyleForEmptyBraces: space

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Expand Down Expand Up @@ -222,12 +206,11 @@ Lint/UselessAccessModifier:
- 'db/migrate/20100928030620_remove_uuid.rb'
- 'lib/gravatar_image_tag.rb'

# Offense count: 4
# Offense count: 3
Lint/UselessAssignment:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/views/home/index.atom.builder'
- 'lib/fat_free_crm/mail_processor/base.rb'

# Offense count: 130
Metrics/AbcSize:
Expand All @@ -248,7 +231,7 @@ Metrics/BlockNesting:
Metrics/ClassLength:
Max: 195

# Offense count: 30
# Offense count: 29
Metrics/CyclomaticComplexity:
Max: 13

Expand All @@ -260,9 +243,9 @@ Metrics/MethodLength:
# Offense count: 2
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 391
Max: 392

# Offense count: 28
# Offense count: 27
Metrics/PerceivedComplexity:
Max: 15

Expand Down Expand Up @@ -311,14 +294,13 @@ Naming/VariableNumber:
Exclude:
- 'spec/controllers/home_controller_spec.rb'

# Offense count: 4
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect.
Performance/HashEachMethods:
Exclude:
- 'app/controllers/entities/opportunities_controller.rb'
- 'lib/fat_free_crm/errors.rb'
- 'spec/controllers/tasks_controller_spec.rb'

# Offense count: 1
# Cop supports --auto-correct.
Expand Down Expand Up @@ -346,13 +328,12 @@ Security/YAMLLoad:
- 'db/migrate/20120405080742_change_further_subscribed_users_to_set.rb'
- 'lib/tasks/ffcrm/config.rake'

# Offense count: 4
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, conditionals
Style/AndOr:
Exclude:
- 'config/unicorn.rb'
- 'lib/fat_free_crm/mail_processor/base.rb'

# Offense count: 8
Expand All @@ -373,7 +354,8 @@ Style/CaseEquality:
- 'app/models/fields/field.rb'

# Offense count: 18
# Configuration parameters: EnforcedStyle.
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Enabled: false
Expand All @@ -393,14 +375,12 @@ Style/ClassVars:
- 'lib/fat_free_crm/tabs.rb'
- 'lib/fat_free_crm/view_factory.rb'

# Offense count: 7
# Offense count: 3
Style/CommentedKeyword:
Exclude:
- 'app/controllers/entities/leads_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/models/users/authentication.rb'
- 'db/migrate/20100928030617_drop_openid_tables.rb'
- 'lib/fat_free_crm/mail_processor/dropbox.rb'

# Offense count: 13
# Cop supports --auto-correct.
Expand Down Expand Up @@ -463,19 +443,7 @@ Style/FormatString:
Exclude:
- 'spec/factories/shared_factories.rb'

# Offense count: 52
# Configuration parameters: EnforcedStyle.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
Exclude:
- 'app/inputs/date_pair_input.rb'
- 'app/inputs/date_time_input.rb'
- 'app/inputs/datetime_pair_input.rb'
- 'config/locales/th.rb'
- 'spec/models/list_spec.rb'
- 'spec/models/polymorphic/task_spec.rb'

# Offense count: 486
# Offense count: 485
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: when_needed, always, never
Expand All @@ -499,7 +467,7 @@ Style/IdenticalConditionalBranches:
Exclude:
- 'app/helpers/application_helper.rb'

# Offense count: 50
# Offense count: 51
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Enabled: false
Expand Down Expand Up @@ -535,13 +503,9 @@ Style/MethodMissing:
- 'app/models/setting.rb'
- 'lib/fat_free_crm/fields.rb'

# Offense count: 8
# Offense count: 1
Style/MixinUsage:
Exclude:
- 'lib/fat_free_crm/comment_extensions.rb'
- 'lib/fat_free_crm/exportable.rb'
- 'lib/fat_free_crm/fields.rb'
- 'lib/fat_free_crm/permissions.rb'
- 'spec/helpers/fields_helper_spec.rb'

# Offense count: 2
Expand Down Expand Up @@ -601,13 +565,12 @@ Style/ParallelAssignment:
Exclude:
- 'lib/fat_free_crm/core_ext/alias_method_chain.rb'

# Offense count: 100
# Offense count: 98
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Exclude:
- 'app/views/tasks/index.xls.builder'
- 'config/locales/th.rb'
- 'lib/tasks/ffcrm/update_data.rake'
- 'spec/models/fields/field_spec.rb'

Expand Down Expand Up @@ -687,7 +650,7 @@ Style/UnneededInterpolation:
- 'app/views/opportunities/index.xls.builder'
- 'app/views/tasks/index.xls.builder'

# Offense count: 2164
# Offense count: 2157
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,10 +4,12 @@ It does not matter how slowly you go as long as you do not stop.
First they ignore you, then they laugh at you, then they fight you,
then you win. –- Mahatma Gandhi

Unreleased
Fri Jan 5, 2018 (0.16.0)
---------------------------------------------------------------------
- #633 Upgrade to rails 5.1.0
- #641 Swap default server from thin/unicorn to puma
- #631 Clean up locale files
- #612 DEPRECATION WARNING: #table_exists? currently checks both tables and views

Thu Dec 14, 2017 (0.15.0)
---------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -62,7 +62,7 @@ group :development, :test do
gem 'byebug'
gem 'pry-rails' unless ENV["CI"]
gem 'factory_girl_rails', '~> 4.7.0' # 4.8.0+ stubbed models are not allowed to access the database - User#destroyed?()
gem 'rubocop', '~> 0.50.0' # Pinned because upgrades require regenerating rubocop_todo.yml
gem 'rubocop', '~> 0.52.0' # Pinned because upgrades require regenerating rubocop_todo.yml
gem 'rainbow'
end

Expand Down
14 changes: 6 additions & 8 deletions Gemfile.lock
Expand Up @@ -275,8 +275,7 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rainbow (3.0.0)
rake (12.3.0)
ransack (1.8.4)
actionpack (>= 3.0)
Expand Down Expand Up @@ -325,11 +324,11 @@ GEM
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
rubocop (0.50.0)
rubocop (0.52.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0)
parser (>= 2.4.0.2, < 3.0)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 3.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.9.0)
Expand Down Expand Up @@ -381,8 +380,6 @@ GEM
timecop (0.9.1)
tzinfo (1.2.4)
thread_safe (~> 0.1)
tzinfo-data (1.2017.3)
tzinfo (>= 1.0.0)
uglifier (4.0.2)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.3.0)
Expand Down Expand Up @@ -443,6 +440,7 @@ DEPENDENCIES
puma
rails (~> 5.1.0)
rails-controller-testing
rails-i18n
rails-observers
rails3-jquery-autocomplete
rails_12factor
Expand All @@ -457,7 +455,7 @@ DEPENDENCIES
responds_to_parent
rspec-activemodel-mocks
rspec-rails
rubocop (~> 0.50.0)
rubocop (~> 0.52.0)
sass
sass-rails
select2-rails
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -84,7 +84,7 @@ This is the best way to deploy Fat Free CRM if you need to add plugins or make a

## Upgrading from previous versions of Fat Free CRM

Please read the [Release Notes](https://github.com/fatfreecrm/fat_free_crm/blob/master/CHANGELOG) document for more detailed information on upgrading from previous versions.
Please read the [Release Notes](https://github.com/fatfreecrm/fat_free_crm/blob/master/CHANGELOG.md) document for more detailed information on upgrading from previous versions.


## Resources
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/application_controller.rb
Expand Up @@ -24,7 +24,7 @@ def auto_complete
#----------------------------------------------------------------------------
def require_admin_user
require_user
if current_user && !current_user.admin?
unless current_user&.admin?
flash[:notice] = t(:msg_require_admin)
redirect_to root_path
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Expand Up @@ -111,7 +111,7 @@ def set_current_tab(tab = controller_name)
#----------------------------------------------------------------------------
def current_user_session
@current_user_session ||= Authentication.find
if @current_user_session && @current_user_session.record.suspended?
if @current_user_session&.record&.suspended?
@current_user_session = nil
end
@current_user_session
Expand All @@ -120,7 +120,7 @@ def current_user_session
#----------------------------------------------------------------------------
def current_user
unless @current_user
@current_user = (current_user_session && current_user_session.record)
@current_user = (current_user_session&.record)
if @current_user
@current_user.set_individual_locale
@current_user.set_single_access_token
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/authentications_controller.rb
Expand Up @@ -30,7 +30,7 @@ def create
end
redirect_back_or_default root_url
else
if @authentication.user && @authentication.user.awaits_approval?
if @authentication.user&.awaits_approval?
flash[:notice] = t(:msg_account_not_approved)
else
flash[:warning] = t(:msg_invalig_login)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/tasks_controller.rb
Expand Up @@ -125,7 +125,7 @@ def destroy
#----------------------------------------------------------------------------
def complete
@task = Task.tracked_by(current_user).find(params[:id])
@task.update_attributes(completed_at: Time.now, completed_by: current_user.id) if @task
@task&.update_attributes(completed_at: Time.now, completed_by: current_user.id)

# Make sure bucket's div gets hidden if it's the last completed task in the bucket.
if Task.bucket_empty?(params[:bucket], current_user)
Expand All @@ -140,7 +140,7 @@ def complete
#----------------------------------------------------------------------------
def uncomplete
@task = Task.tracked_by(current_user).find(params[:id])
@task.update_attributes(completed_at: nil, completed_by: nil) if @task
@task&.update_attributes(completed_at: nil, completed_by: nil)

# Make sure bucket's div gets hidden if we're deleting last task in the bucket.
if Task.bucket_empty?(params[:bucket], current_user, @view)
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/accounts_helper.rb
Expand Up @@ -27,7 +27,7 @@ def account_summary(account)
# and prepends the currently selected account, if any.
#----------------------------------------------------------------------------
def account_select(options = {})
options[:selected] = (@account && @account.id) || 0
options[:selected] = (@account&.id) || 0
accounts = ([@account] + Account.my.order(:name).limit(25)).compact.uniq
collection_select :account, :id, accounts, :id, :name, options,
"data-placeholder": t(:select_an_account),
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/application_helper.rb
Expand Up @@ -161,8 +161,9 @@ def link_to_close(url)
#----------------------------------------------------------------------------
def link_to_email(email, length = nil, &_block)
name = (length ? truncate(email, length: length) : email)
if Setting.email_dropbox && Setting.email_dropbox[:address].present?
mailto = "#{email}?bcc=#{Setting.email_dropbox[:address]}"
bcc = Setting&.email_dropbox
if bcc && bcc[:address].present?
mailto = "#{email}?bcc=#{bcc[:address]}"
else
mailto = email
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/contacts_helper.rb
Expand Up @@ -12,7 +12,7 @@ def contact_summary(contact)
summary = ['']
summary << contact.title.titleize if contact.title?
summary << contact.department if contact.department?
if contact.account && contact.account.name?
if contact.account&.name?
summary.last += " #{t(:at)} #{contact.account.name}"
end
summary << contact.email if contact.email.present?
Expand Down

0 comments on commit ac7e731

Please sign in to comment.