From 3afbd8b82c2d7539d9f2009c9a13d05da9cdd595 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 13:48:23 -0700 Subject: [PATCH 01/54] Add rubocop - Add `.rubocop.yml` + `.rubocop_todo.yml` following instructions in https://rubocop.readthedocs.io/en/latest/configuration/#automatically-generated-configuration - Add rake task for rubocop --- .rubocop.yml | 1 + .rubocop_todo.yml | 880 ++++++++++++++++++++++++++++++++++++++++++++++ Gemfile | 2 + Gemfile.lock | 14 + Rakefile | 8 + 5 files changed, 905 insertions(+) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..cc32da4b9 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1 @@ +inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..9f3eb3e20 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,880 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-03-22 16:26:38 -0700 using RuboCop version 0.54.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 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'devise_token_auth.gemspec' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Layout/AlignParameters: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/rails/routes.rb' + - 'test/dummy/app/models/nice_user.rb' + - 'test/dummy/app/models/scoped_user.rb' + - 'test/dummy/app/models/unregisterable_user.rb' + - 'test/dummy/config.ru' + - 'test/dummy/config/initializers/omniauth.rb' + - 'test/dummy/config/routes.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/CommentIndentation: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + +# Offense count: 24 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'Rakefile' + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/engine.rb' + - 'lib/devise_token_auth/url.rb' + - 'test/dummy/app/controllers/custom/passwords_controller.rb' + - 'test/dummy/app/helpers/application_helper.rb' + - 'test/dummy/config/routes.rb' + - 'test/lib/generators/devise_token_auth/install_generator_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundAccessModifier: + Exclude: + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'test/controllers/devise_token_auth/passwords_controller_test.rb' + - 'test/dummy/db/schema.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/sessions_controller.rb' + - 'test/dummy/app/controllers/custom/confirmations_controller.rb' + - 'test/dummy/app/controllers/custom/passwords_controller.rb' + - 'test/dummy/app/controllers/custom/registrations_controller.rb' + - 'test/dummy/app/controllers/custom/sessions_controller.rb' + - 'test/dummy/app/controllers/custom/token_validations_controller.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundMethodBody: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'test/dummy/app/models/user.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/devise_token_auth/url.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'Guardfile' + - 'test/dummy/bin/rails' + - 'test/dummy/config.ru' + - 'test/dummy/config/environments/test.rb' + - 'test/dummy/config/initializers/omniauth.rb' + - 'test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/IndentArray: + EnforcedStyle: consistent + +# Offense count: 14 +# Cop supports --auto-correct. +# Configuration parameters: IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/IndentHash: + EnforcedStyle: consistent + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, rails +Layout/IndentationConsistency: + Exclude: + - 'test/dummy/tmp/generators/config/routes.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/sessions_controller.rb' + - 'test/dummy/tmp/generators/config/routes.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/InitialIndentation: + Exclude: + - 'test/dummy/tmp/generators/config/routes.rb' + +# Offense count: 20 +# Cop supports --auto-correct. +Layout/LeadingCommentSpace: + Exclude: + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'test/dummy/config/initializers/devise_token_auth.rb' + - 'test/dummy/config/initializers/figaro.rb' + - 'test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb' + - 'test/dummy/tmp/history.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Layout/MultilineBlockLayout: + Exclude: + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/SpaceAfterColon: + Exclude: + - 'app/controllers/devise_token_auth/sessions_controller.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Exclude: + - 'app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb' + - 'lib/devise_token_auth/url.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/controllers/helpers.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceAroundOperators: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + - 'test/dummy/app/controllers/overrides/sessions_controller.rb' + - 'test/dummy/app/models/user.rb' + - 'test/dummy/config/environments/test.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'lib/devise_token_auth/rails/routes.rb' + - 'test/dummy/app/models/user.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'config/initializers/devise.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'lib/devise_token_auth/rails/routes.rb' + - 'test/lib/generators/devise_token_auth/install_generator_test.rb' + +# Offense count: 25 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'app/controllers/devise_token_auth/confirmations_controller.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/engine.rb' + - 'lib/devise_token_auth/rails/routes.rb' + - 'test/dummy/app/controllers/custom/passwords_controller.rb' + - 'test/dummy/app/controllers/custom/registrations_controller.rb' + - 'test/dummy/app/controllers/custom/sessions_controller.rb' + - 'test/dummy/app/controllers/custom/token_validations_controller.rb' + - 'test/lib/devise_token_auth/url_test.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceInsideStringInterpolation: + Exclude: + - 'lib/devise_token_auth/controllers/helpers.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingBlankLines: + Exclude: + - 'app/validators/email_validator.rb' + - 'test/dummy/config/initializers/cookies_serializer.rb' + - 'test/dummy/lib/migration_database_helper.rb' + - 'test/integration/navigation_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/TrailingWhitespace: + Exclude: + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 1 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'test/models/user_test.rb' + +# Offense count: 1 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'test/dummy/bin/spring' + +# Offense count: 1 +Lint/DuplicateMethods: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 2 +Lint/HandleExceptions: + Exclude: + - 'test/dummy/bin/rails' + - 'test/dummy/bin/rake' + +# Offense count: 1 +Lint/IneffectiveAccessModifier: + Exclude: + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/StringConversionInInterpolation: + Exclude: + - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + - 'test/controllers/devise_token_auth/sessions_controller_test.rb' + - 'test/dummy/app/controllers/custom/registrations_controller.rb' + - 'test/dummy/config/initializers/omniauth.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'lib/devise_token_auth/engine.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 3 +Lint/UriEscapeUnescape: + Exclude: + - 'test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb' + - 'test/controllers/devise_token_auth/registrations_controller_test.rb' + - 'test/controllers/overrides/confirmations_controller_test.rb' + +# Offense count: 3 +# Configuration parameters: CheckForMethodsWithNoSideEffects. +Lint/Void: + Exclude: + - 'test/dummy/tmp/history.rb' + +# Offense count: 35 +Metrics/AbcSize: + Max: 74 + +# Offense count: 94 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 696 + +# Offense count: 14 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 698 + +# Offense count: 14 +Metrics/CyclomaticComplexity: + Max: 17 + +# Offense count: 36 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 63 + +# Offense count: 2 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 1037 + +# Offense count: 13 +Metrics/PerceivedComplexity: + Max: 19 + +# Offense count: 5 +Naming/AccessorMethodName: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/sessions_controller.rb' + - 'lib/devise_token_auth/rails/routes.rb' + - 'test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb' + +# Offense count: 2 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'spec/**/*' + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 2 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: io, id, to +Naming/UncommunicativeMethodParamName: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: MaxKeyValuePairs. +Performance/RedundantMerge: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'app/validators/email_validator.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/StringReplacement: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'lib/devise_token_auth/rails/routes.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'test/dummy/app/controllers/overrides/confirmations_controller.rb' + - 'test/dummy/app/controllers/overrides/passwords_controller.rb' + - 'test/dummy/app/controllers/overrides/sessions_controller.rb' + - 'test/dummy/app/models/user.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: percent_q, bare_percent +Style/BarePercentLiterals: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'test/controllers/devise_token_auth/passwords_controller_test.rb' + - 'test/lib/generators/devise_token_auth/install_generator_test.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/registrations_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb' + - 'test/dummy/app/controllers/overrides/passwords_controller.rb' + +# Offense count: 34 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'lib/devise_token_auth/engine.rb' + - 'lib/devise_token_auth/rails/routes.rb' + +# Offense count: 2 +Style/CommentedKeyword: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' + - 'app/controllers/devise_token_auth/registrations_controller.rb' + +# Offense count: 2 +Style/DateTime: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + +# Offense count: 24 +Style/Documentation: + Enabled: false + +# Offense count: 3 +Style/DoubleNegation: + Exclude: + - 'lib/devise_token_auth/url.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/EachWithObject: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'lib/devise_token_auth/controllers/url_helpers.rb' + +# Offense count: 19 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'Rakefile' + - 'bin/rails' + - 'devise_token_auth.gemspec' + - 'lib/generators/devise_token_auth/install_generator.rb' + - 'lib/generators/devise_token_auth/install_views_generator.rb' + - 'test/dummy/Rakefile' + - 'test/dummy/bin/bundle' + - 'test/dummy/bin/rails' + - 'test/dummy/bin/rake' + - 'test/dummy/config/application.rb' + - 'test/dummy/config/boot.rb' + - 'test/dummy/config/environment.rb' + - 'test/test_helper.rb' + +# Offense count: 130 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: when_needed, always, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 12 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'app/controllers/devise_token_auth/confirmations_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'app/validators/email_validator.rb' + - 'test/dummy/app/controllers/overrides/confirmations_controller.rb' + - 'test/dummy/app/controllers/overrides/passwords_controller.rb' + - 'test/dummy/app/models/user.rb' + - 'test/test_helper.rb' + +# Offense count: 127 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +Style/HashSyntax: + Enabled: false + +# Offense count: 23 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' + - 'app/controllers/devise_token_auth/confirmations_controller.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/registrations_controller.rb' + - 'app/controllers/devise_token_auth/sessions_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'app/validators/email_validator.rb' + - 'lib/devise_token_auth/controllers/helpers.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Exclude: + - 'lib/generators/devise_token_auth/install_generator.rb' + - 'test/dummy/app/controllers/overrides/sessions_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'test/models/user_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Exclude: + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/registrations_controller.rb' + +# Offense count: 9 +Style/MixinUsage: + Exclude: + - 'test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb' + - 'test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb' + - 'test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb' + - 'test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb' + - 'test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb' + - 'test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb' + - 'test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb' + - 'test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb' + - 'test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/MultilineIfModifier: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + +# Offense count: 2 +Style/MultilineTernaryOperator: + Exclude: + - 'test/dummy/config/environments/test.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'lib/devise_token_auth/version.rb' + - 'test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb' + - 'test/dummy/app/controllers/overrides/passwords_controller.rb' + - 'test/dummy/app/controllers/overrides/registrations_controller.rb' + - 'test/dummy/app/controllers/overrides/sessions_controller.rb' + - 'test/dummy/app/controllers/overrides/token_validations_controller.rb' + - 'test/dummy/app/helpers/application_helper.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'app/controllers/devise_token_auth/sessions_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Not: + Exclude: + - 'test/dummy/app/controllers/overrides/sessions_controller.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: Strict. +Style/NumericLiterals: + MinDigits: 15 + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'app/controllers/devise_token_auth/confirmations_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'test/dummy/app/models/user.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment. +Style/ParenthesesAroundCondition: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/url.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'test/lib/generators/devise_token_auth/install_generator_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'app/controllers/devise_token_auth/registrations_controller.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: . +# SupportedStyles: compact, exploded +Style/RaiseArgs: + EnforcedStyle: compact + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/sessions_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/url.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/engine.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RescueModifier: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. +# Whitelist: present?, blank?, presence, try +Style/SafeNavigation: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/controllers/devise_token_auth/confirmations_controller.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/engine.rb' + - 'test/dummy/app/controllers/overrides/confirmations_controller.rb' + - 'test/dummy/app/controllers/overrides/passwords_controller.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfMethodIsEmpty. +Style/SingleLineMethods: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + Exclude: + - 'devise_token_auth.gemspec' + +# Offense count: 1487 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 24 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + Enabled: false + +# Offense count: 10 +# Cop supports --auto-correct. +Style/SymbolLiteral: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/engine.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex +Style/TernaryParentheses: + Exclude: + - 'lib/generators/devise_token_auth/install_generator.rb' + - 'test/lib/generators/devise_token_auth/install_generator_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/UnlessElse: + Exclude: + - 'app/controllers/devise_token_auth/registrations_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/UnneededInterpolation: + Exclude: + - 'lib/devise_token_auth/rails/routes.rb' + - 'lib/devise_token_auth/url.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/UnneededPercentQ: + Exclude: + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + Exclude: + - 'Rakefile' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'test/dummy/db/schema.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' + +# Offense count: 329 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 189 diff --git a/Gemfile b/Gemfile index 65bf5e16f..b55a5d1d5 100644 --- a/Gemfile +++ b/Gemfile @@ -35,6 +35,8 @@ group :development, :test do gem 'mocha' gem 'pry' gem 'pry-remote' + + gem 'rubocop', require: false end # code coverage, metrics diff --git a/Gemfile.lock b/Gemfile.lock index 55cc5c72c..d0c2a050e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,6 +85,7 @@ GEM rake thor (>= 0.14.0) arel (8.0.0) + ast (2.4.0) attr_encrypted (3.0.3) encryptor (~> 3.0.0) bcrypt (3.1.11) @@ -193,7 +194,11 @@ GEM oauth2 (~> 1.0) omniauth (~> 1.2) orm_adapter (0.5.0) + parallel (1.12.1) + parser (2.5.0.4) + ast (~> 2.4.0) pg (0.20.0) + powerpack (0.1.1) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -243,6 +248,13 @@ GEM actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) retriable (2.1.0) + rubocop (0.54.0) + parallel (~> 1.10) + parser (>= 2.5) + powerpack (~> 0.1) + rainbow (>= 2.2.2, < 4.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) ruby_dep (1.5.0) sawyer (0.8.1) @@ -267,6 +279,7 @@ GEM thread_safe (0.3.6) tzinfo (1.2.4) thread_safe (~> 0.1) + unicode-display_width (1.3.0) warden (1.2.7) rack (>= 1.0) websocket-driver (0.6.5) @@ -301,6 +314,7 @@ DEPENDENCIES pry-remote rack-cors rails-controller-testing + rubocop sqlite3 (~> 1.3) thor diff --git a/Rakefile b/Rakefile index 1ece77e55..cc8a4b7ea 100644 --- a/Rakefile +++ b/Rakefile @@ -33,3 +33,11 @@ end task default: :test + +require 'rubocop/rake_task' + +desc 'Run RuboCop' +RuboCop::RakeTask.new(:rubocop) do |task| + task.formatters = ['fuubar', 'offenses', 'worst'] + task.fail_on_error = false # don't abort rake on failure +end From ee29d0ae5eb25eddc45d88164f73a69b27dc550e Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 13:48:44 -0700 Subject: [PATCH 02/54] Exclude some paths from rubocop analysis, at least for now. --- .rubocop.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index cc32da4b9..d82935a3e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1 +1,5 @@ inherit_from: .rubocop_todo.yml + +AllCops: + Exclude: + - 'coverage/**/*' From 4557afda2b8a21387b938e322757b88d28ada305 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 13:59:30 -0700 Subject: [PATCH 03/54] Adding `.erb` extension to template. - Rubocop complained about invalid ruby; since the file is technically erb and _not_ ruby, the extension should reflect that anyway. --- lib/generators/devise_token_auth/install_generator.rb | 2 +- .../devise_token_auth/templates/{user.rb => user.rb.erb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lib/generators/devise_token_auth/templates/{user.rb => user.rb.erb} (100%) diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index 17b592593..aaa8fc916 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -25,7 +25,7 @@ def copy_migrations def create_user_model fname = "app/models/#{ user_class.underscore }.rb" unless File.exist?(File.join(destination_root, fname)) - template("user.rb", fname) + template("user.rb.erb", fname) else inclusion = "include DeviseTokenAuth::Concerns::User" unless parse_file_for_line(fname, inclusion) diff --git a/lib/generators/devise_token_auth/templates/user.rb b/lib/generators/devise_token_auth/templates/user.rb.erb similarity index 100% rename from lib/generators/devise_token_auth/templates/user.rb rename to lib/generators/devise_token_auth/templates/user.rb.erb From 7419927e211241f3420d3d3eb35a1e529ef49103 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 17:10:11 -0700 Subject: [PATCH 04/54] Fix `Layout/EmptyLines` - Remove empty lines per `Layout/EmptyLines` Cop. - Remove empty lines per `Layout/EmptyLines` Cop from test-dummy rails app. - Remove `Layout/EmptyLines` Cop from todo list. --- .rubocop_todo.yml | 14 -------------- Rakefile | 3 --- .../concerns/set_user_by_token.rb | 1 - app/models/devise_token_auth/concerns/user.rb | 5 ----- lib/devise_token_auth/engine.rb | 2 -- lib/devise_token_auth/url.rb | 1 - test/controllers/demo_user_controller_test.rb | 2 -- .../app/controllers/custom/passwords_controller.rb | 1 - test/dummy/app/helpers/application_helper.rb | 9 --------- test/dummy/config/routes.rb | 1 - .../devise_token_auth/install_generator_test.rb | 1 - .../install_generator_with_namespace_test.rb | 1 - 12 files changed, 41 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9f3eb3e20..1718e9f35 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -42,20 +42,6 @@ Layout/EmptyLineBetweenDefs: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 24 -# Cop supports --auto-correct. -Layout/EmptyLines: - Exclude: - - 'Rakefile' - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/engine.rb' - - 'lib/devise_token_auth/url.rb' - - 'test/dummy/app/controllers/custom/passwords_controller.rb' - - 'test/dummy/app/helpers/application_helper.rb' - - 'test/dummy/config/routes.rb' - - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - # Offense count: 1 # Cop supports --auto-correct. Layout/EmptyLinesAroundAccessModifier: diff --git a/Rakefile b/Rakefile index cc8a4b7ea..73a3fa367 100644 --- a/Rakefile +++ b/Rakefile @@ -17,8 +17,6 @@ end APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) load 'rails/tasks/engine.rake' - - Bundler::GemHelper.install_tasks require 'rake/testtask' @@ -31,7 +29,6 @@ Rake::TestTask.new(:test) do |t| t.warning = false end - task default: :test require 'rubocop/rake_task' diff --git a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb index 3eefae950..384b7e8c4 100644 --- a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +++ b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb @@ -157,7 +157,6 @@ def update_auth_header private - def is_batch_request?(user, client_id) !params[:unbatch] && user.tokens[client_id] && diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index bb009ea81..847b582bc 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -115,7 +115,6 @@ def database_exists? end end - def valid_token?(token, client_id='default') return false unless tokens[client_id] return true if token_is_current?(token, client_id) @@ -125,12 +124,10 @@ def valid_token?(token, client_id='default') return false end - # this must be done from the controller so that additional params # can be passed on from the client def send_confirmation_notification?; false; end - def token_is_current?(token, client_id) # ghetto HashWithIndifferentAccess expiry = tokens[client_id]['expiry'] || tokens[client_id][:expiry] @@ -148,7 +145,6 @@ def token_is_current?(token, client_id) ) end - # allow batch requests to use the previous token def token_can_be_reused?(token, client_id) # ghetto HashWithIndifferentAccess @@ -167,7 +163,6 @@ def token_can_be_reused?(token, client_id) ) end - # update user's auth token (should happen on each request) def create_new_auth_token(client_id=nil) now = Time.zone.now diff --git a/lib/devise_token_auth/engine.rb b/lib/devise_token_auth/engine.rb index a47ef307a..aebf81bf6 100644 --- a/lib/devise_token_auth/engine.rb +++ b/lib/devise_token_auth/engine.rb @@ -50,7 +50,6 @@ def self.setup(&block) if defined?(::OmniAuth) ::OmniAuth::config.path_prefix = Devise.omniauth_path_prefix = self.omniauth_prefix - # Omniauth currently does not pass along omniauth.params upon failure redirect # see also: https://github.com/intridea/omniauth/issues/626 OmniAuth::FailureEndpoint.class_eval do @@ -64,7 +63,6 @@ def redirect_to_failure end end - # Omniauth currently removes omniauth.params during mocked requests # see also: https://github.com/intridea/omniauth/pull/812 OmniAuth::Strategy.class_eval do diff --git a/lib/devise_token_auth/url.rb b/lib/devise_token_auth/url.rb index 999e6c7ba..e77c31281 100644 --- a/lib/devise_token_auth/url.rb +++ b/lib/devise_token_auth/url.rb @@ -17,7 +17,6 @@ def self.whitelisted?(url) url.nil? || !!DeviseTokenAuth.redirect_whitelist.find { |pattern| !!Wildcat.new(pattern).match(url) } end - # wildcard convenience class class Wildcat def self.parse_to_regex(str) diff --git a/test/controllers/demo_user_controller_test.rb b/test/controllers/demo_user_controller_test.rb index 793e7a038..554fa1176 100644 --- a/test/controllers/demo_user_controller_test.rb +++ b/test/controllers/demo_user_controller_test.rb @@ -547,8 +547,6 @@ class DemoUserControllerTest < ActionDispatch::IntegrationTest refute_equal @resource, @controller.current_mang end - - end it 'should return success status' do diff --git a/test/dummy/app/controllers/custom/passwords_controller.rb b/test/dummy/app/controllers/custom/passwords_controller.rb index 3f7b6a828..c987f6c3d 100644 --- a/test/dummy/app/controllers/custom/passwords_controller.rb +++ b/test/dummy/app/controllers/custom/passwords_controller.rb @@ -36,5 +36,4 @@ def render_update_success render json: {custom: "foo"} end - end diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb index d180b1854..7341c8177 100644 --- a/test/dummy/app/helpers/application_helper.rb +++ b/test/dummy/app/helpers/application_helper.rb @@ -347,7 +347,6 @@ module ApplicationHelper "Eton blue", "Eucalyptus", - "Fallow", "Falu red", "Fandango", @@ -440,7 +439,6 @@ module ApplicationHelper "Hot pink", "Hunter green", - "Iceberg", "Icterine", "Illuminating Emerald", @@ -485,7 +483,6 @@ module ApplicationHelper "Kombu green", "KU Crimson", - "La Salle Green", "Languid lavender", "Lapis lazuli", @@ -559,7 +556,6 @@ module ApplicationHelper "Lumber", "Lust", - "Magenta", "Magenta", "Magenta haze", @@ -674,7 +670,6 @@ module ApplicationHelper "Oxford Blue", "OU Crimson Red", - "Pakistan green", "Palatinate blue", "Palatinate purple", @@ -776,7 +771,6 @@ module ApplicationHelper "Purple taupe", "Purpureus", - "Quartz", "Queen blue", "Queen pink", @@ -849,7 +843,6 @@ module ApplicationHelper "Rust", "Rusty red", - "Sacramento State green", "Saddle brown", "Safety orange", @@ -939,7 +932,6 @@ module ApplicationHelper "Sunset orange", "Super pink", - "Tan", "Tangelo", "Tangerine", @@ -986,7 +978,6 @@ module ApplicationHelper "Twilight lavender", "Tyrian purple", - "UA blue", "UA red", "Ube", diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index c0b6472ea..fc9e9162d 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -60,7 +60,6 @@ get 'demo/members_only', to: 'demo_user#members_only' get 'demo/members_only_remove_token', to: 'demo_user#members_only_remove_token' - # routes within this block will authorize visitors using the Mang class get 'demo/members_only_mang', to: 'demo_mang#members_only' diff --git a/test/lib/generators/devise_token_auth/install_generator_test.rb b/test/lib/generators/devise_token_auth/install_generator_test.rb index ac08adc55..a6a7ce2a8 100644 --- a/test/lib/generators/devise_token_auth/install_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_test.rb @@ -84,7 +84,6 @@ def whatever end end - describe 'routes' do setup :prepare_destination diff --git a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb index af734f38e..da6765d3d 100644 --- a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb @@ -89,7 +89,6 @@ def whatever end end - describe 'routes' do setup :prepare_destination From c23c759595fab06cba4f71aa743652efc07ab084 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 17:15:48 -0700 Subject: [PATCH 05/54] Fix `Style/StringLiterals` - Fix quotes in string literals per `Style/StringLiterals` Cop. - Fix quotes in string literals per rubocop for test-dummy rails app. - Remove `Style/StringLiterals` Cop from todo list. --- .rubocop_todo.yml | 7 - Rakefile | 2 +- .../concerns/resource_finder.rb | 2 +- .../omniauth_callbacks_controller.rb | 4 +- .../devise_token_auth/passwords_controller.rb | 20 +- .../registrations_controller.rb | 4 +- .../devise_token_auth/sessions_controller.rb | 10 +- .../token_validations_controller.rb | 2 +- .../devise_token_auth/unlocks_controller.rb | 6 +- app/models/devise_token_auth/concerns/user.rb | 12 +- devise_token_auth.gemspec | 28 +- lib/devise_token_auth.rb | 10 +- lib/devise_token_auth/controllers/helpers.rb | 2 +- lib/devise_token_auth/engine.rb | 10 +- lib/devise_token_auth/rails/routes.rb | 34 +- .../devise_token_auth/install_generator.rb | 42 +- .../install_views_generator.rb | 8 +- test/controllers/demo_user_controller_test.rb | 2 +- .../sessions_controller_test.rb | 2 +- .../custom/passwords_controller.rb | 2 +- .../custom/registrations_controller.rb | 2 +- .../controllers/custom/sessions_controller.rb | 2 +- .../custom/token_validations_controller.rb | 2 +- .../overrides/confirmations_controller.rb | 2 +- .../omniauth_callbacks_controller.rb | 2 +- .../overrides/passwords_controller.rb | 2 +- .../overrides/registrations_controller.rb | 4 +- .../overrides/sessions_controller.rb | 8 +- .../overrides/token_validations_controller.rb | 2 +- test/dummy/app/helpers/application_helper.rb | 2052 ++++++++--------- test/dummy/app/models/user.rb | 2 +- test/dummy/bin/rails | 2 +- test/dummy/bin/rake | 2 +- test/dummy/bin/spring | 12 +- test/dummy/config/application.rb | 2 +- test/dummy/config/environments/development.rb | 2 +- test/dummy/config/routes.rb | 16 +- ...15061447_devise_token_auth_create_users.rb | 4 +- ...15061805_devise_token_auth_create_mangs.rb | 4 +- ...203_devise_token_auth_create_evil_users.rb | 4 +- ...vise_token_auth_create_only_email_users.rb | 4 +- ..._token_auth_create_unregisterable_users.rb | 4 +- ...712_devise_token_auth_create_nice_users.rb | 4 +- ...e_token_auth_create_unconfirmable_users.rb | 4 +- ...1_devise_token_auth_create_scoped_users.rb | 4 +- ...devise_token_auth_create_lockable_users.rb | 4 +- test/dummy/db/schema.rb | 450 ++-- test/lib/devise_token_auth/url_test.rb | 8 +- .../install_generator_test.rb | 12 +- .../install_generator_with_namespace_test.rb | 16 +- .../install_views_generator_test.rb | 2 +- test/models/user_test.rb | 6 +- test/test_helper.rb | 2 +- 53 files changed, 1425 insertions(+), 1432 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1718e9f35..b5e95b768 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -773,13 +773,6 @@ Style/SpecialGlobalVars: Exclude: - 'devise_token_auth.gemspec' -# Offense count: 1487 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Enabled: false - # Offense count: 24 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinSize. diff --git a/Rakefile b/Rakefile index 73a3fa367..c9d09e87f 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) +APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__) load 'rails/tasks/engine.rake' Bundler::GemHelper.install_tasks diff --git a/app/controllers/devise_token_auth/concerns/resource_finder.rb b/app/controllers/devise_token_auth/concerns/resource_finder.rb index 4a18a51dc..529516441 100644 --- a/app/controllers/devise_token_auth/concerns/resource_finder.rb +++ b/app/controllers/devise_token_auth/concerns/resource_finder.rb @@ -21,7 +21,7 @@ def find_resource(field, value) # fix for mysql default case insensitivity q = "#{field.to_s} = ? AND provider='#{provider.to_s}'" if ActiveRecord::Base.connection.adapter_name.downcase.starts_with? 'mysql' - q = "BINARY " + q + q = 'BINARY ' + q end @resource = resource_class.where(q, value).first diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 52a140d10..071dc1f23 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -101,7 +101,7 @@ def resource_class(mapping = nil) elsif params['resource_class'] params['resource_class'].constantize else - raise "No resource_class found" + raise 'No resource_class found' end end @@ -176,7 +176,7 @@ def render_data(message, data) @data = data.merge({ message: message }) - render :layout => nil, :template => "devise_token_auth/omniauth_external_window" + render :layout => nil, :template => 'devise_token_auth/omniauth_external_window' end def render_data_or_redirect(message, data, user_data = {}) diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index d0afd45aa..48c73eacb 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -110,18 +110,18 @@ def update def resource_update_method allow_password_change = recoverable_enabled? && @resource.allow_password_change == true if DeviseTokenAuth.check_current_password_before_update == false || allow_password_change - "update_attributes" + 'update_attributes' else - "update_with_password" + 'update_with_password' end end def render_create_error_missing_email - render_error(401, I18n.t("devise_token_auth.passwords.missing_email")) + render_error(401, I18n.t('devise_token_auth.passwords.missing_email')) end def render_create_error_missing_redirect_url - render_error(401, I18n.t("devise_token_auth.passwords.missing_redirect_url")) + render_error(401, I18n.t('devise_token_auth.passwords.missing_redirect_url')) end def render_create_error_not_allowed_redirect_url @@ -129,14 +129,14 @@ def render_create_error_not_allowed_redirect_url status: 'error', data: resource_data } - message = I18n.t("devise_token_auth.passwords.not_allowed_redirect_url", redirect_url: @redirect_url) + message = I18n.t('devise_token_auth.passwords.not_allowed_redirect_url', redirect_url: @redirect_url) render_error(422, message, response) end def render_create_success render json: { success: true, - message: I18n.t("devise_token_auth.passwords.sended", email: @email) + message: I18n.t('devise_token_auth.passwords.sended', email: @email) } end @@ -156,18 +156,18 @@ def render_update_error_unauthorized end def render_update_error_password_not_required - render_error(422, I18n.t("devise_token_auth.passwords.password_not_required", provider: @resource.provider.humanize)) + render_error(422, I18n.t('devise_token_auth.passwords.password_not_required', provider: @resource.provider.humanize)) end def render_update_error_missing_password - render_error(422, I18n.t("devise_token_auth.passwords.missing_passwords")) + render_error(422, I18n.t('devise_token_auth.passwords.missing_passwords')) end def render_update_success render json: { success: true, data: resource_data, - message: I18n.t("devise_token_auth.passwords.successfully_updated") + message: I18n.t('devise_token_auth.passwords.successfully_updated') } end @@ -196,7 +196,7 @@ def with_reset_password_token token end def render_not_found_error - render_error(404, I18n.t("devise_token_auth.passwords.user_not_found", email: @email)) + render_error(404, I18n.t('devise_token_auth.passwords.user_not_found', email: @email)) end end end diff --git a/app/controllers/devise_token_auth/registrations_controller.rb b/app/controllers/devise_token_auth/registrations_controller.rb index 1661e8a4a..c67a040c4 100644 --- a/app/controllers/devise_token_auth/registrations_controller.rb +++ b/app/controllers/devise_token_auth/registrations_controller.rb @@ -36,8 +36,8 @@ def create begin # override email confirmation, must be sent manually from ctrl - resource_class.set_callback("create", :after, :send_on_create_confirmation_instructions) - resource_class.skip_callback("create", :after, :send_on_create_confirmation_instructions) + resource_class.set_callback('create', :after, :send_on_create_confirmation_instructions) + resource_class.skip_callback('create', :after, :send_on_create_confirmation_instructions) if @resource.respond_to? :skip_confirmation_notification! # Fix duplicate e-mails by disabling Devise confirmation e-mail @resource.skip_confirmation_notification! diff --git a/app/controllers/devise_token_auth/sessions_controller.rb b/app/controllers/devise_token_auth/sessions_controller.rb index 559d456c5..058ff0ae0 100644 --- a/app/controllers/devise_token_auth/sessions_controller.rb +++ b/app/controllers/devise_token_auth/sessions_controller.rb @@ -92,7 +92,7 @@ def get_auth_params end def render_new_error - render_error(405, I18n.t("devise_token_auth.sessions.not_supported")) + render_error(405, I18n.t('devise_token_auth.sessions.not_supported')) end def render_create_success @@ -102,15 +102,15 @@ def render_create_success end def render_create_error_not_confirmed - render_error(401, I18n.t("devise_token_auth.sessions.not_confirmed", email: @resource.email)) + render_error(401, I18n.t('devise_token_auth.sessions.not_confirmed', email: @resource.email)) end def render_create_error_account_locked - render_error(401, I18n.t("devise.mailer.unlock_instructions.account_lock_msg")) + render_error(401, I18n.t('devise.mailer.unlock_instructions.account_lock_msg')) end def render_create_error_bad_credentials - render_error(401, I18n.t("devise_token_auth.sessions.bad_credentials")) + render_error(401, I18n.t('devise_token_auth.sessions.bad_credentials')) end def render_destroy_success @@ -120,7 +120,7 @@ def render_destroy_success end def render_destroy_error - render_error(404, I18n.t("devise_token_auth.sessions.user_not_found")) + render_error(404, I18n.t('devise_token_auth.sessions.user_not_found')) end private diff --git a/app/controllers/devise_token_auth/token_validations_controller.rb b/app/controllers/devise_token_auth/token_validations_controller.rb index fccc8cafc..cdb21d11b 100644 --- a/app/controllers/devise_token_auth/token_validations_controller.rb +++ b/app/controllers/devise_token_auth/token_validations_controller.rb @@ -23,7 +23,7 @@ def render_validate_token_success end def render_validate_token_error - render_error(401, I18n.t("devise_token_auth.token_validations.invalid")) + render_error(401, I18n.t('devise_token_auth.token_validations.invalid')) end end end diff --git a/app/controllers/devise_token_auth/unlocks_controller.rb b/app/controllers/devise_token_auth/unlocks_controller.rb index de1cf9017..d392c7c5c 100644 --- a/app/controllers/devise_token_auth/unlocks_controller.rb +++ b/app/controllers/devise_token_auth/unlocks_controller.rb @@ -57,13 +57,13 @@ def after_unlock_path_for(resource) end def render_create_error_missing_email - render_error(401, I18n.t("devise_token_auth.unlocks.missing_email")) + render_error(401, I18n.t('devise_token_auth.unlocks.missing_email')) end def render_create_success render json: { success: true, - message: I18n.t("devise_token_auth.unlocks.sended", email: @email) + message: I18n.t('devise_token_auth.unlocks.sended', email: @email) } end @@ -79,7 +79,7 @@ def render_show_error end def render_not_found_error - render_error(404, I18n.t("devise_token_auth.unlocks.user_not_found", email: @email)) + render_error(404, I18n.t('devise_token_auth.unlocks.user_not_found', email: @email)) end def resource_params diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 847b582bc..4eeae40df 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -56,7 +56,7 @@ def send_confirmation_instructions(opts={}) generate_confirmation_token! unless @raw_confirmation_token # fall back to "default" config name - opts[:client_config] ||= "default" + opts[:client_config] ||= 'default' opts[:to] = unconfirmed_email if pending_reconfirmation? opts[:redirect_url] ||= DeviseTokenAuth.default_confirm_success_url @@ -68,7 +68,7 @@ def send_reset_password_instructions(opts={}) token = set_reset_password_token # fall back to "default" config name - opts[:client_config] ||= "default" + opts[:client_config] ||= 'default' send_devise_notification(:reset_password_instructions, token, opts) token @@ -81,7 +81,7 @@ def send_unlock_instructions(opts={}) save(validate: false) # fall back to "default" config name - opts[:client_config] ||= "default" + opts[:client_config] ||= 'default' send_devise_notification(:unlock_instructions, raw, opts) raw @@ -184,7 +184,7 @@ def build_auth_header(token, client_id='default') { DeviseTokenAuth.headers_names[:"access-token"] => token, - DeviseTokenAuth.headers_names[:"token-type"] => "Bearer", + DeviseTokenAuth.headers_names[:"token-type"] => 'Bearer', DeviseTokenAuth.headers_names[:"client"] => client_id, DeviseTokenAuth.headers_names[:"expiry"] => expiry.to_s, DeviseTokenAuth.headers_names[:"uid"] => uid @@ -232,7 +232,7 @@ def set_empty_token_hash def destroy_expired_tokens if tokens tokens.delete_if do |cid, v| - expiry = v[:expiry] || v["expiry"] + expiry = v[:expiry] || v['expiry'] DateTime.strptime(expiry.to_s, '%s') < Time.zone.now end end @@ -252,7 +252,7 @@ def remove_tokens_after_password_reset return unless should_remove_tokens_after_password_reset? if tokens.present? && tokens.many? - client_id, token_data = tokens.max_by { |cid, v| v[:expiry] || v["expiry"] } + client_id, token_data = tokens.max_by { |cid, v| v[:expiry] || v['expiry'] } self.tokens = {client_id => token_data} end end diff --git a/devise_token_auth.gemspec b/devise_token_auth.gemspec index 5620cacf0..27e082fba 100644 --- a/devise_token_auth.gemspec +++ b/devise_token_auth.gemspec @@ -1,28 +1,28 @@ -$:.push File.expand_path("../lib", __FILE__) +$:.push File.expand_path('../lib', __FILE__) # Maintain your gem's version: -require "devise_token_auth/version" +require 'devise_token_auth/version' # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = "devise_token_auth" + s.name = 'devise_token_auth' s.version = DeviseTokenAuth::VERSION - s.authors = ["Lynn Hurley"] - s.email = ["lynn.dylan.hurley@gmail.com"] - s.homepage = "http://github.com/lynndylanhurley/devise_token_auth" - s.summary = "Token based authentication for rails. Uses Devise + OmniAuth." - s.description = "For use with client side single page apps such as the venerable https://github.com/lynndylanhurley/ng-token-auth." - s.license = "WTFPL" + s.authors = ['Lynn Hurley'] + s.email = ['lynn.dylan.hurley@gmail.com'] + s.homepage = 'http://github.com/lynndylanhurley/devise_token_auth' + s.summary = 'Token based authentication for rails. Uses Devise + OmniAuth.' + s.description = 'For use with client side single page apps such as the venerable https://github.com/lynndylanhurley/ng-token-auth.' + s.license = 'WTFPL' - s.files = Dir["{app,config,db,lib}/**/*", "LICENSE", "Rakefile", "README.md"] - s.test_files = Dir["test/**/*"] + s.files = Dir['{app,config,db,lib}/**/*', 'LICENSE', 'Rakefile', 'README.md'] + s.test_files = Dir['test/**/*'] s.test_files.reject! { |file| file.match(/[.log|.sqlite3]$/) } - s.add_dependency "rails", "< 6" - s.add_dependency "devise", "> 3.5.2", "< 4.5" + s.add_dependency 'rails', '< 6' + s.add_dependency 'devise', '> 3.5.2', '< 4.5' s.add_development_dependency 'appraisal' - s.add_development_dependency "sqlite3", "~> 1.3" + s.add_development_dependency 'sqlite3', '~> 1.3' s.add_development_dependency 'pg' s.add_development_dependency 'mysql2' end diff --git a/lib/devise_token_auth.rb b/lib/devise_token_auth.rb index 7ba990e61..b22490928 100644 --- a/lib/devise_token_auth.rb +++ b/lib/devise_token_auth.rb @@ -1,8 +1,8 @@ -require "devise" -require "devise_token_auth/engine" -require "devise_token_auth/controllers/helpers" -require "devise_token_auth/controllers/url_helpers" -require "devise_token_auth/url" +require 'devise' +require 'devise_token_auth/engine' +require 'devise_token_auth/controllers/helpers' +require 'devise_token_auth/controllers/url_helpers' +require 'devise_token_auth/url' module DeviseTokenAuth end diff --git a/lib/devise_token_auth/controllers/helpers.rb b/lib/devise_token_auth/controllers/helpers.rb index 89b8babae..3f96880e1 100644 --- a/lib/devise_token_auth/controllers/helpers.rb +++ b/lib/devise_token_auth/controllers/helpers.rb @@ -140,7 +140,7 @@ def render_authenticate_error ActiveSupport.on_load(:action_controller) do if respond_to?(:helper_method) - helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session", "render_authenticate_error" + helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session", 'render_authenticate_error' end end end diff --git a/lib/devise_token_auth/engine.rb b/lib/devise_token_auth/engine.rb index aebf81bf6..127db27a2 100644 --- a/lib/devise_token_auth/engine.rb +++ b/lib/devise_token_auth/engine.rb @@ -4,7 +4,7 @@ module DeviseTokenAuth class Engine < ::Rails::Engine isolate_namespace DeviseTokenAuth - initializer "devise_token_auth.url_helpers" do + initializer 'devise_token_auth.url_helpers' do Devise.helpers << DeviseTokenAuth::Controllers::Helpers end end @@ -55,11 +55,11 @@ def self.setup(&block) OmniAuth::FailureEndpoint.class_eval do def redirect_to_failure message_key = env['omniauth.error.type'] - origin_query_param = env['omniauth.origin'] ? "&origin=#{CGI.escape(env['omniauth.origin'])}" : "" - strategy_name_query_param = env['omniauth.error.strategy'] ? "&strategy=#{env['omniauth.error.strategy'].name}" : "" - extra_params = env['omniauth.params'] ? "&#{env['omniauth.params'].to_query}" : "" + origin_query_param = env['omniauth.origin'] ? "&origin=#{CGI.escape(env['omniauth.origin'])}" : '' + strategy_name_query_param = env['omniauth.error.strategy'] ? "&strategy=#{env['omniauth.error.strategy'].name}" : '' + extra_params = env['omniauth.params'] ? "&#{env['omniauth.params'].to_query}" : '' new_path = "#{env['SCRIPT_NAME']}#{OmniAuth.config.path_prefix}/failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}#{extra_params}" - Rack::Response.new(["302 Moved"], 302, 'Location' => new_path).finish + Rack::Response.new(['302 Moved'], 302, 'Location' => new_path).finish end end diff --git a/lib/devise_token_auth/rails/routes.rb b/lib/devise_token_auth/rails/routes.rb index e3e248a2a..766faefc7 100644 --- a/lib/devise_token_auth/rails/routes.rb +++ b/lib/devise_token_auth/rails/routes.rb @@ -6,13 +6,13 @@ def mount_devise_token_auth_for(resource, opts) opts[:skip] ||= [] # check for ctrl overrides, fall back to defaults - sessions_ctrl = opts[:controllers][:sessions] || "devise_token_auth/sessions" - registrations_ctrl = opts[:controllers][:registrations] || "devise_token_auth/registrations" - passwords_ctrl = opts[:controllers][:passwords] || "devise_token_auth/passwords" - confirmations_ctrl = opts[:controllers][:confirmations] || "devise_token_auth/confirmations" - token_validations_ctrl = opts[:controllers][:token_validations] || "devise_token_auth/token_validations" - omniauth_ctrl = opts[:controllers][:omniauth_callbacks] || "devise_token_auth/omniauth_callbacks" - unlocks_ctrl = opts[:controllers][:unlocks] || "devise_token_auth/unlocks" + sessions_ctrl = opts[:controllers][:sessions] || 'devise_token_auth/sessions' + registrations_ctrl = opts[:controllers][:registrations] || 'devise_token_auth/registrations' + passwords_ctrl = opts[:controllers][:passwords] || 'devise_token_auth/passwords' + confirmations_ctrl = opts[:controllers][:confirmations] || 'devise_token_auth/confirmations' + token_validations_ctrl = opts[:controllers][:token_validations] || 'devise_token_auth/token_validations' + omniauth_ctrl = opts[:controllers][:omniauth_callbacks] || 'devise_token_auth/omniauth_callbacks' + unlocks_ctrl = opts[:controllers][:unlocks] || 'devise_token_auth/unlocks' # define devise controller mappings controllers = {:sessions => sessions_ctrl, @@ -41,8 +41,8 @@ def mount_devise_token_auth_for(resource, opts) # clear scope so controller routes aren't namespaced @scope = ActionDispatch::Routing::Mapper::Scope.new( - path: "", - shallow_path: "", + path: '', + shallow_path: '', constraints: {}, defaults: {}, options: {}, @@ -54,25 +54,25 @@ def mount_devise_token_auth_for(resource, opts) devise_scope mapping_name.to_sym do # path to verify token validity - get "#{full_path}/validate_token", controller: "#{token_validations_ctrl}", action: "validate_token" + get "#{full_path}/validate_token", controller: "#{token_validations_ctrl}", action: 'validate_token' # omniauth routes. only define if omniauth is installed and not skipped. if defined?(::OmniAuth) && !opts[:skip].include?(:omniauth_callbacks) - match "#{full_path}/failure", controller: omniauth_ctrl, action: "omniauth_failure", via: [:get] - match "#{full_path}/:provider/callback", controller: omniauth_ctrl, action: "omniauth_success", via: [:get] + match "#{full_path}/failure", controller: omniauth_ctrl, action: 'omniauth_failure', via: [:get] + match "#{full_path}/:provider/callback", controller: omniauth_ctrl, action: 'omniauth_success', via: [:get] - match "#{DeviseTokenAuth.omniauth_prefix}/:provider/callback", controller: omniauth_ctrl, action: "redirect_callbacks", via: [:get, :post] - match "#{DeviseTokenAuth.omniauth_prefix}/failure", controller: omniauth_ctrl, action: "omniauth_failure", via: [:get, :post] + match "#{DeviseTokenAuth.omniauth_prefix}/:provider/callback", controller: omniauth_ctrl, action: 'redirect_callbacks', via: [:get, :post] + match "#{DeviseTokenAuth.omniauth_prefix}/failure", controller: omniauth_ctrl, action: 'omniauth_failure', via: [:get, :post] # preserve the resource class thru oauth authentication by setting name of # resource as "resource_class" param match "#{full_path}/:provider", to: redirect{|params, request| # get the current querystring - qs = CGI::parse(request.env["QUERY_STRING"]) + qs = CGI::parse(request.env['QUERY_STRING']) # append name of current resource - qs["resource_class"] = [resource] - qs["namespace_name"] = [namespace_name] if namespace_name + qs['resource_class'] = [resource] + qs['namespace_name'] = [namespace_name] if namespace_name set_omniauth_path_prefix!(DeviseTokenAuth.omniauth_prefix) diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index aaa8fc916..326c5ad58 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -4,20 +4,20 @@ class InstallGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) - argument :user_class, type: :string, default: "User" + argument :user_class, type: :string, default: 'User' argument :mount_path, type: :string, default: 'auth' def create_initializer_file - copy_file("devise_token_auth.rb", "config/initializers/devise_token_auth.rb") + copy_file('devise_token_auth.rb', 'config/initializers/devise_token_auth.rb') end def copy_migrations - if self.class.migration_exists?("db/migrate", "devise_token_auth_create_#{ user_class.pluralize.gsub("::","").underscore }") - say_status("skipped", "Migration 'devise_token_auth_create_#{ user_class.pluralize.gsub("::","").underscore }' already exists") + if self.class.migration_exists?('db/migrate', "devise_token_auth_create_#{ user_class.pluralize.gsub('::','').underscore }") + say_status('skipped', "Migration 'devise_token_auth_create_#{ user_class.pluralize.gsub('::','').underscore }' already exists") else migration_template( - "devise_token_auth_create_users.rb.erb", - "db/migrate/devise_token_auth_create_#{ user_class.pluralize.gsub("::","").underscore }.rb" + 'devise_token_auth_create_users.rb.erb', + "db/migrate/devise_token_auth_create_#{ user_class.pluralize.gsub('::','').underscore }.rb" ) end end @@ -25,9 +25,9 @@ def copy_migrations def create_user_model fname = "app/models/#{ user_class.underscore }.rb" unless File.exist?(File.join(destination_root, fname)) - template("user.rb.erb", fname) + template('user.rb.erb', fname) else - inclusion = "include DeviseTokenAuth::Concerns::User" + inclusion = 'include DeviseTokenAuth::Concerns::User' unless parse_file_for_line(fname, inclusion) active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base' @@ -44,12 +44,12 @@ def create_user_model end def include_controller_concerns - fname = "app/controllers/application_controller.rb" - line = "include DeviseTokenAuth::Concerns::SetUserByToken" + fname = 'app/controllers/application_controller.rb' + line = 'include DeviseTokenAuth::Concerns::SetUserByToken' if File.exist?(File.join(destination_root, fname)) if parse_file_for_line(fname, line) - say_status("skipped", "Concern is already included in the application controller.") + say_status('skipped', 'Concern is already included in the application controller.') elsif is_rails_api? inject_into_file fname, after: "class ApplicationController < ActionController::API\n" do <<-'RUBY' include DeviseTokenAuth::Concerns::SetUserByToken @@ -62,31 +62,31 @@ def include_controller_concerns end end else - say_status("skipped", "app/controllers/application_controller.rb not found. Add 'include DeviseTokenAuth::Concerns::SetUserByToken' to any controllers that require authentication.") + say_status('skipped', "app/controllers/application_controller.rb not found. Add 'include DeviseTokenAuth::Concerns::SetUserByToken' to any controllers that require authentication.") end end def add_route_mount - f = "config/routes.rb" + f = 'config/routes.rb' str = "mount_devise_token_auth_for '#{user_class}', at: '#{mount_path}'" if File.exist?(File.join(destination_root, f)) - line = parse_file_for_line(f, "mount_devise_token_auth_for") + line = parse_file_for_line(f, 'mount_devise_token_auth_for') unless line - line = "Rails.application.routes.draw do" + line = 'Rails.application.routes.draw do' existing_user_class = false else existing_user_class = true end if parse_file_for_line(f, str) - say_status("skipped", "Routes already exist for #{user_class} at #{mount_path}") + say_status('skipped', "Routes already exist for #{user_class} at #{mount_path}") else insert_after_line(f, line, str) if existing_user_class - scoped_routes = ""+ + scoped_routes = ''+ "as :#{user_class.underscore} do\n"+ " # Define routes for #{user_class} within this block.\n"+ " end\n" @@ -94,14 +94,14 @@ def add_route_mount end end else - say_status("skipped", "config/routes.rb not found. Add \"mount_devise_token_auth_for '#{user_class}', at: '#{mount_path}'\" to your routes file.") + say_status('skipped', "config/routes.rb not found. Add \"mount_devise_token_auth_for '#{user_class}', at: '#{mount_path}'\" to your routes file.") end end private def self.next_migration_number(path) - Time.zone.now.utc.strftime("%Y%m%d%H%M%S") + Time.zone.now.utc.strftime('%Y%m%d%H%M%S') end def insert_after_line(filename, line, str) @@ -124,8 +124,8 @@ def parse_file_for_line(filename, str) end def is_rails_api? - fname = "app/controllers/application_controller.rb" - line = "class ApplicationController < ActionController::API" + fname = 'app/controllers/application_controller.rb' + line = 'class ApplicationController < ActionController::API' parse_file_for_line(fname, line) end diff --git a/lib/generators/devise_token_auth/install_views_generator.rb b/lib/generators/devise_token_auth/install_views_generator.rb index 4ba5d97d1..269369a03 100644 --- a/lib/generators/devise_token_auth/install_views_generator.rb +++ b/lib/generators/devise_token_auth/install_views_generator.rb @@ -4,12 +4,12 @@ class InstallViewsGenerator < Rails::Generators::Base def copy_mailer_templates copy_file( - "confirmation_instructions.html.erb", - "app/views/devise/mailer/confirmation_instructions.html.erb" + 'confirmation_instructions.html.erb', + 'app/views/devise/mailer/confirmation_instructions.html.erb' ) copy_file( - "reset_password_instructions.html.erb", - "app/views/devise/mailer/reset_password_instructions.html.erb" + 'reset_password_instructions.html.erb', + 'app/views/devise/mailer/reset_password_instructions.html.erb' ) end end diff --git a/test/controllers/demo_user_controller_test.rb b/test/controllers/demo_user_controller_test.rb index 554fa1176..547ab262a 100644 --- a/test/controllers/demo_user_controller_test.rb +++ b/test/controllers/demo_user_controller_test.rb @@ -438,7 +438,7 @@ class DemoUserControllerTest < ActionDispatch::IntegrationTest # get the oldest token client_id oldest_client_id, = @resource.reload.tokens.min_by do |cid, v| - v[:expiry] || v["expiry"] + v[:expiry] || v['expiry'] end # => [ 'CLIENT_ID', {token: ...} ] # create another token, thereby dropping the oldest token diff --git a/test/controllers/devise_token_auth/sessions_controller_test.rb b/test/controllers/devise_token_auth/sessions_controller_test.rb index 5de4da388..0900694fb 100644 --- a/test/controllers/devise_token_auth/sessions_controller_test.rb +++ b/test/controllers/devise_token_auth/sessions_controller_test.rb @@ -110,7 +110,7 @@ class DeviseTokenAuth::SessionsControllerTest < ActionController::TestCase end oldest_token, _ = @existing_user.reload.tokens \ - .min_by { |cid, v| v[:expiry] || v["expiry"] } + .min_by { |cid, v| v[:expiry] || v['expiry'] } post :create, params: @user_session_params diff --git a/test/dummy/app/controllers/custom/passwords_controller.rb b/test/dummy/app/controllers/custom/passwords_controller.rb index c987f6c3d..b59190a48 100644 --- a/test/dummy/app/controllers/custom/passwords_controller.rb +++ b/test/dummy/app/controllers/custom/passwords_controller.rb @@ -33,7 +33,7 @@ def update_block_called? protected def render_update_success - render json: {custom: "foo"} + render json: {custom: 'foo'} end end diff --git a/test/dummy/app/controllers/custom/registrations_controller.rb b/test/dummy/app/controllers/custom/registrations_controller.rb index 86d98b1d6..84a24d57e 100644 --- a/test/dummy/app/controllers/custom/registrations_controller.rb +++ b/test/dummy/app/controllers/custom/registrations_controller.rb @@ -33,7 +33,7 @@ def destroy_block_called? protected def render_create_success - render json: {custom: "foo"} + render json: {custom: 'foo'} end end diff --git a/test/dummy/app/controllers/custom/sessions_controller.rb b/test/dummy/app/controllers/custom/sessions_controller.rb index 57809020e..bb644471c 100644 --- a/test/dummy/app/controllers/custom/sessions_controller.rb +++ b/test/dummy/app/controllers/custom/sessions_controller.rb @@ -23,7 +23,7 @@ def destroy_block_called? protected def render_create_success - render json: {custom: "foo"} + render json: {custom: 'foo'} end end diff --git a/test/dummy/app/controllers/custom/token_validations_controller.rb b/test/dummy/app/controllers/custom/token_validations_controller.rb index 4bfca82bb..6261c0507 100644 --- a/test/dummy/app/controllers/custom/token_validations_controller.rb +++ b/test/dummy/app/controllers/custom/token_validations_controller.rb @@ -13,7 +13,7 @@ def validate_token_block_called? protected def render_validate_token_success - render json: {custom: "foo"} + render json: {custom: 'foo'} end end diff --git a/test/dummy/app/controllers/overrides/confirmations_controller.rb b/test/dummy/app/controllers/overrides/confirmations_controller.rb index af6648067..a685e5202 100644 --- a/test/dummy/app/controllers/overrides/confirmations_controller.rb +++ b/test/dummy/app/controllers/overrides/confirmations_controller.rb @@ -10,7 +10,7 @@ def show redirect_header_options = { account_confirmation_success: true, config: params[:config], - override_proof: "(^^,)" + override_proof: '(^^,)' } redirect_headers = build_redirect_headers(token, client_id, diff --git a/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb b/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb index 5fee2d4fe..5ccc675e3 100644 --- a/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +++ b/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb @@ -1,6 +1,6 @@ module Overrides class OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController - DEFAULT_NICKNAME = "stimpy" + DEFAULT_NICKNAME = 'stimpy' def assign_provider_attrs(user, auth_hash) user.assign_attributes({ diff --git a/test/dummy/app/controllers/overrides/passwords_controller.rb b/test/dummy/app/controllers/overrides/passwords_controller.rb index 87471e00c..afbffdc98 100644 --- a/test/dummy/app/controllers/overrides/passwords_controller.rb +++ b/test/dummy/app/controllers/overrides/passwords_controller.rb @@ -1,6 +1,6 @@ module Overrides class PasswordsController < DeviseTokenAuth::PasswordsController - OVERRIDE_PROOF = "(^^,)" + OVERRIDE_PROOF = '(^^,)' # this is where users arrive after visiting the email confirmation link def edit diff --git a/test/dummy/app/controllers/overrides/registrations_controller.rb b/test/dummy/app/controllers/overrides/registrations_controller.rb index 5c6be0ce4..e4f8e9013 100644 --- a/test/dummy/app/controllers/overrides/registrations_controller.rb +++ b/test/dummy/app/controllers/overrides/registrations_controller.rb @@ -1,6 +1,6 @@ module Overrides class RegistrationsController < DeviseTokenAuth::RegistrationsController - OVERRIDE_PROOF = "(^^,)" + OVERRIDE_PROOF = '(^^,)' def update if @resource @@ -19,7 +19,7 @@ def update else render json: { status: 'error', - errors: ["User not found."] + errors: ['User not found.'] }, status: 404 end end diff --git a/test/dummy/app/controllers/overrides/sessions_controller.rb b/test/dummy/app/controllers/overrides/sessions_controller.rb index faa2df58f..2c73ce0e9 100644 --- a/test/dummy/app/controllers/overrides/sessions_controller.rb +++ b/test/dummy/app/controllers/overrides/sessions_controller.rb @@ -1,6 +1,6 @@ module Overrides class SessionsController < DeviseTokenAuth::SessionsController - OVERRIDE_PROOF = "(^^,)" + OVERRIDE_PROOF = '(^^,)' def create @resource = resource_class.find_by(email: resource_params[:email]) @@ -21,14 +21,14 @@ def create success: false, errors: [ "A confirmation email was sent to your account at #{@resource.email}. "+ - "You must follow the instructions in the email before your account "+ - "can be activated" + 'You must follow the instructions in the email before your account '+ + 'can be activated' ] }, status: 401 else render json: { - errors: ["Invalid login credentials. Please try again."] + errors: ['Invalid login credentials. Please try again.'] }, status: 401 end end diff --git a/test/dummy/app/controllers/overrides/token_validations_controller.rb b/test/dummy/app/controllers/overrides/token_validations_controller.rb index 7d65ca00a..057a2865d 100644 --- a/test/dummy/app/controllers/overrides/token_validations_controller.rb +++ b/test/dummy/app/controllers/overrides/token_validations_controller.rb @@ -15,7 +15,7 @@ def validate_token else render json: { success: false, - errors: ["Invalid login credentials"] + errors: ['Invalid login credentials'] }, status: 401 end end diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb index 7341c8177..c54abd778 100644 --- a/test/dummy/app/helpers/application_helper.rb +++ b/test/dummy/app/helpers/application_helper.rb @@ -1,1055 +1,1055 @@ module ApplicationHelper COLOR_NAMES = [ - "Acid green", - "Aero", - "Aero blue", - "African violet", - "Air Force blue", - "Air superiority blue", - "Alabama Crimson", - "Alice blue", - "Alizarin crimson", - "Alloy orange", - "Almond", - "Amaranth", - "Amaranth pink", - "Amaranth purple", - "Amazon", - "Amber", - "Amethyst", - "Android green", - "Anti-flash white", - "Antique brass", - "Antique bronze", - "Antique fuchsia", - "Antique ruby", - "Antique white", - "Ao", - "Apple green", - "Apricot", - "Aqua", - "Aquamarine", - "Army green", - "Arsenic", - "Artichoke", - "Arylide yellow", - "Ash grey", - "Asparagus", - "Atomic tangerine", - "Auburn", - "Aureolin", - "AuroMetalSaurus", - "Avocado", - "Azure", - "Azure mist/web", + 'Acid green', + 'Aero', + 'Aero blue', + 'African violet', + 'Air Force blue', + 'Air superiority blue', + 'Alabama Crimson', + 'Alice blue', + 'Alizarin crimson', + 'Alloy orange', + 'Almond', + 'Amaranth', + 'Amaranth pink', + 'Amaranth purple', + 'Amazon', + 'Amber', + 'Amethyst', + 'Android green', + 'Anti-flash white', + 'Antique brass', + 'Antique bronze', + 'Antique fuchsia', + 'Antique ruby', + 'Antique white', + 'Ao', + 'Apple green', + 'Apricot', + 'Aqua', + 'Aquamarine', + 'Army green', + 'Arsenic', + 'Artichoke', + 'Arylide yellow', + 'Ash grey', + 'Asparagus', + 'Atomic tangerine', + 'Auburn', + 'Aureolin', + 'AuroMetalSaurus', + 'Avocado', + 'Azure', + 'Azure mist/web', - "Baby blue", - "Baby blue eyes", - "Baby pink", - "Baby powder", - "Baker-Miller pink", - "Ball blue", - "Banana Mania", - "Banana yellow", - "Bangladesh green", - "Barbie pink", - "Barn red", - "Battleship grey", - "Bazaar", - "Beau blue", - "Beaver", - "Beige", + 'Baby blue', + 'Baby blue eyes', + 'Baby pink', + 'Baby powder', + 'Baker-Miller pink', + 'Ball blue', + 'Banana Mania', + 'Banana yellow', + 'Bangladesh green', + 'Barbie pink', + 'Barn red', + 'Battleship grey', + 'Bazaar', + 'Beau blue', + 'Beaver', + 'Beige', "B'dazzled blue", "Big dip o'ruby", - "Bisque", - "Bistre", - "Bistre brown", - "Bitter lemon", - "Bitter lime", - "Bittersweet", - "Bittersweet shimmer", - "Black", - "Black bean", - "Black leather jacket", - "Black olive", - "Blanched almond", - "Blast-off bronze", - "Bleu de France", - "Blizzard Blue", - "Blond", - "Blue", - "Blue Bell", - "Blue-gray", - "Blue-green", - "Blue sapphire", - "Blue-violet", - "Blue yonder", - "Blueberry", - "Bluebonnet", - "Blush", - "Bole", - "Bondi blue", - "Bone", - "Boston University Red", - "Bottle green", - "Boysenberry", - "Brandeis blue", - "Brass", - "Brick red", - "Bright cerulean", - "Bright green", - "Bright lavender", - "Bright lilac", - "Bright maroon", - "Bright navy blue", - "Bright pink", - "Bright turquoise", - "Bright ube", - "Brilliant lavender", - "Brilliant rose", - "Brink pink", - "British racing green", - "Bronze", - "Bronze Yellow", - "Brown", - "Brown-nose", - "Brunswick green", - "Bubble gum", - "Bubbles", - "Buff", - "Bud green", - "Bulgarian rose", - "Burgundy", - "Burlywood", - "Burnt orange", - "Burnt sienna", - "Burnt umber", - "Byzantine", - "Byzantium", + 'Bisque', + 'Bistre', + 'Bistre brown', + 'Bitter lemon', + 'Bitter lime', + 'Bittersweet', + 'Bittersweet shimmer', + 'Black', + 'Black bean', + 'Black leather jacket', + 'Black olive', + 'Blanched almond', + 'Blast-off bronze', + 'Bleu de France', + 'Blizzard Blue', + 'Blond', + 'Blue', + 'Blue Bell', + 'Blue-gray', + 'Blue-green', + 'Blue sapphire', + 'Blue-violet', + 'Blue yonder', + 'Blueberry', + 'Bluebonnet', + 'Blush', + 'Bole', + 'Bondi blue', + 'Bone', + 'Boston University Red', + 'Bottle green', + 'Boysenberry', + 'Brandeis blue', + 'Brass', + 'Brick red', + 'Bright cerulean', + 'Bright green', + 'Bright lavender', + 'Bright lilac', + 'Bright maroon', + 'Bright navy blue', + 'Bright pink', + 'Bright turquoise', + 'Bright ube', + 'Brilliant lavender', + 'Brilliant rose', + 'Brink pink', + 'British racing green', + 'Bronze', + 'Bronze Yellow', + 'Brown', + 'Brown-nose', + 'Brunswick green', + 'Bubble gum', + 'Bubbles', + 'Buff', + 'Bud green', + 'Bulgarian rose', + 'Burgundy', + 'Burlywood', + 'Burnt orange', + 'Burnt sienna', + 'Burnt umber', + 'Byzantine', + 'Byzantium', - "Cadet", - "Cadet blue", - "Cadet grey", - "Cadmium green", - "Cadmium orange", - "Cadmium red", - "Cadmium yellow", - "Cafe au lait", - "Cafe noir", - "Cal Poly Pomona green", - "Cambridge Blue", - "Camel", - "Cameo pink", - "Camouflage green", - "Canary yellow", - "Candy apple red", - "Candy pink", - "Capri", - "Caput mortuum", - "Cardinal", - "Caribbean green", - "Carmine", - "Carmine", - "Carmine pink", - "Carmine red", - "Carnation pink", - "Carnelian", - "Carolina blue", - "Carrot orange", - "Castleton green", - "Catalina blue", - "Catawba", - "Cedar Chest", - "Ceil", - "Celadon", - "Celadon blue", - "Celadon green", - "Celeste", - "Celestial blue", - "Cerise", - "Cerise pink", - "Cerulean", - "Cerulean blue", - "Cerulean frost", - "CG Blue", - "CG Red", - "Chamoisee", - "Champagne", - "Charcoal", - "Charleston green", - "Charm pink", - "Chartreuse", - "Cherry", - "Cherry blossom pink", - "Chestnut", - "China pink", - "China rose", - "Chinese red", - "Chinese violet", - "Chocolate", - "Chrome yellow", - "Cinereous", - "Cinnabar", - "Cinnamon", - "Citrine", - "Citron", - "Claret", - "Classic rose", - "Cobalt", - "Cocoa brown", - "Coconut", - "Coffee", - "Columbia blue", - "Congo pink", - "Cool grey", - "Copper", - "Copper penny", - "Copper red", - "Copper rose", - "Coquelicot", - "Coral", - "Coral pink", - "Coral red", - "Cordovan", - "Corn", - "Cornell Red", - "Cornflower blue", - "Cornsilk", - "Cosmic latte", - "Cotton candy", - "Cream", - "Crimson", - "Crimson glory", - "Cyan", - "Cyber grape", - "Cyber yellow", + 'Cadet', + 'Cadet blue', + 'Cadet grey', + 'Cadmium green', + 'Cadmium orange', + 'Cadmium red', + 'Cadmium yellow', + 'Cafe au lait', + 'Cafe noir', + 'Cal Poly Pomona green', + 'Cambridge Blue', + 'Camel', + 'Cameo pink', + 'Camouflage green', + 'Canary yellow', + 'Candy apple red', + 'Candy pink', + 'Capri', + 'Caput mortuum', + 'Cardinal', + 'Caribbean green', + 'Carmine', + 'Carmine', + 'Carmine pink', + 'Carmine red', + 'Carnation pink', + 'Carnelian', + 'Carolina blue', + 'Carrot orange', + 'Castleton green', + 'Catalina blue', + 'Catawba', + 'Cedar Chest', + 'Ceil', + 'Celadon', + 'Celadon blue', + 'Celadon green', + 'Celeste', + 'Celestial blue', + 'Cerise', + 'Cerise pink', + 'Cerulean', + 'Cerulean blue', + 'Cerulean frost', + 'CG Blue', + 'CG Red', + 'Chamoisee', + 'Champagne', + 'Charcoal', + 'Charleston green', + 'Charm pink', + 'Chartreuse', + 'Cherry', + 'Cherry blossom pink', + 'Chestnut', + 'China pink', + 'China rose', + 'Chinese red', + 'Chinese violet', + 'Chocolate', + 'Chrome yellow', + 'Cinereous', + 'Cinnabar', + 'Cinnamon', + 'Citrine', + 'Citron', + 'Claret', + 'Classic rose', + 'Cobalt', + 'Cocoa brown', + 'Coconut', + 'Coffee', + 'Columbia blue', + 'Congo pink', + 'Cool grey', + 'Copper', + 'Copper penny', + 'Copper red', + 'Copper rose', + 'Coquelicot', + 'Coral', + 'Coral pink', + 'Coral red', + 'Cordovan', + 'Corn', + 'Cornell Red', + 'Cornflower blue', + 'Cornsilk', + 'Cosmic latte', + 'Cotton candy', + 'Cream', + 'Crimson', + 'Crimson glory', + 'Cyan', + 'Cyber grape', + 'Cyber yellow', - "Daffodil", - "Dandelion", - "Dark blue", - "Dark blue-gray", - "Dark brown", - "Dark byzantium", - "Dark candy apple red", - "Dark cerulean", - "Dark chestnut", - "Dark coral", - "Dark cyan", - "Dark electric blue", - "Dark goldenrod", - "Dark gray", - "Dark green", - "Dark imperial blue", - "Dark jungle green", - "Dark khaki", - "Dark lava", - "Dark lavender", - "Dark liver", - "Dark magenta", - "Dark medium gray", - "Dark midnight blue", - "Dark moss green", - "Dark olive green", - "Dark orange", - "Dark orchid", - "Dark pastel blue", - "Dark pastel green", - "Dark pastel purple", - "Dark pastel red", - "Dark pink", - "Dark powder blue", - "Dark puce", - "Dark raspberry", - "Dark red", - "Dark salmon", - "Dark scarlet", - "Dark sea green", - "Dark sienna", - "Dark sky blue", - "Dark slate blue", - "Dark slate gray", - "Dark spring green", - "Dark tan", - "Dark tangerine", - "Dark taupe", - "Dark terra cotta", - "Dark turquoise", - "Dark vanilla", - "Dark violet", - "Dark yellow", - "Dartmouth green", + 'Daffodil', + 'Dandelion', + 'Dark blue', + 'Dark blue-gray', + 'Dark brown', + 'Dark byzantium', + 'Dark candy apple red', + 'Dark cerulean', + 'Dark chestnut', + 'Dark coral', + 'Dark cyan', + 'Dark electric blue', + 'Dark goldenrod', + 'Dark gray', + 'Dark green', + 'Dark imperial blue', + 'Dark jungle green', + 'Dark khaki', + 'Dark lava', + 'Dark lavender', + 'Dark liver', + 'Dark magenta', + 'Dark medium gray', + 'Dark midnight blue', + 'Dark moss green', + 'Dark olive green', + 'Dark orange', + 'Dark orchid', + 'Dark pastel blue', + 'Dark pastel green', + 'Dark pastel purple', + 'Dark pastel red', + 'Dark pink', + 'Dark powder blue', + 'Dark puce', + 'Dark raspberry', + 'Dark red', + 'Dark salmon', + 'Dark scarlet', + 'Dark sea green', + 'Dark sienna', + 'Dark sky blue', + 'Dark slate blue', + 'Dark slate gray', + 'Dark spring green', + 'Dark tan', + 'Dark tangerine', + 'Dark taupe', + 'Dark terra cotta', + 'Dark turquoise', + 'Dark vanilla', + 'Dark violet', + 'Dark yellow', + 'Dartmouth green', "Davy's grey", - "Debian red", - "Deep carmine", - "Deep carmine pink", - "Deep carrot orange", - "Deep cerise", - "Deep champagne", - "Deep chestnut", - "Deep coffee", - "Deep fuchsia", - "Deep jungle green", - "Deep lemon", - "Deep lilac", - "Deep magenta", - "Deep mauve", - "Deep moss green", - "Deep peach", - "Deep pink", - "Deep puce", - "Deep ruby", - "Deep saffron", - "Deep sky blue", - "Deep Space Sparkle", - "Deep Taupe", - "Deep Tuscan red", - "Deer", - "Denim", - "Desert", - "Desert sand", - "Desire", - "Diamond", - "Dim gray", - "Dirt", - "Dodger blue", - "Dogwood rose", - "Dollar bill", - "Donkey brown", - "Drab", - "Duke blue", - "Dust storm", - "Dutch white", + 'Debian red', + 'Deep carmine', + 'Deep carmine pink', + 'Deep carrot orange', + 'Deep cerise', + 'Deep champagne', + 'Deep chestnut', + 'Deep coffee', + 'Deep fuchsia', + 'Deep jungle green', + 'Deep lemon', + 'Deep lilac', + 'Deep magenta', + 'Deep mauve', + 'Deep moss green', + 'Deep peach', + 'Deep pink', + 'Deep puce', + 'Deep ruby', + 'Deep saffron', + 'Deep sky blue', + 'Deep Space Sparkle', + 'Deep Taupe', + 'Deep Tuscan red', + 'Deer', + 'Denim', + 'Desert', + 'Desert sand', + 'Desire', + 'Diamond', + 'Dim gray', + 'Dirt', + 'Dodger blue', + 'Dogwood rose', + 'Dollar bill', + 'Donkey brown', + 'Drab', + 'Duke blue', + 'Dust storm', + 'Dutch white', - "Earth yellow", - "Ebony", - "Ecru", - "Eerie black", - "Eggplant", - "Eggshell", - "Egyptian blue", - "Electric blue", - "Electric crimson", - "Electric cyan", - "Electric green", - "Electric indigo", - "Electric lavender", - "Electric lime", - "Electric purple", - "Electric ultramarine", - "Electric violet", - "Electric yellow", - "Emerald", - "Eminence", - "English green", - "English lavender", - "English red", - "English violet", - "Eton blue", - "Eucalyptus", + 'Earth yellow', + 'Ebony', + 'Ecru', + 'Eerie black', + 'Eggplant', + 'Eggshell', + 'Egyptian blue', + 'Electric blue', + 'Electric crimson', + 'Electric cyan', + 'Electric green', + 'Electric indigo', + 'Electric lavender', + 'Electric lime', + 'Electric purple', + 'Electric ultramarine', + 'Electric violet', + 'Electric yellow', + 'Emerald', + 'Eminence', + 'English green', + 'English lavender', + 'English red', + 'English violet', + 'Eton blue', + 'Eucalyptus', - "Fallow", - "Falu red", - "Fandango", - "Fandango pink", - "Fashion fuchsia", - "Fawn", - "Feldgrau", - "Feldspar", - "Fern green", - "Ferrari Red", - "Field drab", - "Firebrick", - "Fire engine red", - "Flame", - "Flamingo pink", - "Flattery", - "Flavescent", - "Flax", - "Flirt", - "Floral white", - "Fluorescent orange", - "Fluorescent pink", - "Fluorescent yellow", - "Folly", - "Forest green", - "French beige", - "French bistre", - "French blue", - "French fuchsia", - "French lilac", - "French lime", - "French mauve", - "French pink", - "French plum", - "French puce", - "French raspberry", - "French rose", - "French sky blue", - "French violet", - "French wine", - "Fresh Air", - "Fuchsia", - "Fuchsia", - "Fuchsia pink", - "Fuchsia purple", - "Fuchsia rose", - "Fulvous", - "Fuzzy Wuzzy", + 'Fallow', + 'Falu red', + 'Fandango', + 'Fandango pink', + 'Fashion fuchsia', + 'Fawn', + 'Feldgrau', + 'Feldspar', + 'Fern green', + 'Ferrari Red', + 'Field drab', + 'Firebrick', + 'Fire engine red', + 'Flame', + 'Flamingo pink', + 'Flattery', + 'Flavescent', + 'Flax', + 'Flirt', + 'Floral white', + 'Fluorescent orange', + 'Fluorescent pink', + 'Fluorescent yellow', + 'Folly', + 'Forest green', + 'French beige', + 'French bistre', + 'French blue', + 'French fuchsia', + 'French lilac', + 'French lime', + 'French mauve', + 'French pink', + 'French plum', + 'French puce', + 'French raspberry', + 'French rose', + 'French sky blue', + 'French violet', + 'French wine', + 'Fresh Air', + 'Fuchsia', + 'Fuchsia', + 'Fuchsia pink', + 'Fuchsia purple', + 'Fuchsia rose', + 'Fulvous', + 'Fuzzy Wuzzy', - "Gainsboro", - "Gamboge", - "Generic viridian", - "Ghost white", - "Giants orange", - "Ginger", - "Glaucous", - "Glitter", - "GO green", - "Gold", - "Gold Fusion", - "Golden brown", - "Golden poppy", - "Golden yellow", - "Goldenrod", - "Granny Smith Apple", - "Grape", - "Gray", - "Gray-asparagus", - "Gray-blue", - "Green", - "Green-yellow", - "Grizzly", - "Grullo", - "Guppie green", - "Halaya ube", - "Han blue", - "Han purple", - "Hansa yellow", - "Harlequin", - "Harvard crimson", - "Harvest gold", - "Heart Gold", - "Heliotrope", - "Heliotrope gray", - "Hollywood cerise", - "Honeydew", - "Honolulu blue", + 'Gainsboro', + 'Gamboge', + 'Generic viridian', + 'Ghost white', + 'Giants orange', + 'Ginger', + 'Glaucous', + 'Glitter', + 'GO green', + 'Gold', + 'Gold Fusion', + 'Golden brown', + 'Golden poppy', + 'Golden yellow', + 'Goldenrod', + 'Granny Smith Apple', + 'Grape', + 'Gray', + 'Gray-asparagus', + 'Gray-blue', + 'Green', + 'Green-yellow', + 'Grizzly', + 'Grullo', + 'Guppie green', + 'Halaya ube', + 'Han blue', + 'Han purple', + 'Hansa yellow', + 'Harlequin', + 'Harvard crimson', + 'Harvest gold', + 'Heart Gold', + 'Heliotrope', + 'Heliotrope gray', + 'Hollywood cerise', + 'Honeydew', + 'Honolulu blue', "Hooker's green", - "Hot magenta", - "Hot pink", - "Hunter green", + 'Hot magenta', + 'Hot pink', + 'Hunter green', - "Iceberg", - "Icterine", - "Illuminating Emerald", - "Imperial", - "Imperial blue", - "Imperial purple", - "Imperial red", - "Inchworm", - "Independence", - "India green", - "Indian red", - "Indian yellow", - "Indigo", - "Indigo dye", - "International Klein Blue", - "International orange", - "Iris", - "Irresistible", - "Isabelline", - "Islamic green", - "Italian sky blue", - "Ivory", - "Jade", - "Japanese carmine", - "Japanese indigo", - "Japanese violet", - "Jasmine", - "Jasper", - "Jazzberry jam", - "Jelly Bean", - "Jet", - "Jonquil", - "Jordy blue", - "June bud", - "Jungle green", - "Kelly green", - "Kenyan copper", - "Keppel", - "Khaki", - "Kobe", - "Kobi", - "Kombu green", - "KU Crimson", + 'Iceberg', + 'Icterine', + 'Illuminating Emerald', + 'Imperial', + 'Imperial blue', + 'Imperial purple', + 'Imperial red', + 'Inchworm', + 'Independence', + 'India green', + 'Indian red', + 'Indian yellow', + 'Indigo', + 'Indigo dye', + 'International Klein Blue', + 'International orange', + 'Iris', + 'Irresistible', + 'Isabelline', + 'Islamic green', + 'Italian sky blue', + 'Ivory', + 'Jade', + 'Japanese carmine', + 'Japanese indigo', + 'Japanese violet', + 'Jasmine', + 'Jasper', + 'Jazzberry jam', + 'Jelly Bean', + 'Jet', + 'Jonquil', + 'Jordy blue', + 'June bud', + 'Jungle green', + 'Kelly green', + 'Kenyan copper', + 'Keppel', + 'Khaki', + 'Kobe', + 'Kobi', + 'Kombu green', + 'KU Crimson', - "La Salle Green", - "Languid lavender", - "Lapis lazuli", - "Laser Lemon", - "Laurel green", - "Lava", - "Lavender", - "Lavender blue", - "Lavender blush", - "Lavender gray", - "Lavender indigo", - "Lavender magenta", - "Lavender mist", - "Lavender pink", - "Lavender purple", - "Lavender rose", - "Lawn green", - "Lemon", - "Lemon chiffon", - "Lemon curry", - "Lemon glacier", - "Lemon lime", - "Lemon meringue", - "Lemon yellow", - "Licorice", - "Liberty", - "Light apricot", - "Light blue", - "Light brown", - "Light carmine pink", - "Light coral", - "Light cornflower blue", - "Light crimson", - "Light cyan", - "Light deep pink", - "Light French beige", - "Light fuchsia pink", - "Light goldenrod yellow", - "Light gray", - "Light green", - "Light hot pink", - "Light khaki", - "Light medium orchid", - "Light moss green", - "Light orchid", - "Light pastel purple", - "Light pink", - "Light red ochre", - "Light salmon", - "Light salmon pink", - "Light sea green", - "Light sky blue", - "Light slate gray", - "Light steel blue", - "Light taupe", - "Light Thulian pink", - "Light yellow", - "Lilac", - "Lime", - "Lime green", - "Limerick", - "Lincoln green", - "Linen", - "Lion", - "Liseran Purple", - "Little boy blue", - "Liver", - "Liver", - "Liver chestnut", - "Livid", - "Lumber", - "Lust", + 'La Salle Green', + 'Languid lavender', + 'Lapis lazuli', + 'Laser Lemon', + 'Laurel green', + 'Lava', + 'Lavender', + 'Lavender blue', + 'Lavender blush', + 'Lavender gray', + 'Lavender indigo', + 'Lavender magenta', + 'Lavender mist', + 'Lavender pink', + 'Lavender purple', + 'Lavender rose', + 'Lawn green', + 'Lemon', + 'Lemon chiffon', + 'Lemon curry', + 'Lemon glacier', + 'Lemon lime', + 'Lemon meringue', + 'Lemon yellow', + 'Licorice', + 'Liberty', + 'Light apricot', + 'Light blue', + 'Light brown', + 'Light carmine pink', + 'Light coral', + 'Light cornflower blue', + 'Light crimson', + 'Light cyan', + 'Light deep pink', + 'Light French beige', + 'Light fuchsia pink', + 'Light goldenrod yellow', + 'Light gray', + 'Light green', + 'Light hot pink', + 'Light khaki', + 'Light medium orchid', + 'Light moss green', + 'Light orchid', + 'Light pastel purple', + 'Light pink', + 'Light red ochre', + 'Light salmon', + 'Light salmon pink', + 'Light sea green', + 'Light sky blue', + 'Light slate gray', + 'Light steel blue', + 'Light taupe', + 'Light Thulian pink', + 'Light yellow', + 'Lilac', + 'Lime', + 'Lime green', + 'Limerick', + 'Lincoln green', + 'Linen', + 'Lion', + 'Liseran Purple', + 'Little boy blue', + 'Liver', + 'Liver', + 'Liver chestnut', + 'Livid', + 'Lumber', + 'Lust', - "Magenta", - "Magenta", - "Magenta haze", - "Magic mint", - "Magnolia", - "Mahogany", - "Maize", - "Majorelle Blue", - "Malachite", - "Manatee", - "Mango Tango", - "Mantis", - "Mardi Gras", - "Maroon", - "Mauve", - "Mauve taupe", - "Mauvelous", - "May green", - "Maya blue", - "Meat brown", - "Medium aquamarine", - "Medium blue", - "Medium candy apple red", - "Medium carmine", - "Medium champagne", - "Medium electric blue", - "Medium jungle green", - "Medium lavender magenta", - "Medium orchid", - "Medium Persian blue", - "Medium purple", - "Medium red-violet", - "Medium ruby", - "Medium sea green", - "Medium sky blue", - "Medium slate blue", - "Medium spring bud", - "Medium spring green", - "Medium taupe", - "Medium turquoise", - "Medium Tuscan red", - "Medium vermilion", - "Medium violet-red", - "Mellow apricot", - "Mellow yellow", - "Melon", - "Metallic Seaweed", - "Metallic Sunburst", - "Mexican pink", - "Midnight blue", - "Milky blue", - "Midnight green", - "Mikado yellow", - "Mindaro", - "Mint", - "Mint cream", - "Mint green", - "Misty rose", - "Moccasin", - "Mode beige", - "Moonstone blue", - "Mordant red 19", - "Moss green", - "Mountain Meadow", - "Mountbatten pink", - "MSU Green", - "Mughal green", - "Mulberry", - "Mustard", - "Myrtle green", + 'Magenta', + 'Magenta', + 'Magenta haze', + 'Magic mint', + 'Magnolia', + 'Mahogany', + 'Maize', + 'Majorelle Blue', + 'Malachite', + 'Manatee', + 'Mango Tango', + 'Mantis', + 'Mardi Gras', + 'Maroon', + 'Mauve', + 'Mauve taupe', + 'Mauvelous', + 'May green', + 'Maya blue', + 'Meat brown', + 'Medium aquamarine', + 'Medium blue', + 'Medium candy apple red', + 'Medium carmine', + 'Medium champagne', + 'Medium electric blue', + 'Medium jungle green', + 'Medium lavender magenta', + 'Medium orchid', + 'Medium Persian blue', + 'Medium purple', + 'Medium red-violet', + 'Medium ruby', + 'Medium sea green', + 'Medium sky blue', + 'Medium slate blue', + 'Medium spring bud', + 'Medium spring green', + 'Medium taupe', + 'Medium turquoise', + 'Medium Tuscan red', + 'Medium vermilion', + 'Medium violet-red', + 'Mellow apricot', + 'Mellow yellow', + 'Melon', + 'Metallic Seaweed', + 'Metallic Sunburst', + 'Mexican pink', + 'Midnight blue', + 'Milky blue', + 'Midnight green', + 'Mikado yellow', + 'Mindaro', + 'Mint', + 'Mint cream', + 'Mint green', + 'Misty rose', + 'Moccasin', + 'Mode beige', + 'Moonstone blue', + 'Mordant red 19', + 'Moss green', + 'Mountain Meadow', + 'Mountbatten pink', + 'MSU Green', + 'Mughal green', + 'Mulberry', + 'Mustard', + 'Myrtle green', - "Nadeshiko pink", - "Napier green", - "Naples yellow", - "Navajo white", - "Navy", - "Navy purple", - "Neon Carrot", - "Neon fuchsia", - "Neon green", - "New Car", - "New York pink", - "Non-photo blue", - "North Texas Green", - "Nyanza", - "Ocean Boat Blue", - "Ochre", - "Office green", - "Old burgundy", - "Old gold", - "Old heliotrope", - "Old lace", - "Old lavender", - "Old mauve", - "Old moss green", - "Old rose", - "Old silver", - "Olive", - "Olive Drab", - "Olivine", - "Onyx", - "Opera mauve", - "Orange", - "Orange peel", - "Orange-red", - "Orchid", - "Orchid pink", - "Orioles orange", - "Otter brown", - "Outer Space", - "Outrageous Orange", - "Oxford Blue", - "OU Crimson Red", + 'Nadeshiko pink', + 'Napier green', + 'Naples yellow', + 'Navajo white', + 'Navy', + 'Navy purple', + 'Neon Carrot', + 'Neon fuchsia', + 'Neon green', + 'New Car', + 'New York pink', + 'Non-photo blue', + 'North Texas Green', + 'Nyanza', + 'Ocean Boat Blue', + 'Ochre', + 'Office green', + 'Old burgundy', + 'Old gold', + 'Old heliotrope', + 'Old lace', + 'Old lavender', + 'Old mauve', + 'Old moss green', + 'Old rose', + 'Old silver', + 'Olive', + 'Olive Drab', + 'Olivine', + 'Onyx', + 'Opera mauve', + 'Orange', + 'Orange peel', + 'Orange-red', + 'Orchid', + 'Orchid pink', + 'Orioles orange', + 'Otter brown', + 'Outer Space', + 'Outrageous Orange', + 'Oxford Blue', + 'OU Crimson Red', - "Pakistan green", - "Palatinate blue", - "Palatinate purple", - "Pale aqua", - "Pale blue", - "Pale brown", - "Pale carmine", - "Pale cerulean", - "Pale chestnut", - "Pale copper", - "Pale cornflower blue", - "Pale gold", - "Pale goldenrod", - "Pale green", - "Pale lavender", - "Pale magenta", - "Pale pink", - "Pale plum", - "Pale red-violet", - "Pale robin egg blue", - "Pale silver", - "Pale spring bud", - "Pale taupe", - "Pale turquoise", - "Pale violet-red", - "Pansy purple", - "Paolo Veronese green", - "Papaya whip", - "Paradise pink", - "Paris Green", - "Pastel blue", - "Pastel brown", - "Pastel gray", - "Pastel green", - "Pastel magenta", - "Pastel orange", - "Pastel pink", - "Pastel purple", - "Pastel red", - "Pastel violet", - "Pastel yellow", - "Patriarch", + 'Pakistan green', + 'Palatinate blue', + 'Palatinate purple', + 'Pale aqua', + 'Pale blue', + 'Pale brown', + 'Pale carmine', + 'Pale cerulean', + 'Pale chestnut', + 'Pale copper', + 'Pale cornflower blue', + 'Pale gold', + 'Pale goldenrod', + 'Pale green', + 'Pale lavender', + 'Pale magenta', + 'Pale pink', + 'Pale plum', + 'Pale red-violet', + 'Pale robin egg blue', + 'Pale silver', + 'Pale spring bud', + 'Pale taupe', + 'Pale turquoise', + 'Pale violet-red', + 'Pansy purple', + 'Paolo Veronese green', + 'Papaya whip', + 'Paradise pink', + 'Paris Green', + 'Pastel blue', + 'Pastel brown', + 'Pastel gray', + 'Pastel green', + 'Pastel magenta', + 'Pastel orange', + 'Pastel pink', + 'Pastel purple', + 'Pastel red', + 'Pastel violet', + 'Pastel yellow', + 'Patriarch', "Payne's grey", - "Peach", - "Peach", - "Peach-orange", - "Peach puff", - "Peach-yellow", - "Pear", - "Pearl", - "Pearl Aqua", - "Pearly purple", - "Peridot", - "Periwinkle", - "Persian blue", - "Persian green", - "Persian indigo", - "Persian orange", - "Persian pink", - "Persian plum", - "Persian red", - "Persian rose", - "Persimmon", - "Peru", - "Phlox", - "Phthalo blue", - "Phthalo green", - "Picton blue", - "Pictorial carmine", - "Piggy pink", - "Pine green", - "Pineapple", - "Pink", - "Pink lace", - "Pink lavender", - "Pink-orange", - "Pink pearl", - "Pink Sherbet", - "Pistachio", - "Platinum", - "Plum", - "Pomp and Power", - "Popstar", - "Portland Orange", - "Powder blue", - "Princeton orange", - "Prune", - "Prussian blue", - "Psychedelic purple", - "Puce", - "Puce red", - "Pullman Brown", - "Pumpkin", - "Purple", - "Purple Heart", - "Purple mountain majesty", - "Purple navy", - "Purple pizzazz", - "Purple taupe", - "Purpureus", + 'Peach', + 'Peach', + 'Peach-orange', + 'Peach puff', + 'Peach-yellow', + 'Pear', + 'Pearl', + 'Pearl Aqua', + 'Pearly purple', + 'Peridot', + 'Periwinkle', + 'Persian blue', + 'Persian green', + 'Persian indigo', + 'Persian orange', + 'Persian pink', + 'Persian plum', + 'Persian red', + 'Persian rose', + 'Persimmon', + 'Peru', + 'Phlox', + 'Phthalo blue', + 'Phthalo green', + 'Picton blue', + 'Pictorial carmine', + 'Piggy pink', + 'Pine green', + 'Pineapple', + 'Pink', + 'Pink lace', + 'Pink lavender', + 'Pink-orange', + 'Pink pearl', + 'Pink Sherbet', + 'Pistachio', + 'Platinum', + 'Plum', + 'Pomp and Power', + 'Popstar', + 'Portland Orange', + 'Powder blue', + 'Princeton orange', + 'Prune', + 'Prussian blue', + 'Psychedelic purple', + 'Puce', + 'Puce red', + 'Pullman Brown', + 'Pumpkin', + 'Purple', + 'Purple Heart', + 'Purple mountain majesty', + 'Purple navy', + 'Purple pizzazz', + 'Purple taupe', + 'Purpureus', - "Quartz", - "Queen blue", - "Queen pink", - "Quinacridone magenta", - "Rackley", - "Radical Red", - "Rajah", - "Raspberry", - "Raspberry glace", - "Raspberry pink", - "Raspberry rose", - "Raw umber", - "Razzle dazzle rose", - "Razzmatazz", - "Razzmic Berry", - "Rebecca Purple", - "Red", - "Red", - "Red-brown", - "Red devil", - "Red-orange", - "Red-purple", - "Red-violet", - "Redwood", - "Regalia", - "Resolution blue", - "Rhythm", - "Rich black", - "Rich brilliant lavender", - "Rich carmine", - "Rich electric blue", - "Rich lavender", - "Rich lilac", - "Rich maroon", - "Rifle green", - "Roast coffee", - "Robin egg blue", - "Rocket metallic", - "Roman silver", - "Rose", - "Rose bonbon", - "Rose ebony", - "Rose gold", - "Rose madder", - "Rose pink", - "Rose quartz", - "Rose red", - "Rose taupe", - "Rose vale", - "Rosewood", - "Rosso corsa", - "Rosy brown", - "Royal azure", - "Royal blue", - "Royal blue", - "Royal fuchsia", - "Royal purple", - "Royal yellow", - "Ruber", - "Rubine red", - "Ruby", - "Ruby red", - "Ruddy", - "Ruddy brown", - "Ruddy pink", - "Rufous", - "Russet", - "Russian green", - "Russian violet", - "Rust", - "Rusty red", + 'Quartz', + 'Queen blue', + 'Queen pink', + 'Quinacridone magenta', + 'Rackley', + 'Radical Red', + 'Rajah', + 'Raspberry', + 'Raspberry glace', + 'Raspberry pink', + 'Raspberry rose', + 'Raw umber', + 'Razzle dazzle rose', + 'Razzmatazz', + 'Razzmic Berry', + 'Rebecca Purple', + 'Red', + 'Red', + 'Red-brown', + 'Red devil', + 'Red-orange', + 'Red-purple', + 'Red-violet', + 'Redwood', + 'Regalia', + 'Resolution blue', + 'Rhythm', + 'Rich black', + 'Rich brilliant lavender', + 'Rich carmine', + 'Rich electric blue', + 'Rich lavender', + 'Rich lilac', + 'Rich maroon', + 'Rifle green', + 'Roast coffee', + 'Robin egg blue', + 'Rocket metallic', + 'Roman silver', + 'Rose', + 'Rose bonbon', + 'Rose ebony', + 'Rose gold', + 'Rose madder', + 'Rose pink', + 'Rose quartz', + 'Rose red', + 'Rose taupe', + 'Rose vale', + 'Rosewood', + 'Rosso corsa', + 'Rosy brown', + 'Royal azure', + 'Royal blue', + 'Royal blue', + 'Royal fuchsia', + 'Royal purple', + 'Royal yellow', + 'Ruber', + 'Rubine red', + 'Ruby', + 'Ruby red', + 'Ruddy', + 'Ruddy brown', + 'Ruddy pink', + 'Rufous', + 'Russet', + 'Russian green', + 'Russian violet', + 'Rust', + 'Rusty red', - "Sacramento State green", - "Saddle brown", - "Safety orange", - "Safety yellow", - "Saffron", - "Sage", + 'Sacramento State green', + 'Saddle brown', + 'Safety orange', + 'Safety yellow', + 'Saffron', + 'Sage', "St. Patrick's blue", - "Salmon", - "Salmon pink", - "Sand", - "Sand dune", - "Sandstorm", - "Sandy brown", - "Sandy taupe", - "Sangria", - "Sap green", - "Sapphire", - "Sapphire blue", - "Satin sheen gold", - "Scarlet", - "Scarlet", - "Schauss pink", - "School bus yellow", + 'Salmon', + 'Salmon pink', + 'Sand', + 'Sand dune', + 'Sandstorm', + 'Sandy brown', + 'Sandy taupe', + 'Sangria', + 'Sap green', + 'Sapphire', + 'Sapphire blue', + 'Satin sheen gold', + 'Scarlet', + 'Scarlet', + 'Schauss pink', + 'School bus yellow', "Screamin' Green", - "Sea blue", - "Sea green", - "Seal brown", - "Seashell", - "Selective yellow", - "Sepia", - "Shadow", - "Shadow blue", - "Shampoo", - "Shamrock green", - "Sheen Green", - "Shimmering Blush", - "Shocking pink", - "Sienna", - "Silver", - "Silver chalice", - "Silver Lake blue", - "Silver pink", - "Silver sand", - "Sinopia", - "Skobeloff", - "Sky blue", - "Sky magenta", - "Slate blue", - "Slate gray", - "Smalt", - "Smitten", - "Smoke", - "Smoky black", - "Smoky Topaz", - "Snow", - "Soap", - "Solid pink", - "Sonic silver", - "Spartan Crimson", - "Space cadet", - "Spanish bistre", - "Spanish blue", - "Spanish carmine", - "Spanish crimson", - "Spanish gray", - "Spanish green", - "Spanish orange", - "Spanish pink", - "Spanish red", - "Spanish sky blue", - "Spanish violet", - "Spanish viridian", - "Spiro Disco Ball", - "Spring bud", - "Spring green", - "Star command blue", - "Steel blue", - "Steel pink", - "Stil de grain yellow", - "Stizza", - "Stormcloud", - "Straw", - "Strawberry", - "Sunglow", - "Sunray", - "Sunset", - "Sunset orange", - "Super pink", + 'Sea blue', + 'Sea green', + 'Seal brown', + 'Seashell', + 'Selective yellow', + 'Sepia', + 'Shadow', + 'Shadow blue', + 'Shampoo', + 'Shamrock green', + 'Sheen Green', + 'Shimmering Blush', + 'Shocking pink', + 'Sienna', + 'Silver', + 'Silver chalice', + 'Silver Lake blue', + 'Silver pink', + 'Silver sand', + 'Sinopia', + 'Skobeloff', + 'Sky blue', + 'Sky magenta', + 'Slate blue', + 'Slate gray', + 'Smalt', + 'Smitten', + 'Smoke', + 'Smoky black', + 'Smoky Topaz', + 'Snow', + 'Soap', + 'Solid pink', + 'Sonic silver', + 'Spartan Crimson', + 'Space cadet', + 'Spanish bistre', + 'Spanish blue', + 'Spanish carmine', + 'Spanish crimson', + 'Spanish gray', + 'Spanish green', + 'Spanish orange', + 'Spanish pink', + 'Spanish red', + 'Spanish sky blue', + 'Spanish violet', + 'Spanish viridian', + 'Spiro Disco Ball', + 'Spring bud', + 'Spring green', + 'Star command blue', + 'Steel blue', + 'Steel pink', + 'Stil de grain yellow', + 'Stizza', + 'Stormcloud', + 'Straw', + 'Strawberry', + 'Sunglow', + 'Sunray', + 'Sunset', + 'Sunset orange', + 'Super pink', - "Tan", - "Tangelo", - "Tangerine", - "Tangerine yellow", - "Tango pink", - "Taupe", - "Taupe gray", - "Tea green", - "Tea rose", - "Tea rose", - "Teal", - "Teal blue", - "Teal deer", - "Teal green", - "Telemagenta", - "Tenne", - "Terra cotta", - "Thistle", - "Thulian pink", - "Tickle Me Pink", - "Tiffany Blue", + 'Tan', + 'Tangelo', + 'Tangerine', + 'Tangerine yellow', + 'Tango pink', + 'Taupe', + 'Taupe gray', + 'Tea green', + 'Tea rose', + 'Tea rose', + 'Teal', + 'Teal blue', + 'Teal deer', + 'Teal green', + 'Telemagenta', + 'Tenne', + 'Terra cotta', + 'Thistle', + 'Thulian pink', + 'Tickle Me Pink', + 'Tiffany Blue', "Tiger's eye", - "Timberwolf", - "Titanium yellow", - "Tomato", - "Toolbox", - "Topaz", - "Tractor red", - "Trolley Grey", - "Tropical rain forest", - "True Blue", - "Tufts Blue", - "Tulip", - "Tumbleweed", - "Turkish rose", - "Turquoise", - "Turquoise blue", - "Turquoise green", - "Tuscan", - "Tuscan brown", - "Tuscan red", - "Tuscan tan", - "Tuscany", - "Twilight lavender", - "Tyrian purple", + 'Timberwolf', + 'Titanium yellow', + 'Tomato', + 'Toolbox', + 'Topaz', + 'Tractor red', + 'Trolley Grey', + 'Tropical rain forest', + 'True Blue', + 'Tufts Blue', + 'Tulip', + 'Tumbleweed', + 'Turkish rose', + 'Turquoise', + 'Turquoise blue', + 'Turquoise green', + 'Tuscan', + 'Tuscan brown', + 'Tuscan red', + 'Tuscan tan', + 'Tuscany', + 'Twilight lavender', + 'Tyrian purple', - "UA blue", - "UA red", - "Ube", - "UCLA Blue", - "UCLA Gold", - "UFO Green", - "Ultramarine", - "Ultramarine blue", - "Ultra pink", - "Ultra red", - "Umber", - "Unbleached silk", - "United Nations blue", - "University of California Gold", - "Unmellow yellow", - "UP Forest green", - "UP Maroon", - "Upsdell red", - "Urobilin", - "USAFA blue", - "USC Cardinal", - "USC Gold", - "University of Tennessee Orange", - "Utah Crimson", - "Vanilla", - "Vanilla ice", - "Vegas gold", - "Venetian red", - "Verdigris", - "Vermilion", - "Vermilion", - "Veronica", - "Violet", - "Violet-blue", - "Violet-red", - "Viridian", - "Viridian green", - "Vista blue", - "Vivid auburn", - "Vivid burgundy", - "Vivid cerise", - "Vivid orchid", - "Vivid sky blue", - "Vivid tangerine", - "Vivid violet", + 'UA blue', + 'UA red', + 'Ube', + 'UCLA Blue', + 'UCLA Gold', + 'UFO Green', + 'Ultramarine', + 'Ultramarine blue', + 'Ultra pink', + 'Ultra red', + 'Umber', + 'Unbleached silk', + 'United Nations blue', + 'University of California Gold', + 'Unmellow yellow', + 'UP Forest green', + 'UP Maroon', + 'Upsdell red', + 'Urobilin', + 'USAFA blue', + 'USC Cardinal', + 'USC Gold', + 'University of Tennessee Orange', + 'Utah Crimson', + 'Vanilla', + 'Vanilla ice', + 'Vegas gold', + 'Venetian red', + 'Verdigris', + 'Vermilion', + 'Vermilion', + 'Veronica', + 'Violet', + 'Violet-blue', + 'Violet-red', + 'Viridian', + 'Viridian green', + 'Vista blue', + 'Vivid auburn', + 'Vivid burgundy', + 'Vivid cerise', + 'Vivid orchid', + 'Vivid sky blue', + 'Vivid tangerine', + 'Vivid violet', - "Warm black", - "Waterspout", - "Wenge", - "Wheat", - "White", - "White smoke", - "Wild blue yonder", - "Wild orchid", - "Wild Strawberry", - "Wild watermelon", - "Willpower orange", - "Windsor tan", - "Wine", - "Wine dregs", - "Wisteria", - "Wood brown", - "Xanadu", - "Yale Blue", - "Yankees blue", - "Yellow", - "Yellow-green", - "Yellow Orange", - "Yellow rose", - "Zaffre", - "Zinnwaldite brown", - "Zomp" + 'Warm black', + 'Waterspout', + 'Wenge', + 'Wheat', + 'White', + 'White smoke', + 'Wild blue yonder', + 'Wild orchid', + 'Wild Strawberry', + 'Wild watermelon', + 'Willpower orange', + 'Windsor tan', + 'Wine', + 'Wine dregs', + 'Wisteria', + 'Wood brown', + 'Xanadu', + 'Yale Blue', + 'Yankees blue', + 'Yellow', + 'Yellow-green', + 'Yellow Orange', + 'Yellow rose', + 'Zaffre', + 'Zinnwaldite brown', + 'Zomp' ] COLOR_SEARCH = FuzzBall::Searcher.new(COLOR_NAMES) diff --git a/test/dummy/app/models/user.rb b/test/dummy/app/models/user.rb index 17df68f5e..329656eba 100644 --- a/test/dummy/app/models/user.rb +++ b/test/dummy/app/models/user.rb @@ -6,7 +6,7 @@ class User < ActiveRecord::Base def ensure_correct_favorite_color - if favorite_color and favorite_color != "" + if favorite_color and favorite_color != '' unless ApplicationHelper::COLOR_NAMES.any?{ |s| s.casecmp(favorite_color)==0 } matches = ApplicationHelper::COLOR_SEARCH.search(favorite_color) closest_match = matches.last[:string] diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index 7feb6a30e..b82341c98 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby begin - load File.expand_path("../spring", __FILE__) + load File.expand_path('../spring', __FILE__) rescue LoadError end APP_PATH = File.expand_path('../../config/application', __FILE__) diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake index 8017a0271..2e9ece45c 100755 --- a/test/dummy/bin/rake +++ b/test/dummy/bin/rake @@ -1,6 +1,6 @@ #!/usr/bin/env ruby begin - load File.expand_path("../spring", __FILE__) + load File.expand_path('../spring', __FILE__) rescue LoadError end require_relative '../config/boot' diff --git a/test/dummy/bin/spring b/test/dummy/bin/spring index 253ec37c3..ec62a6582 100755 --- a/test/dummy/bin/spring +++ b/test/dummy/bin/spring @@ -4,15 +4,15 @@ # It gets overwritten when you run the `spring binstub` command unless defined?(Spring) - require "rubygems" - require "bundler" + require 'rubygems' + require 'bundler' if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) - ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) - ENV["GEM_HOME"] = "" + ENV['GEM_PATH'] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) + ENV['GEM_HOME'] = '' Gem.paths = ENV - gem "spring", match[1] - require "spring/binstub" + gem 'spring', match[1] + require 'spring/binstub' end end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index ff7cd58d8..e3eb919dd 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -4,7 +4,7 @@ require 'rails/all' Bundler.require(*Rails.groups) -require "devise_token_auth" +require 'devise_token_auth' module Dummy class Application < Rails::Application diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 4a908bafb..3a67b510c 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -40,5 +40,5 @@ # Raises error for missing translations # config.action_view.raise_on_missing_translations = true - OmniAuth.config.full_host = "http://devise-token-auth.dev" + OmniAuth.config.full_host = 'http://devise-token-auth.dev' end diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index fc9e9162d..9a778916a 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -8,7 +8,7 @@ # define :mangs as the second devise mapping. routes using this class will # need to be defined within a devise_scope as shown below - mount_devise_token_auth_for "Mang", at: 'mangs' + mount_devise_token_auth_for 'Mang', at: 'mangs' mount_devise_token_auth_for 'EvilUser', at: 'evil_user_auth', controllers: { confirmations: 'overrides/confirmations', @@ -45,14 +45,14 @@ # test namespacing with not created devise mapping namespace :api_v2, defaults: { format: :json } do - mount_devise_token_auth_for "ScopedUser", - at: "auth", + mount_devise_token_auth_for 'ScopedUser', + at: 'auth', controllers: { - omniauth_callbacks: "api_v2/omniauth_callbacks", - sessions: "api_v2/sessions", - registrations: "api_v2/registrations", - confirmations: "api_v2/confirmations", - passwords: "api_v2/passwords" + omniauth_callbacks: 'api_v2/omniauth_callbacks', + sessions: 'api_v2/sessions', + registrations: 'api_v2/registrations', + confirmations: 'api_v2/confirmations', + passwords: 'api_v2/passwords' } end diff --git a/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb b/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb index 87b65272c..b7939784a 100644 --- a/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +++ b/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb @@ -5,7 +5,7 @@ def change create_table(:users) do |t| ## Database authenticatable t.string :email - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable t.string :reset_password_token @@ -41,7 +41,7 @@ def change ## unique oauth id t.string :provider - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Tokens if json_supported_database? diff --git a/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb b/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb index d820b8bfa..1cc25bb99 100644 --- a/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +++ b/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb @@ -5,7 +5,7 @@ def change create_table(:mangs) do |t| ## Database authenticatable t.string :email - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable t.string :reset_password_token @@ -41,7 +41,7 @@ def change ## unique oauth id t.string :provider - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Tokens if json_supported_database? diff --git a/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb b/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb index 216eccdad..8f7a69893 100644 --- a/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +++ b/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb @@ -5,7 +5,7 @@ def change create_table(:evil_users) do |t| ## Database authenticatable t.string :email - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable t.string :reset_password_token @@ -40,7 +40,7 @@ def change ## unique oauth id t.string :provider - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Tokens if json_supported_database? diff --git a/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb b/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb index 2518ebb33..b40b3f08a 100644 --- a/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +++ b/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb @@ -5,10 +5,10 @@ def change create_table(:only_email_users) do |t| ## Required t.string :provider, :null => false - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable #t.string :reset_password_token diff --git a/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb b/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb index 19c7c46b2..411d1bc68 100644 --- a/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +++ b/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb @@ -5,10 +5,10 @@ def change create_table(:unregisterable_users) do |t| ## Required t.string :provider, :null => false - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable t.string :reset_password_token diff --git a/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb b/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb index 81c3b47c4..243ec76a8 100644 --- a/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +++ b/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb @@ -5,10 +5,10 @@ def change create_table(:nice_users) do |t| ## Required t.string :provider, :null => false - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable t.string :reset_password_token diff --git a/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb b/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb index 34ca72b89..bd5678692 100644 --- a/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +++ b/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb @@ -5,10 +5,10 @@ def change create_table(:unconfirmable_users) do |t| ## Required t.string :provider, :null => false - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable t.string :reset_password_token diff --git a/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb b/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb index 31c7f750d..147f57bb0 100644 --- a/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +++ b/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb @@ -5,10 +5,10 @@ def change create_table(:scoped_users) do |t| ## Required t.string :provider, :null => false - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable t.string :reset_password_token diff --git a/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb b/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb index 990844135..9da9930da 100644 --- a/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +++ b/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb @@ -5,10 +5,10 @@ def change create_table(:lockable_users) do |t| ## Required t.string :provider, :null => false - t.string :uid, :null => false, :default => "" + t.string :uid, :null => false, :default => '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => "" + t.string :encrypted_password, :null => false, :default => '' ## Recoverable # t.string :reset_password_token diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 292cf3ee8..6012fe79f 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -12,247 +12,247 @@ ActiveRecord::Schema.define(version: 20160629184441) do - create_table "evil_users", force: :cascade do |t| - t.string "email" - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.boolean "allow_password_change", default: false - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "name" - t.string "nickname" - t.string "image" - t.string "provider" - t.string "uid", default: "", null: false - t.text "tokens" - t.string "favorite_color" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["confirmation_token"], name: "index_evil_users_on_confirmation_token", unique: true - t.index ["email"], name: "index_evil_users_on_email" - t.index ["reset_password_token"], name: "index_evil_users_on_reset_password_token", unique: true - t.index ["uid", "provider"], name: "index_evil_users_on_uid_and_provider", unique: true + create_table 'evil_users', force: :cascade do |t| + t.string 'email' + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.boolean 'allow_password_change', default: false + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0, null: false + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.string 'confirmation_token' + t.datetime 'confirmed_at' + t.datetime 'confirmation_sent_at' + t.string 'unconfirmed_email' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'provider' + t.string 'uid', default: '', null: false + t.text 'tokens' + t.string 'favorite_color' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['confirmation_token'], name: 'index_evil_users_on_confirmation_token', unique: true + t.index ['email'], name: 'index_evil_users_on_email' + t.index ['reset_password_token'], name: 'index_evil_users_on_reset_password_token', unique: true + t.index ['uid', 'provider'], name: 'index_evil_users_on_uid_and_provider', unique: true end - create_table "lockable_users", force: :cascade do |t| - t.string "provider", null: false - t.string "uid", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.integer "failed_attempts", default: 0, null: false - t.string "unlock_token" - t.datetime "locked_at" - t.string "name" - t.string "nickname" - t.string "image" - t.string "email" - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["email"], name: "index_lockable_users_on_email" - t.index ["uid", "provider"], name: "index_lockable_users_on_uid_and_provider", unique: true - t.index ["unlock_token"], name: "index_lockable_users_on_unlock_token", unique: true + create_table 'lockable_users', force: :cascade do |t| + t.string 'provider', null: false + t.string 'uid', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.integer 'failed_attempts', default: 0, null: false + t.string 'unlock_token' + t.datetime 'locked_at' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'email' + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['email'], name: 'index_lockable_users_on_email' + t.index ['uid', 'provider'], name: 'index_lockable_users_on_uid_and_provider', unique: true + t.index ['unlock_token'], name: 'index_lockable_users_on_unlock_token', unique: true end - create_table "mangs", force: :cascade do |t| - t.string "email" - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.string "reset_password_redirect_url" - t.boolean "allow_password_change", default: false - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "name" - t.string "nickname" - t.string "image" - t.string "provider" - t.string "uid", default: "", null: false - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.string "favorite_color" - t.index ["confirmation_token"], name: "index_mangs_on_confirmation_token", unique: true - t.index ["email"], name: "index_mangs_on_email" - t.index ["reset_password_token"], name: "index_mangs_on_reset_password_token", unique: true - t.index ["uid", "provider"], name: "index_mangs_on_uid_and_provider", unique: true + create_table 'mangs', force: :cascade do |t| + t.string 'email' + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.string 'reset_password_redirect_url' + t.boolean 'allow_password_change', default: false + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0, null: false + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.string 'confirmation_token' + t.datetime 'confirmed_at' + t.datetime 'confirmation_sent_at' + t.string 'unconfirmed_email' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'provider' + t.string 'uid', default: '', null: false + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.string 'favorite_color' + t.index ['confirmation_token'], name: 'index_mangs_on_confirmation_token', unique: true + t.index ['email'], name: 'index_mangs_on_email' + t.index ['reset_password_token'], name: 'index_mangs_on_reset_password_token', unique: true + t.index ['uid', 'provider'], name: 'index_mangs_on_uid_and_provider', unique: true end - create_table "nice_users", force: :cascade do |t| - t.string "provider", null: false - t.string "uid", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.boolean "allow_password_change", default: false - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "name" - t.string "nickname" - t.string "image" - t.string "email" - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["email"], name: "index_nice_users_on_email" - t.index ["reset_password_token"], name: "index_nice_users_on_reset_password_token", unique: true - t.index ["uid", "provider"], name: "index_nice_users_on_uid_and_provider", unique: true + create_table 'nice_users', force: :cascade do |t| + t.string 'provider', null: false + t.string 'uid', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.boolean 'allow_password_change', default: false + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0, null: false + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.string 'confirmation_token' + t.datetime 'confirmed_at' + t.datetime 'confirmation_sent_at' + t.string 'unconfirmed_email' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'email' + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['email'], name: 'index_nice_users_on_email' + t.index ['reset_password_token'], name: 'index_nice_users_on_reset_password_token', unique: true + t.index ['uid', 'provider'], name: 'index_nice_users_on_uid_and_provider', unique: true end - create_table "only_email_users", force: :cascade do |t| - t.string "provider", null: false - t.string "uid", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "name" - t.string "nickname" - t.string "image" - t.string "email" - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["email"], name: "index_only_email_users_on_email" - t.index ["uid", "provider"], name: "index_only_email_users_on_uid_and_provider", unique: true + create_table 'only_email_users', force: :cascade do |t| + t.string 'provider', null: false + t.string 'uid', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'email' + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['email'], name: 'index_only_email_users_on_email' + t.index ['uid', 'provider'], name: 'index_only_email_users_on_uid_and_provider', unique: true end - create_table "scoped_users", force: :cascade do |t| - t.string "provider", null: false - t.string "uid", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.boolean "allow_password_change", default: false - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "name" - t.string "nickname" - t.string "image" - t.string "email" - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["email"], name: "index_scoped_users_on_email" - t.index ["reset_password_token"], name: "index_scoped_users_on_reset_password_token", unique: true - t.index ["uid", "provider"], name: "index_scoped_users_on_uid_and_provider", unique: true + create_table 'scoped_users', force: :cascade do |t| + t.string 'provider', null: false + t.string 'uid', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.boolean 'allow_password_change', default: false + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0, null: false + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.string 'confirmation_token' + t.datetime 'confirmed_at' + t.datetime 'confirmation_sent_at' + t.string 'unconfirmed_email' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'email' + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['email'], name: 'index_scoped_users_on_email' + t.index ['reset_password_token'], name: 'index_scoped_users_on_reset_password_token', unique: true + t.index ['uid', 'provider'], name: 'index_scoped_users_on_uid_and_provider', unique: true end - create_table "unconfirmable_users", force: :cascade do |t| - t.string "provider", null: false - t.string "uid", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.boolean "allow_password_change", default: false - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "name" - t.string "nickname" - t.string "image" - t.string "email" - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["email"], name: "index_unconfirmable_users_on_email" - t.index ["reset_password_token"], name: "index_unconfirmable_users_on_reset_password_token", unique: true - t.index ["uid", "provider"], name: "index_unconfirmable_users_on_uid_and_provider", unique: true + create_table 'unconfirmable_users', force: :cascade do |t| + t.string 'provider', null: false + t.string 'uid', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.boolean 'allow_password_change', default: false + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0, null: false + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'email' + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['email'], name: 'index_unconfirmable_users_on_email' + t.index ['reset_password_token'], name: 'index_unconfirmable_users_on_reset_password_token', unique: true + t.index ['uid', 'provider'], name: 'index_unconfirmable_users_on_uid_and_provider', unique: true end - create_table "unregisterable_users", force: :cascade do |t| - t.string "provider", null: false - t.string "uid", default: "", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.boolean "allow_password_change", default: false - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "name" - t.string "nickname" - t.string "image" - t.string "email" - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.index ["email"], name: "index_unregisterable_users_on_email" - t.index ["reset_password_token"], name: "index_unregisterable_users_on_reset_password_token", unique: true - t.index ["uid", "provider"], name: "index_unregisterable_users_on_uid_and_provider", unique: true + create_table 'unregisterable_users', force: :cascade do |t| + t.string 'provider', null: false + t.string 'uid', default: '', null: false + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.boolean 'allow_password_change', default: false + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0, null: false + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.string 'confirmation_token' + t.datetime 'confirmed_at' + t.datetime 'confirmation_sent_at' + t.string 'unconfirmed_email' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'email' + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.index ['email'], name: 'index_unregisterable_users_on_email' + t.index ['reset_password_token'], name: 'index_unregisterable_users_on_reset_password_token', unique: true + t.index ['uid', 'provider'], name: 'index_unregisterable_users_on_uid_and_provider', unique: true end - create_table "users", force: :cascade do |t| - t.string "email" - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.string "reset_password_redirect_url" - t.boolean "allow_password_change", default: false - t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" - t.string "unconfirmed_email" - t.string "name" - t.string "nickname" - t.string "image" - t.string "provider" - t.string "uid", default: "", null: false - t.text "tokens" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "operating_thetan" - t.string "favorite_color" - t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true - t.index ["email"], name: "index_users_on_email" - t.index ["nickname"], name: "index_users_on_nickname", unique: true - t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true - t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true + create_table 'users', force: :cascade do |t| + t.string 'email' + t.string 'encrypted_password', default: '', null: false + t.string 'reset_password_token' + t.datetime 'reset_password_sent_at' + t.string 'reset_password_redirect_url' + t.boolean 'allow_password_change', default: false + t.datetime 'remember_created_at' + t.integer 'sign_in_count', default: 0, null: false + t.datetime 'current_sign_in_at' + t.datetime 'last_sign_in_at' + t.string 'current_sign_in_ip' + t.string 'last_sign_in_ip' + t.string 'confirmation_token' + t.datetime 'confirmed_at' + t.datetime 'confirmation_sent_at' + t.string 'unconfirmed_email' + t.string 'name' + t.string 'nickname' + t.string 'image' + t.string 'provider' + t.string 'uid', default: '', null: false + t.text 'tokens' + t.datetime 'created_at' + t.datetime 'updated_at' + t.integer 'operating_thetan' + t.string 'favorite_color' + t.index ['confirmation_token'], name: 'index_users_on_confirmation_token', unique: true + t.index ['email'], name: 'index_users_on_email' + t.index ['nickname'], name: 'index_users_on_nickname', unique: true + t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true + t.index ['uid', 'provider'], name: 'index_users_on_uid_and_provider', unique: true end end diff --git a/test/lib/devise_token_auth/url_test.rb b/test/lib/devise_token_auth/url_test.rb index 6f75a4526..df7830d82 100644 --- a/test/lib/devise_token_auth/url_test.rb +++ b/test/lib/devise_token_auth/url_test.rb @@ -1,23 +1,23 @@ require 'test_helper' class DeviseTokenAuth::UrlTest < ActiveSupport::TestCase - describe "DeviseTokenAuth::Url#generate" do + describe 'DeviseTokenAuth::Url#generate' do test 'URI fragment should appear at the end of URL' do params = {client_id: 123} url = 'http://example.com#fragment' - assert_equal DeviseTokenAuth::Url.send(:generate, url, params), "http://example.com?client_id=123#fragment" + assert_equal DeviseTokenAuth::Url.send(:generate, url, params), 'http://example.com?client_id=123#fragment' end describe 'with existing query params' do test 'should preserve existing query params' do url = 'http://example.com?a=1' - assert_equal DeviseTokenAuth::Url.send(:generate, url), "http://example.com?a=1" + assert_equal DeviseTokenAuth::Url.send(:generate, url), 'http://example.com?a=1' end test 'should marge existing query params with new ones' do params = {client_id: 123} url = 'http://example.com?a=1' - assert_equal DeviseTokenAuth::Url.send(:generate, url, params), "http://example.com?a=1&client_id=123" + assert_equal DeviseTokenAuth::Url.send(:generate, url, params), 'http://example.com?a=1&client_id=123' end end end diff --git a/test/lib/generators/devise_token_auth/install_generator_test.rb b/test/lib/generators/devise_token_auth/install_generator_test.rb index a6a7ce2a8..14d6fbeae 100644 --- a/test/lib/generators/devise_token_auth/install_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_test.rb @@ -45,9 +45,9 @@ class InstallGeneratorTest < Rails::Generators::TestCase setup :prepare_destination before do - @dir = File.join(destination_root, "app", "models") + @dir = File.join(destination_root, 'app', 'models') - @fname = File.join(@dir, "user.rb") + @fname = File.join(@dir, 'user.rb') # make dir if not exists FileUtils.mkdir_p(@dir) @@ -88,9 +88,9 @@ def whatever setup :prepare_destination before do - @dir = File.join(destination_root, "config") + @dir = File.join(destination_root, 'config') - @fname = File.join(@dir, "routes.rb") + @fname = File.join(@dir, 'routes.rb') # make dir if not exists FileUtils.mkdir_p(@dir) @@ -148,9 +148,9 @@ def whatever setup :prepare_destination before do - @dir = File.join(destination_root, "app", "controllers") + @dir = File.join(destination_root, 'app', 'controllers') - @fname = File.join(@dir, "application_controller.rb") + @fname = File.join(@dir, 'application_controller.rb') # make dir if not exists FileUtils.mkdir_p(@dir) diff --git a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb index da6765d3d..fb89d1a43 100644 --- a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb @@ -8,9 +8,9 @@ class InstallGeneratorTest < Rails::Generators::TestCase destination Rails.root.join('tmp/generators') # The namespaced user model for testing - let(:user_class) { "Azpire::V1::HumanResource::User" } + let(:user_class) { 'Azpire::V1::HumanResource::User' } let(:namespace_path) { user_class.underscore } - let(:table_name) { user_class.pluralize.underscore.gsub("/","_") } + let(:table_name) { user_class.pluralize.underscore.gsub('/','_') } describe 'user model with namespace, clean install' do setup :prepare_destination @@ -50,9 +50,9 @@ class InstallGeneratorTest < Rails::Generators::TestCase setup :prepare_destination before do - @dir = File.join(destination_root, "app", "models") + @dir = File.join(destination_root, 'app', 'models') - @fname = File.join(@dir, "user.rb") + @fname = File.join(@dir, 'user.rb') # make dir if not exists FileUtils.mkdir_p(@dir) @@ -93,9 +93,9 @@ def whatever setup :prepare_destination before do - @dir = File.join(destination_root, "config") + @dir = File.join(destination_root, 'config') - @fname = File.join(@dir, "routes.rb") + @fname = File.join(@dir, 'routes.rb') # make dir if not exists FileUtils.mkdir_p(@dir) @@ -153,9 +153,9 @@ def whatever setup :prepare_destination before do - @dir = File.join(destination_root, "app", "controllers") + @dir = File.join(destination_root, 'app', 'controllers') - @fname = File.join(@dir, "application_controller.rb") + @fname = File.join(@dir, 'application_controller.rb') # make dir if not exists FileUtils.mkdir_p(@dir) diff --git a/test/lib/generators/devise_token_auth/install_views_generator_test.rb b/test/lib/generators/devise_token_auth/install_views_generator_test.rb index 33e2c7102..e1dd2ee7f 100644 --- a/test/lib/generators/devise_token_auth/install_views_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_views_generator_test.rb @@ -14,7 +14,7 @@ class InstallViewsGeneratorTest < Rails::Generators::TestCase run_generator end - test "files are copied" do + test 'files are copied' do assert_file 'app/views/devise/mailer/reset_password_instructions.html.erb' assert_file 'app/views/devise/mailer/confirmation_instructions.html.erb' end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index fddceb37d..1689383b2 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -31,7 +31,7 @@ class UserTest < ActiveSupport::TestCase @resource.password_confirmation = @password refute @resource.save - assert @resource.errors.messages[:email] == [I18n.t("errors.messages.blank")] + assert @resource.errors.messages[:email] == [I18n.t('errors.messages.blank')] end test 'model should not save if email is not an email' do @@ -41,7 +41,7 @@ class UserTest < ActiveSupport::TestCase @resource.password_confirmation = @password refute @resource.save - assert @resource.errors.messages[:email] == [I18n.t("errors.messages.not_email")] + assert @resource.errors.messages[:email] == [I18n.t('errors.messages.not_email')] end end @@ -149,7 +149,7 @@ def @resource.token_lifespan end test 'current token was not removed' do - assert @resource.tokens[@new_auth_headers["client"]] + assert @resource.tokens[@new_auth_headers['client']] end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 90c78131e..43b0f8017 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -60,7 +60,7 @@ def expire_token(user, client_id) # Suppress OmniAuth logger output def silence_omniauth previous_logger = OmniAuth.config.logger - OmniAuth.config.logger = Logger.new("/dev/null") + OmniAuth.config.logger = Logger.new('/dev/null') yield ensure OmniAuth.config.logger = previous_logger From ab89dba3c5e46ff5e071a167aef3f17a733ba9b6 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 17:28:58 -0700 Subject: [PATCH 06/54] Move `Style/FrozenStringLiteralComment` from todos to main config. - This Cop is for future Ruby. Skip it for now; it works with the `--auto-correct` option, making future application trivial. --- .rubocop.yml | 16 ++++++++++++++++ .rubocop_todo.yml | 7 ------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index d82935a3e..a3310e90f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,3 +3,19 @@ inherit_from: .rubocop_todo.yml AllCops: Exclude: - 'coverage/**/*' + +# Offense count: 130 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: when_needed, always, never +# +# Description from Rubocop Manual: +# This cop is designed to help upgrade to Ruby 3.0. It will add the comment +# `# frozen_string_literal: true` to the top of files to enable frozen string +# literals. Frozen string literals may be default in Ruby 3.0. The comment +# will be added below a shebang and encoding comment. The frozen string +# literal comment is only valid in Ruby 2.3+. +# +# https://rubocop.readthedocs.io/en/latest/cops_style/#stylefrozenstringliteralcomment +Style/FrozenStringLiteralComment: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b5e95b768..f5c151e84 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -543,13 +543,6 @@ Style/ExpandPathArguments: - 'test/dummy/config/environment.rb' - 'test/test_helper.rb' -# Offense count: 130 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: when_needed, always, never -Style/FrozenStringLiteralComment: - Enabled: false - # Offense count: 12 # Configuration parameters: MinBodyLength. Style/GuardClause: From bfc0edecbd0a28809aa7f120ff5215ef93e1635b Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 18:02:09 -0700 Subject: [PATCH 07/54] Move `Style/ClassAndModuleChildren` from todos to main config. - This Cop forces either nested or compact module declarations. While nested may be considered best practice, changing these up may lead to all kinds of merge conflicts on open PRs. --- .rubocop.yml | 10 ++++++++++ .rubocop_todo.yml | 7 ------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a3310e90f..27bc1e9c1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -19,3 +19,13 @@ AllCops: # https://rubocop.readthedocs.io/en/latest/cops_style/#stylefrozenstringliteralcomment Style/FrozenStringLiteralComment: Enabled: false + +# Offense count: 34 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: nested, compact +# +# Description from Rubocop Manual: +# https://rubocop.readthedocs.io/en/latest/cops_style/#styleclassandmodulechildren +Style/ClassAndModuleChildren: + Enabled: false \ No newline at end of file diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f5c151e84..cba7f98c5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -468,13 +468,6 @@ Style/BracesAroundHashParameters: - 'test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb' - 'test/dummy/app/controllers/overrides/passwords_controller.rb' -# Offense count: 34 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Enabled: false - # Offense count: 2 # Cop supports --auto-correct. Style/ColonMethodCall: From deb1be28d332b30706db35ae5a6c433c08a26618 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 18:52:03 -0700 Subject: [PATCH 08/54] Fix `Style/HashSyntax` - Move `Style/HashSyntax` from todos to main config, and set enforced style to `ruby19`--i.e. `{foo: :bar}`. - Update hash syntax from hash-rockets to ruby 1.9 style. - Update hash syntax to ruby 1.9 style in test-dummy rails app. --- .rubocop.yml | 15 ++++++++++++++- .rubocop_todo.yml | 7 ------- .../omniauth_callbacks_controller.rb | 2 +- .../devise_token_auth/passwords_controller.rb | 4 ++-- .../devise_token_auth/sessions_controller.rb | 4 ++-- .../token_validations_controller.rb | 4 ++-- .../devise_token_auth/unlocks_controller.rb | 2 +- lib/devise_token_auth/engine.rb | 10 +++++----- lib/devise_token_auth/rails/routes.rb | 18 +++++++++--------- test/dummy/config.ru | 6 +++--- test/dummy/config/environments/development.rb | 4 ++-- test/dummy/config/environments/test.rb | 2 +- test/dummy/config/initializers/omniauth.rb | 4 ++-- ...715061447_devise_token_auth_create_users.rb | 16 ++++++++-------- ...715061805_devise_token_auth_create_mangs.rb | 14 +++++++------- ...1203_devise_token_auth_create_evil_users.rb | 14 +++++++------- ...evise_token_auth_create_only_email_users.rb | 8 ++++---- ...e_token_auth_create_unregisterable_users.rb | 14 +++++++------- ...5712_devise_token_auth_create_nice_users.rb | 14 +++++++------- ...se_token_auth_create_unconfirmable_users.rb | 14 +++++++------- ...41_devise_token_auth_create_scoped_users.rb | 14 +++++++------- ..._devise_token_auth_create_lockable_users.rb | 12 ++++++------ 22 files changed, 104 insertions(+), 98 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 27bc1e9c1..75634e20b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -28,4 +28,17 @@ Style/FrozenStringLiteralComment: # Description from Rubocop Manual: # https://rubocop.readthedocs.io/en/latest/cops_style/#styleclassandmodulechildren Style/ClassAndModuleChildren: - Enabled: false \ No newline at end of file + Enabled: false + +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, +# PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# +# Description from Rubocop Manual: +# This cop checks hash literal syntax +# +# https://rubocop.readthedocs.io/en/latest/cops_style/#stylehashsyntax +Style/HashSyntax: + Enabled: true + EnforcedStyle: ruby19 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cba7f98c5..34d8126d1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -550,13 +550,6 @@ Style/GuardClause: - 'test/dummy/app/models/user.rb' - 'test/test_helper.rb' -# Offense count: 127 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -Style/HashSyntax: - Enabled: false - # Offense count: 23 # Cop supports --auto-correct. Style/IfUnlessModifier: diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 071dc1f23..5b847ccb7 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -176,7 +176,7 @@ def render_data(message, data) @data = data.merge({ message: message }) - render :layout => nil, :template => 'devise_token_auth/omniauth_external_window' + render layout: nil, template: 'devise_token_auth/omniauth_external_window' end def render_data_or_redirect(message, data, user_data = {}) diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index 48c73eacb..91176b88e 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -1,7 +1,7 @@ module DeviseTokenAuth class PasswordsController < DeviseTokenAuth::ApplicationController - before_action :set_user_by_token, :only => [:update] - skip_after_action :update_auth_header, :only => [:create, :edit] + before_action :set_user_by_token, only: [:update] + skip_after_action :update_auth_header, only: [:create, :edit] # this action is responsible for generating password reset tokens and # sending emails diff --git a/app/controllers/devise_token_auth/sessions_controller.rb b/app/controllers/devise_token_auth/sessions_controller.rb index 058ff0ae0..a89d8f40e 100644 --- a/app/controllers/devise_token_auth/sessions_controller.rb +++ b/app/controllers/devise_token_auth/sessions_controller.rb @@ -1,8 +1,8 @@ # see http://www.emilsoman.com/blog/2013/05/18/building-a-tested/ module DeviseTokenAuth class SessionsController < DeviseTokenAuth::ApplicationController - before_action :set_user_by_token, :only => [:destroy] - after_action :reset_session, :only => [:destroy] + before_action :set_user_by_token, only: [:destroy] + after_action :reset_session, only: [:destroy] def new render_new_error diff --git a/app/controllers/devise_token_auth/token_validations_controller.rb b/app/controllers/devise_token_auth/token_validations_controller.rb index cdb21d11b..68f07a8f7 100644 --- a/app/controllers/devise_token_auth/token_validations_controller.rb +++ b/app/controllers/devise_token_auth/token_validations_controller.rb @@ -1,7 +1,7 @@ module DeviseTokenAuth class TokenValidationsController < DeviseTokenAuth::ApplicationController - skip_before_action :assert_is_devise_resource!, :only => [:validate_token] - before_action :set_user_by_token, :only => [:validate_token] + skip_before_action :assert_is_devise_resource!, only: [:validate_token] + before_action :set_user_by_token, only: [:validate_token] def validate_token # @resource will have been set by set_user_by_token concern diff --git a/app/controllers/devise_token_auth/unlocks_controller.rb b/app/controllers/devise_token_auth/unlocks_controller.rb index d392c7c5c..82b984ce1 100644 --- a/app/controllers/devise_token_auth/unlocks_controller.rb +++ b/app/controllers/devise_token_auth/unlocks_controller.rb @@ -1,6 +1,6 @@ module DeviseTokenAuth class UnlocksController < DeviseTokenAuth::ApplicationController - skip_after_action :update_auth_header, :only => [:create, :show] + skip_after_action :update_auth_header, only: [:create, :show] # this action is responsible for generating unlock tokens and # sending emails diff --git a/lib/devise_token_auth/engine.rb b/lib/devise_token_auth/engine.rb index 127db27a2..3302bed0b 100644 --- a/lib/devise_token_auth/engine.rb +++ b/lib/devise_token_auth/engine.rb @@ -36,11 +36,11 @@ class Engine < ::Rails::Engine self.enable_standard_devise_support = false self.remove_tokens_after_password_reset = false self.default_callbacks = true - self.headers_names = {:'access-token' => 'access-token', - :'client' => 'client', - :'expiry' => 'expiry', - :'uid' => 'uid', - :'token-type' => 'token-type' } + self.headers_names = {'access-token': 'access-token', + 'client': 'client', + 'expiry': 'expiry', + 'uid': 'uid', + 'token-type': 'token-type' } self.bypass_sign_in = true def self.setup(&block) diff --git a/lib/devise_token_auth/rails/routes.rb b/lib/devise_token_auth/rails/routes.rb index 766faefc7..b77e7e226 100644 --- a/lib/devise_token_auth/rails/routes.rb +++ b/lib/devise_token_auth/rails/routes.rb @@ -15,10 +15,10 @@ def mount_devise_token_auth_for(resource, opts) unlocks_ctrl = opts[:controllers][:unlocks] || 'devise_token_auth/unlocks' # define devise controller mappings - controllers = {:sessions => sessions_ctrl, - :registrations => registrations_ctrl, - :passwords => passwords_ctrl, - :confirmations => confirmations_ctrl} + controllers = {sessions: sessions_ctrl, + registrations: registrations_ctrl, + passwords: passwords_ctrl, + confirmations: confirmations_ctrl} controllers[:unlocks] = unlocks_ctrl if unlocks_ctrl @@ -26,11 +26,11 @@ def mount_devise_token_auth_for(resource, opts) opts[:skip].each{|item| controllers.delete(item)} devise_for resource.pluralize.underscore.gsub('/', '_').to_sym, - :class_name => resource, - :module => :devise, - :path => "#{opts[:at]}", - :controllers => controllers, - :skip => opts[:skip] + [:omniauth_callbacks] + class_name: resource, + module: :devise, + path: "#{opts[:at]}", + controllers: controllers, + skip: opts[:skip] + [:omniauth_callbacks] unnest_namespace do # get full url path as if it were namespaced diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 0a867388d..0751990f2 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -9,8 +9,8 @@ use Rack::Cors do allow do origins '*' resource '*', - :headers => :any, - :expose => ['access-token', 'expiry', 'token-type', 'uid', 'client'], - :methods => [:get, :post, :options, :delete, :put] + headers: :any, + expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'], + methods: [:get, :post, :options, :delete, :put] end end diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 3a67b510c..8392cf27c 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -17,9 +17,9 @@ config.action_mailer.raise_delivery_errors = true # use mailcatcher for development - config.action_mailer.default_url_options = { :host => 'devise-token-auth.dev' } + config.action_mailer.default_url_options = { host: 'devise-token-auth.dev' } config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { :address => 'localhost', :port => 1025 } + config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 } # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 4fd5b040b..3a9d642de 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -35,7 +35,7 @@ # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - config.action_mailer.default_url_options = { :host => 'localhost' } + config.action_mailer.default_url_options = { host: 'localhost' } # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/test/dummy/config/initializers/omniauth.rb b/test/dummy/config/initializers/omniauth.rb index 93376412f..05591c8c9 100644 --- a/test/dummy/config/initializers/omniauth.rb +++ b/test/dummy/config/initializers/omniauth.rb @@ -3,6 +3,6 @@ provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'] provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'] provider :developer, - :fields => [:first_name, :last_name], - :uid_field => :last_name + fields: [:first_name, :last_name], + uid_field: :last_name end diff --git a/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb b/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb index b7939784a..799f23eda 100644 --- a/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb +++ b/test/dummy/db/migrate/20140715061447_devise_token_auth_create_users.rb @@ -5,19 +5,19 @@ def change create_table(:users) do |t| ## Database authenticatable t.string :email - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at t.string :reset_password_redirect_url - t.boolean :allow_password_change, :default => false + t.boolean :allow_password_change, default: false ## Rememberable t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0, :null => false + t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -41,7 +41,7 @@ def change ## unique oauth id t.string :provider - t.string :uid, :null => false, :default => '' + t.string :uid, null: false, default: '' ## Tokens if json_supported_database? @@ -54,10 +54,10 @@ def change end add_index :users, :email - add_index :users, [:uid, :provider], :unique => true - add_index :users, :reset_password_token, :unique => true - add_index :users, :confirmation_token, :unique => true - add_index :users, :nickname, :unique => true + add_index :users, [:uid, :provider], unique: true + add_index :users, :reset_password_token, unique: true + add_index :users, :confirmation_token, unique: true + add_index :users, :nickname, unique: true # add_index :users, :unlock_token, :unique => true end end diff --git a/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb b/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb index 1cc25bb99..264a8793e 100644 --- a/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb +++ b/test/dummy/db/migrate/20140715061805_devise_token_auth_create_mangs.rb @@ -5,19 +5,19 @@ def change create_table(:mangs) do |t| ## Database authenticatable t.string :email - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at t.string :reset_password_redirect_url - t.boolean :allow_password_change, :default => false + t.boolean :allow_password_change, default: false ## Rememberable t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0, :null => false + t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -41,7 +41,7 @@ def change ## unique oauth id t.string :provider - t.string :uid, :null => false, :default => '' + t.string :uid, null: false, default: '' ## Tokens if json_supported_database? @@ -54,9 +54,9 @@ def change end add_index :mangs, :email - add_index :mangs, [:uid, :provider], :unique => true - add_index :mangs, :reset_password_token, :unique => true - add_index :mangs, :confirmation_token, :unique => true + add_index :mangs, [:uid, :provider], unique: true + add_index :mangs, :reset_password_token, unique: true + add_index :mangs, :confirmation_token, unique: true # add_index :mangs, :unlock_token, :unique => true end end diff --git a/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb b/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb index 8f7a69893..e19470970 100644 --- a/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb +++ b/test/dummy/db/migrate/20140928231203_devise_token_auth_create_evil_users.rb @@ -5,18 +5,18 @@ def change create_table(:evil_users) do |t| ## Database authenticatable t.string :email - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at - t.boolean :allow_password_change, :default => false + t.boolean :allow_password_change, default: false ## Rememberable t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0, :null => false + t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -40,7 +40,7 @@ def change ## unique oauth id t.string :provider - t.string :uid, :null => false, :default => '' + t.string :uid, null: false, default: '' ## Tokens if json_supported_database? @@ -56,9 +56,9 @@ def change end add_index :evil_users, :email - add_index :evil_users, [:uid, :provider], :unique => true - add_index :evil_users, :reset_password_token, :unique => true - add_index :evil_users, :confirmation_token, :unique => true + add_index :evil_users, [:uid, :provider], unique: true + add_index :evil_users, :reset_password_token, unique: true + add_index :evil_users, :confirmation_token, unique: true # add_index :evil_users, :unlock_token, :unique => true end end diff --git a/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb b/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb index b40b3f08a..cdc415c24 100644 --- a/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb +++ b/test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb @@ -4,11 +4,11 @@ class DeviseTokenAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2] def change create_table(:only_email_users) do |t| ## Required - t.string :provider, :null => false - t.string :uid, :null => false, :default => '' + t.string :provider, null: false + t.string :uid, null: false, default: '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable #t.string :reset_password_token @@ -52,7 +52,7 @@ def change end add_index :only_email_users, :email - add_index :only_email_users, [:uid, :provider], :unique => true + add_index :only_email_users, [:uid, :provider], unique: true #add_index :only_email_users, :reset_password_token, :unique => true # add_index :only_email_users, :confirmation_token, :unique => true # add_index :only_email_users, :unlock_token, :unique => true diff --git a/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb b/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb index 411d1bc68..f2e292f58 100644 --- a/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb +++ b/test/dummy/db/migrate/20141222053502_devise_token_auth_create_unregisterable_users.rb @@ -4,22 +4,22 @@ class DeviseTokenAuthCreateUnregisterableUsers < ActiveRecord::Migration[4.2] def change create_table(:unregisterable_users) do |t| ## Required - t.string :provider, :null => false - t.string :uid, :null => false, :default => '' + t.string :provider, null: false + t.string :uid, null: false, default: '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at - t.boolean :allow_password_change, :default => false + t.boolean :allow_password_change, default: false ## Rememberable t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0, :null => false + t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -53,8 +53,8 @@ def change end add_index :unregisterable_users, :email - add_index :unregisterable_users, [:uid, :provider], :unique => true - add_index :unregisterable_users, :reset_password_token, :unique => true + add_index :unregisterable_users, [:uid, :provider], unique: true + add_index :unregisterable_users, :reset_password_token, unique: true # add_index :unregisterable_users, :confirmation_token, :unique => true # add_index :unregisterable_users, :unlock_token, :unique => true end diff --git a/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb b/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb index 243ec76a8..334a4275a 100644 --- a/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb +++ b/test/dummy/db/migrate/20150409095712_devise_token_auth_create_nice_users.rb @@ -4,22 +4,22 @@ class DeviseTokenAuthCreateNiceUsers < ActiveRecord::Migration[4.2] def change create_table(:nice_users) do |t| ## Required - t.string :provider, :null => false - t.string :uid, :null => false, :default => '' + t.string :provider, null: false + t.string :uid, null: false, default: '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at - t.boolean :allow_password_change, :default => false + t.boolean :allow_password_change, default: false ## Rememberable t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0, :null => false + t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -53,8 +53,8 @@ def change end add_index :nice_users, :email - add_index :nice_users, [:uid, :provider], :unique => true - add_index :nice_users, :reset_password_token, :unique => true + add_index :nice_users, [:uid, :provider], unique: true + add_index :nice_users, :reset_password_token, unique: true # add_index :nice_users, :confirmation_token, :unique => true # add_index :nice_users, :unlock_token, :unique => true end diff --git a/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb b/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb index bd5678692..35da2d318 100644 --- a/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb +++ b/test/dummy/db/migrate/20150708104536_devise_token_auth_create_unconfirmable_users.rb @@ -4,22 +4,22 @@ class DeviseTokenAuthCreateUnconfirmableUsers < ActiveRecord::Migration[4.2] def change create_table(:unconfirmable_users) do |t| ## Required - t.string :provider, :null => false - t.string :uid, :null => false, :default => '' + t.string :provider, null: false + t.string :uid, null: false, default: '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at - t.boolean :allow_password_change, :default => false + t.boolean :allow_password_change, default: false ## Rememberable t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0, :null => false + t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -53,8 +53,8 @@ def change end add_index :unconfirmable_users, :email - add_index :unconfirmable_users, [:uid, :provider], :unique => true - add_index :unconfirmable_users, :reset_password_token, :unique => true + add_index :unconfirmable_users, [:uid, :provider], unique: true + add_index :unconfirmable_users, :reset_password_token, unique: true # add_index :nice_users, :confirmation_token, :unique => true # add_index :nice_users, :unlock_token, :unique => true end diff --git a/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb b/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb index 147f57bb0..51f2f0dde 100644 --- a/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb +++ b/test/dummy/db/migrate/20160103235141_devise_token_auth_create_scoped_users.rb @@ -4,22 +4,22 @@ class DeviseTokenAuthCreateScopedUsers < ActiveRecord::Migration[4.2] def change create_table(:scoped_users) do |t| ## Required - t.string :provider, :null => false - t.string :uid, :null => false, :default => '' + t.string :provider, null: false + t.string :uid, null: false, default: '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at - t.boolean :allow_password_change, :default => false + t.boolean :allow_password_change, default: false ## Rememberable t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0, :null => false + t.integer :sign_in_count, default: 0, null: false t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -53,8 +53,8 @@ def change end add_index :scoped_users, :email - add_index :scoped_users, [:uid, :provider], :unique => true - add_index :scoped_users, :reset_password_token, :unique => true + add_index :scoped_users, [:uid, :provider], unique: true + add_index :scoped_users, :reset_password_token, unique: true # add_index :scoped_users, :confirmation_token, :unique => true # add_index :scoped_users, :unlock_token, :unique => true end diff --git a/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb b/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb index 9da9930da..9955f139c 100644 --- a/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb +++ b/test/dummy/db/migrate/20160629184441_devise_token_auth_create_lockable_users.rb @@ -4,11 +4,11 @@ class DeviseTokenAuthCreateLockableUsers < ActiveRecord::Migration[4.2] def change create_table(:lockable_users) do |t| ## Required - t.string :provider, :null => false - t.string :uid, :null => false, :default => '' + t.string :provider, null: false + t.string :uid, null: false, default: '' ## Database authenticatable - t.string :encrypted_password, :null => false, :default => '' + t.string :encrypted_password, null: false, default: '' ## Recoverable # t.string :reset_password_token @@ -32,7 +32,7 @@ def change # t.string :unconfirmed_email # Only if using reconfirmable ## Lockable - t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts + t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts t.string :unlock_token # Only if unlock strategy is :email or :both t.datetime :locked_at @@ -53,9 +53,9 @@ def change end add_index :lockable_users, :email - add_index :lockable_users, [:uid, :provider], :unique => true + add_index :lockable_users, [:uid, :provider], unique: true # add_index :lockable_users, :reset_password_token, :unique => true # add_index :lockable_users, :confirmation_token, :unique => true - add_index :lockable_users, :unlock_token, :unique => true + add_index :lockable_users, :unlock_token, unique: true end end From 022e8329d7f85de843d8cd3738d5bc0f64043fb9 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 19:11:36 -0700 Subject: [PATCH 09/54] Fix `Style/SymbolArray` - Move `Style/SymbolArray` from todos to main config: * Set enforced style to 'percent' -- i.e. `%i[]`. * Don't enforce on arrays with < 3 elements. - Use percent array literals for large arrays of symbols. - Use percent array literals for large arrays of symbols. --- .rubocop.yml | 14 ++++++++++++++ .rubocop_todo.yml | 7 ------- app/models/devise_token_auth/concerns/user.rb | 2 +- .../controllers/overrides/sessions_controller.rb | 4 +--- .../overrides/token_validations_controller.rb | 4 +--- test/dummy/config.ru | 2 +- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 75634e20b..97d71acd0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -42,3 +42,17 @@ Style/ClassAndModuleChildren: Style/HashSyntax: Enabled: true EnforcedStyle: ruby19 + +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinSize. +# SupportedStyles: percent, brackets +# +# Description from Rubocop Manual: +# Check for array literals made up of symbols that are not using +# the `%i()` syntax. +# +# https://rubocop.readthedocs.io/en/latest/cops_style/#stylesymbolarray +Style/SymbolArray: + Enabled: true + EnforcedStyle: percent + MinSize: 3 diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 34d8126d1..0ff579eb9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -752,13 +752,6 @@ Style/SpecialGlobalVars: Exclude: - 'devise_token_auth.gemspec' -# Offense count: 24 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinSize. -# SupportedStyles: percent, brackets -Style/SymbolArray: - Enabled: false - # Offense count: 10 # Cop supports --auto-correct. Style/SymbolLiteral: diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 4eeae40df..8b28e9ad8 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -216,7 +216,7 @@ def confirmed? end def token_validation_response - as_json(except: [:tokens, :created_at, :updated_at]) + as_json(except: %i[tokens created_at updated_at]) end def token_lifespan diff --git a/test/dummy/app/controllers/overrides/sessions_controller.rb b/test/dummy/app/controllers/overrides/sessions_controller.rb index 2c73ce0e9..18178202f 100644 --- a/test/dummy/app/controllers/overrides/sessions_controller.rb +++ b/test/dummy/app/controllers/overrides/sessions_controller.rb @@ -10,9 +10,7 @@ def create @resource.save render json: { - data: @resource.as_json(except: [ - :tokens, :created_at, :updated_at - ]), + data: @resource.as_json(except: %i[tokens created_at updated_at]), override_proof: OVERRIDE_PROOF } diff --git a/test/dummy/app/controllers/overrides/token_validations_controller.rb b/test/dummy/app/controllers/overrides/token_validations_controller.rb index 057a2865d..b8160cc2f 100644 --- a/test/dummy/app/controllers/overrides/token_validations_controller.rb +++ b/test/dummy/app/controllers/overrides/token_validations_controller.rb @@ -7,9 +7,7 @@ def validate_token if @resource render json: { success: true, - data: @resource.as_json(except: [ - :tokens, :created_at, :updated_at - ]), + data: @resource.as_json(except: %i[tokens created_at updated_at]), override_proof: OVERRIDE_PROOF } else diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 0751990f2..8c6d62ca3 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -11,6 +11,6 @@ use Rack::Cors do resource '*', headers: :any, expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'], - methods: [:get, :post, :options, :delete, :put] + methods: %i[get post options delete put] end end From 88b9e47c87e232c3aded12ba8ab819cbb8702c9a Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 19:21:36 -0700 Subject: [PATCH 10/54] Update `Style/Documentation` todo to specify files with Cop violations. --- .rubocop_todo.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0ff579eb9..4e69af0a7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -497,7 +497,30 @@ Style/DateTime: # Offense count: 24 Style/Documentation: - Enabled: false + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/controllers/devise_token_auth/confirmations_controller.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/registrations_controller.rb' + - 'app/controllers/devise_token_auth/sessions_controller.rb' + - 'app/controllers/devise_token_auth/token_validations_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb' + - 'app/validators/email_validator.rb' + - 'lib/devise_token_auth.rb' + - 'lib/devise_token_auth/controllers/helpers.rb' + - 'lib/devise_token_auth/controllers/url_helpers.rb' + - 'lib/devise_token_auth/engine.rb' + - 'lib/devise_token_auth/rails/routes.rb' + - 'lib/devise_token_auth/url.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + - 'lib/generators/devise_token_auth/install_views_generator.rb' # Offense count: 3 Style/DoubleNegation: From 00672ad003f06092503dc160c9b09859f849681e Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 23 Mar 2018 19:23:50 -0700 Subject: [PATCH 11/54] Update offense counts in rubocop todo list. --- .rubocop_todo.yml | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4e69af0a7..e6000160e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config` -# on 2018-03-22 16:26:38 -0700 using RuboCop version 0.54.0. +# `rubocop --auto-gen-config --exclude-limit 30` +# on 2018-03-23 19:22:33 -0700 using RuboCop version 0.54.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 @@ -35,7 +35,7 @@ Layout/CommentIndentation: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' -# Offense count: 6 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: @@ -100,13 +100,6 @@ Layout/ExtraSpacing: - 'test/dummy/config/initializers/omniauth.rb' - 'test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: - EnforcedStyle: consistent - # Offense count: 14 # Cop supports --auto-correct. # Configuration parameters: IndentationWidth. @@ -341,7 +334,7 @@ Lint/Void: Exclude: - 'test/dummy/tmp/history.rb' -# Offense count: 35 +# Offense count: 36 Metrics/AbcSize: Max: 74 @@ -359,7 +352,7 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 17 -# Offense count: 36 +# Offense count: 37 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 63 @@ -775,14 +768,13 @@ Style/SpecialGlobalVars: Exclude: - 'devise_token_auth.gemspec' -# Offense count: 10 +# Offense count: 7 # Cop supports --auto-correct. Style/SymbolLiteral: Exclude: - 'app/controllers/devise_token_auth/application_controller.rb' - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/engine.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -847,7 +839,7 @@ Style/ZeroLengthPredicate: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 329 +# Offense count: 326 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: From 7418df4c998c3865156fc9a7e417ec2ffc3f199d Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Mon, 26 Mar 2018 13:41:13 -0700 Subject: [PATCH 12/54] Update `parser` gem. When `rubocop` was added, the `parser` gem was added as a dependency. Unfortunately, the version of parser specified in the `Gemfile.lock` was unpublished; must update to the newly released parser dependency. --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d0c2a050e..973312084 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -195,7 +195,7 @@ GEM omniauth (~> 1.2) orm_adapter (0.5.0) parallel (1.12.1) - parser (2.5.0.4) + parser (2.5.0.5) ast (~> 2.4.0) pg (0.20.0) powerpack (0.1.1) From 10359089a657179fd9b388e191c4c2682ade96d0 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 25 Mar 2018 20:39:34 +0300 Subject: [PATCH 13/54] Fix Style/TrailingCommaInHashLiteral --- .rubocop_todo.yml | 8 -------- app/controllers/devise_token_auth/passwords_controller.rb | 2 +- app/controllers/devise_token_auth/unlocks_controller.rb | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e6000160e..6d8926f09 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -793,14 +793,6 @@ Style/TernaryParentheses: - 'lib/generators/devise_token_auth/install_generator.rb' - 'test/lib/generators/devise_token_auth/install_generator_test.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInHashLiteral: - Exclude: - - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/unlocks_controller.rb' # Offense count: 4 # Cop supports --auto-correct. diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index 91176b88e..18128a972 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -143,7 +143,7 @@ def render_create_success def render_create_error(errors) render json: { success: false, - errors: errors, + errors: errors }, status: 400 end diff --git a/app/controllers/devise_token_auth/unlocks_controller.rb b/app/controllers/devise_token_auth/unlocks_controller.rb index 82b984ce1..9b85981c1 100644 --- a/app/controllers/devise_token_auth/unlocks_controller.rb +++ b/app/controllers/devise_token_auth/unlocks_controller.rb @@ -70,7 +70,7 @@ def render_create_success def render_create_error(errors) render json: { success: false, - errors: errors, + errors: errors }, status: 400 end From 3edb53b124c10409fed7ae921930f6b1e0ae1cc8 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 25 Mar 2018 20:47:42 +0300 Subject: [PATCH 14/54] Fix Style/PreferredHashMethods --- .rubocop_todo.yml | 7 ------- .../devise_token_auth/registrations_controller.rb | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6d8926f09..4c38e730a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -697,13 +697,6 @@ Style/PercentLiteralDelimiters: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'test/lib/generators/devise_token_auth/install_generator_test.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: short, verbose -Style/PreferredHashMethods: - Exclude: - - 'app/controllers/devise_token_auth/registrations_controller.rb' # Offense count: 5 # Cop supports --auto-correct. diff --git a/app/controllers/devise_token_auth/registrations_controller.rb b/app/controllers/devise_token_auth/registrations_controller.rb index c67a040c4..da6f6a211 100644 --- a/app/controllers/devise_token_auth/registrations_controller.rb +++ b/app/controllers/devise_token_auth/registrations_controller.rb @@ -181,9 +181,9 @@ def render_destroy_error def resource_update_method if DeviseTokenAuth.check_current_password_before_update == :attributes 'update_with_password' - elsif DeviseTokenAuth.check_current_password_before_update == :password && account_update_params.has_key?(:password) + elsif DeviseTokenAuth.check_current_password_before_update == :password && account_update_params.key?(:password) 'update_with_password' - elsif account_update_params.has_key?(:current_password) + elsif account_update_params.key?(:current_password) 'update_with_password' else 'update_attributes' From 7e3dffcf37f3b97256b190be9a90d9bfb6090f9a Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 25 Mar 2018 20:52:43 +0300 Subject: [PATCH 15/54] Fix Style/NegatedIf --- .rubocop_todo.yml | 8 -------- .../devise_token_auth/concerns/set_user_by_token.rb | 2 +- .../devise_token_auth/omniauth_callbacks_controller.rb | 2 +- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4c38e730a..6da6a011e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -641,14 +641,6 @@ Style/MutableConstant: - 'test/dummy/app/controllers/overrides/token_validations_controller.rb' - 'test/dummy/app/helpers/application_helper.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: both, prefix, postfix -Style/NegatedIf: - Exclude: - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' # Offense count: 1 # Cop supports --auto-correct. diff --git a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb index 384b7e8c4..cfb55d483 100644 --- a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +++ b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb @@ -70,7 +70,7 @@ def set_user_by_token(mapping=nil) return @resource if @resource && @resource.is_a?(rc) # ensure we clear the client_id - if !@token + unless @token @client_id = nil return end diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 5b847ccb7..0403c42d1 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -60,7 +60,7 @@ def omniauth_failure # after use. In the failure case, finally, the omniauth params # are added as query params in our monkey patch to OmniAuth in engine.rb def omniauth_params - if !defined?(@_omniauth_params) + unless defined?(@_omniauth_params) if request.env['omniauth.params'] && request.env['omniauth.params'].any? @_omniauth_params = request.env['omniauth.params'] elsif session['dta.omniauth.params'] && session['dta.omniauth.params'].any? From 185245f360885368be309f0984e9bb8fe1c241ec Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 25 Mar 2018 21:03:05 +0300 Subject: [PATCH 16/54] Fix Layout/SpaceInsideHashLiteralBraces --- .rubocop_todo.yml | 19 ------------------- .../confirmations_controller.rb | 2 +- .../omniauth_callbacks_controller.rb | 2 +- .../devise_token_auth/passwords_controller.rb | 2 +- .../devise_token_auth/unlocks_controller.rb | 2 +- app/models/devise_token_auth/concerns/user.rb | 2 +- lib/devise_token_auth/engine.rb | 10 +++++----- lib/devise_token_auth/rails/routes.rb | 8 ++++---- .../custom/passwords_controller.rb | 2 +- .../custom/registrations_controller.rb | 2 +- .../controllers/custom/sessions_controller.rb | 2 +- .../custom/token_validations_controller.rb | 2 +- test/lib/devise_token_auth/url_test.rb | 4 ++-- 13 files changed, 20 insertions(+), 39 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6da6a011e..910c70613 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -222,25 +222,6 @@ Layout/SpaceInsideBlockBraces: - 'lib/devise_token_auth/rails/routes.rb' - 'test/lib/generators/devise_token_auth/install_generator_test.rb' -# Offense count: 25 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Exclude: - - 'app/controllers/devise_token_auth/confirmations_controller.rb' - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/engine.rb' - - 'lib/devise_token_auth/rails/routes.rb' - - 'test/dummy/app/controllers/custom/passwords_controller.rb' - - 'test/dummy/app/controllers/custom/registrations_controller.rb' - - 'test/dummy/app/controllers/custom/sessions_controller.rb' - - 'test/dummy/app/controllers/custom/token_validations_controller.rb' - - 'test/lib/devise_token_auth/url_test.rb' # Offense count: 5 # Cop supports --auto-correct. diff --git a/app/controllers/devise_token_auth/confirmations_controller.rb b/app/controllers/devise_token_auth/confirmations_controller.rb index 441cc3448..762801a5f 100644 --- a/app/controllers/devise_token_auth/confirmations_controller.rb +++ b/app/controllers/devise_token_auth/confirmations_controller.rb @@ -16,7 +16,7 @@ def show yield @resource if block_given? - redirect_header_options = {account_confirmation_success: true} + redirect_header_options = { account_confirmation_success: true } redirect_headers = build_redirect_headers(token, client_id, redirect_header_options) diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 0403c42d1..95f3ef2e5 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -46,7 +46,7 @@ def omniauth_success def omniauth_failure @error = params[:message] - render_data_or_redirect('authFailure', {error: @error}) + render_data_or_redirect('authFailure', { error: @error }) end protected diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index 18128a972..1f258b558 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -67,7 +67,7 @@ def edit yield @resource if block_given? - redirect_header_options = {reset_password: true} + redirect_header_options = { reset_password: true } redirect_headers = build_redirect_headers(token, client_id, redirect_header_options) diff --git a/app/controllers/devise_token_auth/unlocks_controller.rb b/app/controllers/devise_token_auth/unlocks_controller.rb index 9b85981c1..1ce0d6c66 100644 --- a/app/controllers/devise_token_auth/unlocks_controller.rb +++ b/app/controllers/devise_token_auth/unlocks_controller.rb @@ -39,7 +39,7 @@ def show @resource.save! yield @resource if block_given? - redirect_header_options = {unlock: true} + redirect_header_options = { unlock: true } redirect_headers = build_redirect_headers(token, client_id, redirect_header_options) diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 8b28e9ad8..b0b949ddf 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -253,7 +253,7 @@ def remove_tokens_after_password_reset if tokens.present? && tokens.many? client_id, token_data = tokens.max_by { |cid, v| v[:expiry] || v['expiry'] } - self.tokens = {client_id => token_data} + self.tokens = { client_id => token_data } end end diff --git a/lib/devise_token_auth/engine.rb b/lib/devise_token_auth/engine.rb index 3302bed0b..89b581fce 100644 --- a/lib/devise_token_auth/engine.rb +++ b/lib/devise_token_auth/engine.rb @@ -36,11 +36,11 @@ class Engine < ::Rails::Engine self.enable_standard_devise_support = false self.remove_tokens_after_password_reset = false self.default_callbacks = true - self.headers_names = {'access-token': 'access-token', - 'client': 'client', - 'expiry': 'expiry', - 'uid': 'uid', - 'token-type': 'token-type' } + self.headers_names = { 'access-token': 'access-token', + 'client': 'client', + 'expiry': 'expiry', + 'uid': 'uid', + 'token-type': 'token-type' } self.bypass_sign_in = true def self.setup(&block) diff --git a/lib/devise_token_auth/rails/routes.rb b/lib/devise_token_auth/rails/routes.rb index b77e7e226..5481288b2 100644 --- a/lib/devise_token_auth/rails/routes.rb +++ b/lib/devise_token_auth/rails/routes.rb @@ -15,10 +15,10 @@ def mount_devise_token_auth_for(resource, opts) unlocks_ctrl = opts[:controllers][:unlocks] || 'devise_token_auth/unlocks' # define devise controller mappings - controllers = {sessions: sessions_ctrl, - registrations: registrations_ctrl, - passwords: passwords_ctrl, - confirmations: confirmations_ctrl} + controllers = { sessions: sessions_ctrl, + registrations: registrations_ctrl, + passwords: passwords_ctrl, + confirmations: confirmations_ctrl } controllers[:unlocks] = unlocks_ctrl if unlocks_ctrl diff --git a/test/dummy/app/controllers/custom/passwords_controller.rb b/test/dummy/app/controllers/custom/passwords_controller.rb index b59190a48..7ac364c03 100644 --- a/test/dummy/app/controllers/custom/passwords_controller.rb +++ b/test/dummy/app/controllers/custom/passwords_controller.rb @@ -33,7 +33,7 @@ def update_block_called? protected def render_update_success - render json: {custom: 'foo'} + render json: { custom: 'foo' } end end diff --git a/test/dummy/app/controllers/custom/registrations_controller.rb b/test/dummy/app/controllers/custom/registrations_controller.rb index 84a24d57e..760c33e90 100644 --- a/test/dummy/app/controllers/custom/registrations_controller.rb +++ b/test/dummy/app/controllers/custom/registrations_controller.rb @@ -33,7 +33,7 @@ def destroy_block_called? protected def render_create_success - render json: {custom: 'foo'} + render json: { custom: 'foo' } end end diff --git a/test/dummy/app/controllers/custom/sessions_controller.rb b/test/dummy/app/controllers/custom/sessions_controller.rb index bb644471c..d9bef07cb 100644 --- a/test/dummy/app/controllers/custom/sessions_controller.rb +++ b/test/dummy/app/controllers/custom/sessions_controller.rb @@ -23,7 +23,7 @@ def destroy_block_called? protected def render_create_success - render json: {custom: 'foo'} + render json: { custom: 'foo' } end end diff --git a/test/dummy/app/controllers/custom/token_validations_controller.rb b/test/dummy/app/controllers/custom/token_validations_controller.rb index 6261c0507..d395e0910 100644 --- a/test/dummy/app/controllers/custom/token_validations_controller.rb +++ b/test/dummy/app/controllers/custom/token_validations_controller.rb @@ -13,7 +13,7 @@ def validate_token_block_called? protected def render_validate_token_success - render json: {custom: 'foo'} + render json: { custom: 'foo' } end end diff --git a/test/lib/devise_token_auth/url_test.rb b/test/lib/devise_token_auth/url_test.rb index df7830d82..d383bc21e 100644 --- a/test/lib/devise_token_auth/url_test.rb +++ b/test/lib/devise_token_auth/url_test.rb @@ -3,7 +3,7 @@ class DeviseTokenAuth::UrlTest < ActiveSupport::TestCase describe 'DeviseTokenAuth::Url#generate' do test 'URI fragment should appear at the end of URL' do - params = {client_id: 123} + params = { client_id: 123 } url = 'http://example.com#fragment' assert_equal DeviseTokenAuth::Url.send(:generate, url, params), 'http://example.com?client_id=123#fragment' end @@ -15,7 +15,7 @@ class DeviseTokenAuth::UrlTest < ActiveSupport::TestCase end test 'should marge existing query params with new ones' do - params = {client_id: 123} + params = { client_id: 123 } url = 'http://example.com?a=1' assert_equal DeviseTokenAuth::Url.send(:generate, url, params), 'http://example.com?a=1&client_id=123' end From 7c0bd98f980a04ad60266982d7d7ba4373233b37 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 25 Mar 2018 21:07:00 +0300 Subject: [PATCH 17/54] Fix Layout/SpaceInsideStringInterpolation --- .rubocop_todo.yml | 9 --------- lib/devise_token_auth/controllers/helpers.rb | 2 +- lib/generators/devise_token_auth/install_generator.rb | 8 ++++---- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 910c70613..ba2e44d10 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -223,15 +223,6 @@ Layout/SpaceInsideBlockBraces: - 'test/lib/generators/devise_token_auth/install_generator_test.rb' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideStringInterpolation: - Exclude: - - 'lib/devise_token_auth/controllers/helpers.rb' - - 'lib/generators/devise_token_auth/install_generator.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/lib/devise_token_auth/controllers/helpers.rb b/lib/devise_token_auth/controllers/helpers.rb index 3f96880e1..3cc61801b 100644 --- a/lib/devise_token_auth/controllers/helpers.rb +++ b/lib/devise_token_auth/controllers/helpers.rb @@ -27,7 +27,7 @@ module ClassMethods # current_blogger :user # Preferably returns a User if one is signed in # def devise_token_auth_group(group_name, opts={}) - mappings = "[#{ opts[:contains].map { |m| ":#{m}" }.join(',') }]" + mappings = "[#{opts[:contains].map { |m| ":#{m}" }.join(',')}]" class_eval <<-METHODS, __FILE__, __LINE__ + 1 def authenticate_#{group_name}!(favourite=nil, opts={}) diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index 326c5ad58..c67a0fef5 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -12,18 +12,18 @@ def create_initializer_file end def copy_migrations - if self.class.migration_exists?('db/migrate', "devise_token_auth_create_#{ user_class.pluralize.gsub('::','').underscore }") - say_status('skipped', "Migration 'devise_token_auth_create_#{ user_class.pluralize.gsub('::','').underscore }' already exists") + if self.class.migration_exists?('db/migrate', "devise_token_auth_create_#{user_class.pluralize.gsub('::','').underscore}") + say_status('skipped', "Migration 'devise_token_auth_create_#{user_class.pluralize.gsub('::','').underscore}' already exists") else migration_template( 'devise_token_auth_create_users.rb.erb', - "db/migrate/devise_token_auth_create_#{ user_class.pluralize.gsub('::','').underscore }.rb" + "db/migrate/devise_token_auth_create_#{user_class.pluralize.gsub('::','').underscore}.rb" ) end end def create_user_model - fname = "app/models/#{ user_class.underscore }.rb" + fname = "app/models/#{user_class.underscore}.rb" unless File.exist?(File.join(destination_root, fname)) template('user.rb.erb', fname) else From e055c89d24bc319425c4547919af3a050def9b88 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sun, 25 Mar 2018 21:10:46 +0300 Subject: [PATCH 18/54] Fix Layout/CommentIndentation --- .rubocop_todo.yml | 5 ----- .../devise_token_auth/omniauth_callbacks_controller.rb | 8 ++++---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ba2e44d10..e1c9126f0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -29,11 +29,6 @@ Layout/AlignParameters: - 'test/dummy/config/initializers/omniauth.rb' - 'test/dummy/config/routes.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/CommentIndentation: - Exclude: - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' # Offense count: 2 # Cop supports --auto-correct. diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 95f3ef2e5..30b2233e8 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -149,10 +149,10 @@ def devise_mapping def set_random_password # set crazy password for new oauth users. this is only used to prevent - # access via email sign-in. - p = SecureRandom.urlsafe_base64(nil, false) - @resource.password = p - @resource.password_confirmation = p + # access via email sign-in. + p = SecureRandom.urlsafe_base64(nil, false) + @resource.password = p + @resource.password_confirmation = p end def create_auth_params From 2c4cd084f78295508bcbf439c760c54b202c869f Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Tue, 27 Mar 2018 16:18:03 -0700 Subject: [PATCH 19/54] Update rubocop todo list and exclusions. --- .rubocop.yml | 2 + .rubocop_todo.yml | 112 ++++++++++++++++++++++------------------------ 2 files changed, 55 insertions(+), 59 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 97d71acd0..6264ff45d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,6 +3,8 @@ inherit_from: .rubocop_todo.yml AllCops: Exclude: - 'coverage/**/*' + - 'test/dummy/tmp/**/*' + - 'test/dummy/log/**/*' # Offense count: 130 # Cop supports --auto-correct. diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e1c9126f0..10ad5147b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --exclude-limit 30` -# on 2018-03-23 19:22:33 -0700 using RuboCop version 0.54.0. +# `rubocop --auto-gen-config --exclude-limit 100` +# on 2018-03-27 14:56:41 -0700 using RuboCop version 0.54.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 @@ -29,6 +29,13 @@ Layout/AlignParameters: - 'test/dummy/config/initializers/omniauth.rb' - 'test/dummy/config/routes.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'test/controllers/demo_user_controller_test.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -43,13 +50,14 @@ Layout/EmptyLinesAroundAccessModifier: Exclude: - 'app/controllers/devise_token_auth/unlocks_controller.rb' -# Offense count: 4 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines Layout/EmptyLinesAroundBlockBody: Exclude: - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'test/controllers/demo_user_controller_test.rb' - 'test/controllers/devise_token_auth/passwords_controller_test.rb' - 'test/dummy/db/schema.rb' @@ -102,30 +110,15 @@ Layout/ExtraSpacing: Layout/IndentHash: EnforcedStyle: consistent -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: normal, rails -Layout/IndentationConsistency: - Exclude: - - 'test/dummy/tmp/generators/config/routes.rb' - -# Offense count: 4 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'app/controllers/devise_token_auth/sessions_controller.rb' - - 'test/dummy/tmp/generators/config/routes.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/InitialIndentation: - Exclude: - - 'test/dummy/tmp/generators/config/routes.rb' -# Offense count: 20 +# Offense count: 19 # Cop supports --auto-correct. Layout/LeadingCommentSpace: Exclude: @@ -133,7 +126,6 @@ Layout/LeadingCommentSpace: - 'test/dummy/config/initializers/devise_token_auth.rb' - 'test/dummy/config/initializers/figaro.rb' - 'test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb' - - 'test/dummy/tmp/history.rb' # Offense count: 3 # Cop supports --auto-correct. @@ -141,13 +133,22 @@ Layout/MultilineBlockLayout: Exclude: - 'lib/generators/devise_token_auth/install_generator.rb' -# Offense count: 6 +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'test/controllers/devise_token_auth/sessions_controller_test.rb' + +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: Exclude: - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/models/devise_token_auth/concerns/user.rb' - 'lib/generators/devise_token_auth/install_generator.rb' # Offense count: 1 @@ -156,12 +157,14 @@ Layout/SpaceAfterColon: Exclude: - 'app/controllers/devise_token_auth/sessions_controller.rb' -# Offense count: 2 +# Offense count: 6 # Cop supports --auto-correct. Layout/SpaceAfterComma: Exclude: - 'app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb' - 'lib/devise_token_auth/url.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' # Offense count: 12 # Cop supports --auto-correct. @@ -206,7 +209,7 @@ Layout/SpaceInsideArrayLiteralBrackets: Exclude: - 'config/initializers/devise.rb' -# Offense count: 11 +# Offense count: 14 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -216,7 +219,7 @@ Layout/SpaceInsideBlockBraces: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'lib/devise_token_auth/rails/routes.rb' - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - + - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' # Offense count: 4 # Cop supports --auto-correct. @@ -229,12 +232,6 @@ Layout/TrailingBlankLines: - 'test/dummy/lib/migration_database_helper.rb' - 'test/integration/navigation_test.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/TrailingWhitespace: - Exclude: - - 'lib/generators/devise_token_auth/install_generator.rb' - # Offense count: 1 Lint/AmbiguousBlockAssociation: Exclude: @@ -268,12 +265,13 @@ Lint/StringConversionInInterpolation: Exclude: - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' -# Offense count: 5 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' + - 'test/controllers/demo_user_controller_test.rb' - 'test/controllers/devise_token_auth/sessions_controller_test.rb' - 'test/dummy/app/controllers/custom/registrations_controller.rb' - 'test/dummy/config/initializers/omniauth.rb' @@ -295,22 +293,16 @@ Lint/UriEscapeUnescape: - 'test/controllers/devise_token_auth/registrations_controller_test.rb' - 'test/controllers/overrides/confirmations_controller_test.rb' -# Offense count: 3 -# Configuration parameters: CheckForMethodsWithNoSideEffects. -Lint/Void: - Exclude: - - 'test/dummy/tmp/history.rb' - -# Offense count: 36 +# Offense count: 35 Metrics/AbcSize: Max: 74 -# Offense count: 94 +# Offense count: 98 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: Max: 696 -# Offense count: 14 +# Offense count: 15 # Configuration parameters: CountComments. Metrics/ClassLength: Max: 698 @@ -319,7 +311,7 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 17 -# Offense count: 37 +# Offense count: 35 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 63 @@ -376,12 +368,13 @@ Performance/RegexpMatch: - 'app/validators/email_validator.rb' - 'lib/generators/devise_token_auth/install_generator.rb' -# Offense count: 3 +# Offense count: 4 # Cop supports --auto-correct. Performance/StringReplacement: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'lib/devise_token_auth/rails/routes.rb' + - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' # Offense count: 7 # Cop supports --auto-correct. @@ -402,7 +395,7 @@ Style/BarePercentLiterals: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' -# Offense count: 7 +# Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining @@ -414,6 +407,7 @@ Style/BlockDelimiters: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'test/controllers/devise_token_auth/passwords_controller_test.rb' - 'test/lib/generators/devise_token_auth/install_generator_test.rb' + - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' # Offense count: 11 # Cop supports --auto-correct. @@ -435,10 +429,11 @@ Style/ColonMethodCall: - 'lib/devise_token_auth/engine.rb' - 'lib/devise_token_auth/rails/routes.rb' -# Offense count: 2 +# Offense count: 3 Style/CommentedKeyword: Exclude: - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'test/controllers/demo_user_controller_test.rb' # Offense count: 3 # Cop supports --auto-correct. @@ -519,7 +514,7 @@ Style/ExpandPathArguments: - 'test/dummy/config/environment.rb' - 'test/test_helper.rb' -# Offense count: 12 +# Offense count: 13 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: @@ -608,7 +603,6 @@ Style/MutableConstant: - 'test/dummy/app/controllers/overrides/token_validations_controller.rb' - 'test/dummy/app/helpers/application_helper.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinBodyLength. @@ -629,7 +623,7 @@ Style/Not: Style/NumericLiterals: MinDigits: 15 -# Offense count: 3 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: predicate, comparison @@ -637,7 +631,6 @@ Style/NumericPredicate: Exclude: - 'spec/**/*' - 'app/controllers/devise_token_auth/confirmations_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - 'test/dummy/app/models/user.rb' # Offense count: 3 @@ -648,14 +641,14 @@ Style/ParenthesesAroundCondition: - 'app/models/devise_token_auth/concerns/user.rb' - 'lib/devise_token_auth/url.rb' -# Offense count: 2 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - + - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' # Offense count: 5 # Cop supports --auto-correct. @@ -736,7 +729,7 @@ Style/SymbolProc: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 2 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowSafeAssignment. # SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex @@ -744,7 +737,14 @@ Style/TernaryParentheses: Exclude: - 'lib/generators/devise_token_auth/install_generator.rb' - 'test/lib/generators/devise_token_auth/install_generator_test.rb' + - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowNamedUnderscoreVariables. +Style/TrailingUnderscoreVariable: + Exclude: + - 'test/controllers/devise_token_auth/sessions_controller_test.rb' # Offense count: 4 # Cop supports --auto-correct. @@ -777,13 +777,7 @@ Style/WordArray: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'test/dummy/db/schema.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/ZeroLengthPredicate: - Exclude: - - 'app/models/devise_token_auth/concerns/user.rb' - -# Offense count: 326 +# Offense count: 332 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: From bb57a6ac08c144eb14c2f4ee3aaf342773084125 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 2 Apr 2018 18:13:32 +0300 Subject: [PATCH 20/54] Fix Layout/BlockAlignment --- .rubocop_todo.yml | 62 ++++--------------- test/controllers/demo_user_controller_test.rb | 4 +- 2 files changed, 15 insertions(+), 51 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 10ad5147b..a52d524e8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --exclude-limit 100` -# on 2018-03-27 14:56:41 -0700 using RuboCop version 0.54.0. +# `rubocop --auto-gen-config --exclude-limit 30` +# on 2018-04-02 18:11:02 +0300 using RuboCop version 0.54.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 @@ -29,14 +29,6 @@ Layout/AlignParameters: - 'test/dummy/config/initializers/omniauth.rb' - 'test/dummy/config/routes.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyleAlignWith. -# SupportedStylesAlignWith: either, start_of_block, start_of_line -Layout/BlockAlignment: - Exclude: - - 'test/controllers/demo_user_controller_test.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. @@ -276,14 +268,13 @@ Lint/UnusedBlockArgument: - 'test/dummy/app/controllers/custom/registrations_controller.rb' - 'test/dummy/config/initializers/omniauth.rb' -# Offense count: 4 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. Lint/UnusedMethodArgument: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'lib/devise_token_auth/engine.rb' - 'lib/generators/devise_token_auth/install_generator.rb' # Offense count: 3 @@ -293,11 +284,11 @@ Lint/UriEscapeUnescape: - 'test/controllers/devise_token_auth/registrations_controller_test.rb' - 'test/controllers/overrides/confirmations_controller_test.rb' -# Offense count: 35 +# Offense count: 32 Metrics/AbcSize: Max: 74 -# Offense count: 98 +# Offense count: 97 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: Max: 696 @@ -307,11 +298,11 @@ Metrics/BlockLength: Metrics/ClassLength: Max: 698 -# Offense count: 14 +# Offense count: 13 Metrics/CyclomaticComplexity: Max: 17 -# Offense count: 35 +# Offense count: 33 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 63 @@ -321,7 +312,7 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 1037 -# Offense count: 13 +# Offense count: 12 Metrics/PerceivedComplexity: Max: 19 @@ -361,13 +352,6 @@ Performance/RedundantMerge: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Performance/RegexpMatch: - Exclude: - - 'app/validators/email_validator.rb' - - 'lib/generators/devise_token_auth/install_generator.rb' - # Offense count: 4 # Cop supports --auto-correct. Performance/StringReplacement: @@ -422,11 +406,10 @@ Style/BracesAroundHashParameters: - 'test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb' - 'test/dummy/app/controllers/overrides/passwords_controller.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. Style/ColonMethodCall: Exclude: - - 'lib/devise_token_auth/engine.rb' - 'lib/devise_token_auth/rails/routes.rb' # Offense count: 3 @@ -450,7 +433,7 @@ Style/DateTime: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 24 +# Offense count: 22 Style/Documentation: Exclude: - 'spec/**/*' @@ -471,7 +454,6 @@ Style/Documentation: - 'lib/devise_token_auth.rb' - 'lib/devise_token_auth/controllers/helpers.rb' - 'lib/devise_token_auth/controllers/url_helpers.rb' - - 'lib/devise_token_auth/engine.rb' - 'lib/devise_token_auth/rails/routes.rb' - 'lib/devise_token_auth/url.rb' - 'lib/generators/devise_token_auth/install_generator.rb' @@ -623,14 +605,13 @@ Style/Not: Style/NumericLiterals: MinDigits: 15 -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'spec/**/*' - - 'app/controllers/devise_token_auth/confirmations_controller.rb' - 'test/dummy/app/models/user.rb' # Offense count: 3 @@ -668,13 +649,12 @@ Style/RedundantReturn: - 'app/models/devise_token_auth/concerns/user.rb' - 'lib/devise_token_auth/url.rb' -# Offense count: 8 +# Offense count: 7 # Cop supports --auto-correct. Style/RedundantSelf: Exclude: - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/engine.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -682,22 +662,6 @@ Style/RescueModifier: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. -# Whitelist: present?, blank?, presence, try -Style/SafeNavigation: - Exclude: - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/controllers/devise_token_auth/confirmations_controller.rb' - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/engine.rb' - - 'test/dummy/app/controllers/overrides/confirmations_controller.rb' - - 'test/dummy/app/controllers/overrides/passwords_controller.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowIfMethodIsEmpty. @@ -777,7 +741,7 @@ Style/WordArray: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'test/dummy/db/schema.rb' -# Offense count: 332 +# Offense count: 324 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: diff --git a/test/controllers/demo_user_controller_test.rb b/test/controllers/demo_user_controller_test.rb index 547ab262a..3a05a2073 100644 --- a/test/controllers/demo_user_controller_test.rb +++ b/test/controllers/demo_user_controller_test.rb @@ -438,8 +438,8 @@ class DemoUserControllerTest < ActionDispatch::IntegrationTest # get the oldest token client_id oldest_client_id, = @resource.reload.tokens.min_by do |cid, v| - v[:expiry] || v['expiry'] - end # => [ 'CLIENT_ID', {token: ...} ] + v[:expiry] || v['expiry'] + end # => [ 'CLIENT_ID', {token: ...} ] # create another token, thereby dropping the oldest token @resource.create_new_auth_token From ede2ff97caa808f99bf46995fb4aaa6772063368 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 2 Apr 2018 18:18:38 +0300 Subject: [PATCH 21/54] Fix Style/UnneededInterpolation --- .rubocop_todo.yml | 11 ++--------- lib/devise_token_auth/rails/routes.rb | 4 ++-- lib/devise_token_auth/url.rb | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a52d524e8..745a004f5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 30` -# on 2018-04-02 18:11:02 +0300 using RuboCop version 0.54.0. +# on 2018-04-02 18:18:11 +0300 using RuboCop version 0.54.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 @@ -286,7 +286,7 @@ Lint/UriEscapeUnescape: # Offense count: 32 Metrics/AbcSize: - Max: 74 + Max: 76 # Offense count: 97 # Configuration parameters: CountComments, ExcludedMethods. @@ -718,13 +718,6 @@ Style/UnlessElse: - 'app/models/devise_token_auth/concerns/user.rb' - 'lib/generators/devise_token_auth/install_generator.rb' -# Offense count: 3 -# Cop supports --auto-correct. -Style/UnneededInterpolation: - Exclude: - - 'lib/devise_token_auth/rails/routes.rb' - - 'lib/devise_token_auth/url.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/UnneededPercentQ: diff --git a/lib/devise_token_auth/rails/routes.rb b/lib/devise_token_auth/rails/routes.rb index 5481288b2..19b62d2ed 100644 --- a/lib/devise_token_auth/rails/routes.rb +++ b/lib/devise_token_auth/rails/routes.rb @@ -28,7 +28,7 @@ def mount_devise_token_auth_for(resource, opts) devise_for resource.pluralize.underscore.gsub('/', '_').to_sym, class_name: resource, module: :devise, - path: "#{opts[:at]}", + path: opts[:at].to_s, controllers: controllers, skip: opts[:skip] + [:omniauth_callbacks] @@ -54,7 +54,7 @@ def mount_devise_token_auth_for(resource, opts) devise_scope mapping_name.to_sym do # path to verify token validity - get "#{full_path}/validate_token", controller: "#{token_validations_ctrl}", action: 'validate_token' + get "#{full_path}/validate_token", controller: token_validations_ctrl.to_s, action: 'validate_token' # omniauth routes. only define if omniauth is installed and not skipped. if defined?(::OmniAuth) && !opts[:skip].include?(:omniauth_callbacks) diff --git a/lib/devise_token_auth/url.rb b/lib/devise_token_auth/url.rb index e77c31281..76eae11f2 100644 --- a/lib/devise_token_auth/url.rb +++ b/lib/devise_token_auth/url.rb @@ -5,7 +5,7 @@ def self.generate(url, params = {}) res = "#{uri.scheme}://#{uri.host}" res += ":#{uri.port}" if (uri.port && uri.port != 80 && uri.port != 443) - res += "#{uri.path}" if uri.path + res += uri.path.to_s if uri.path query = [uri.query, params.to_query].reject(&:blank?).join('&') res += "?#{query}" res += "##{uri.fragment}" if uri.fragment From 5aaccab1aee4526cc0b4494e878a4ef1d7160690 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 2 Apr 2018 18:34:03 +0300 Subject: [PATCH 22/54] Fix Style/UnlessElse --- .rubocop_todo.yml | 10 +------- .../registrations_controller.rb | 15 ++++++------ app/models/devise_token_auth/concerns/user.rb | 6 ++--- .../devise_token_auth/install_generator.rb | 24 +++++++++---------- 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 745a004f5..0d9afac35 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 30` -# on 2018-04-02 18:18:11 +0300 using RuboCop version 0.54.0. +# on 2018-04-02 18:32:20 +0300 using RuboCop version 0.54.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 @@ -710,14 +710,6 @@ Style/TrailingUnderscoreVariable: Exclude: - 'test/controllers/devise_token_auth/sessions_controller_test.rb' -# Offense count: 4 -# Cop supports --auto-correct. -Style/UnlessElse: - Exclude: - - 'app/controllers/devise_token_auth/registrations_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/generators/devise_token_auth/install_generator.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/UnneededPercentQ: diff --git a/app/controllers/devise_token_auth/registrations_controller.rb b/app/controllers/devise_token_auth/registrations_controller.rb index da6f6a211..19b064d07 100644 --- a/app/controllers/devise_token_auth/registrations_controller.rb +++ b/app/controllers/devise_token_auth/registrations_controller.rb @@ -45,20 +45,19 @@ def create if @resource.save yield @resource if block_given? - unless @resource.confirmed? - # user will require email authentication - @resource.send_confirmation_instructions({ - client_config: params[:config_name], - redirect_url: @redirect_url - }) - - else + if @resource.confirmed? # email auth has been bypassed, authenticate user @client_id, @token = @resource.create_token @resource.save! update_auth_header + else + # user will require email authentication + @resource.send_confirmation_instructions({ + client_config: params[:config_name], + redirect_url: @redirect_url + }) end render_create_success else diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index b0b949ddf..68d1cdf87 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -16,11 +16,11 @@ def self.tokens_match?(token_hash, token) included do # Hack to check if devise is already enabled - unless self.method_defined?(:devise_modules) + if self.method_defined?(:devise_modules) + self.devise_modules.delete(:omniauthable) + else devise :database_authenticatable, :registerable, :recoverable, :trackable, :validatable, :confirmable - else - self.devise_modules.delete(:omniauthable) end unless tokens_has_json_column_type? diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index c67a0fef5..3a1c9b837 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -24,22 +24,22 @@ def copy_migrations def create_user_model fname = "app/models/#{user_class.underscore}.rb" - unless File.exist?(File.join(destination_root, fname)) - template('user.rb.erb', fname) - else + if File.exist?(File.join(destination_root, fname)) inclusion = 'include DeviseTokenAuth::Concerns::User' unless parse_file_for_line(fname, inclusion) active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base' inject_into_file fname, after: "class #{user_class} < #{active_record_needle}\n" do <<-'RUBY' - # Include default devise modules. - devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable, - :confirmable, :omniauthable - include DeviseTokenAuth::Concerns::User - RUBY + # Include default devise modules. + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable, + :confirmable, :omniauthable + include DeviseTokenAuth::Concerns::User + RUBY end end + else + template('user.rb.erb', fname) end end @@ -73,11 +73,11 @@ def add_route_mount if File.exist?(File.join(destination_root, f)) line = parse_file_for_line(f, 'mount_devise_token_auth_for') - unless line + if line + existing_user_class = true + else line = 'Rails.application.routes.draw do' existing_user_class = false - else - existing_user_class = true end if parse_file_for_line(f, str) From 7f77c342e48febe2a2f3b96c500d6e03684ae2dc Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 2 Apr 2018 18:55:25 +0300 Subject: [PATCH 23/54] Fix Style/RedundantReturn --- .rubocop_todo.yml | 13 +------------ .../devise_token_auth/application_controller.rb | 4 ++-- .../devise_token_auth/passwords_controller.rb | 2 +- .../devise_token_auth/sessions_controller.rb | 5 +---- app/models/devise_token_auth/concerns/user.rb | 2 +- lib/devise_token_auth/url.rb | 2 +- 6 files changed, 7 insertions(+), 21 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0d9afac35..bd7e30804 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 30` -# on 2018-04-02 18:32:20 +0300 using RuboCop version 0.54.0. +# on 2018-04-02 18:53:29 +0300 using RuboCop version 0.54.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 @@ -638,17 +638,6 @@ Style/PercentLiteralDelimiters: Style/RaiseArgs: EnforcedStyle: compact -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: AllowMultipleReturnValues. -Style/RedundantReturn: - Exclude: - - 'app/controllers/devise_token_auth/application_controller.rb' - - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/sessions_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/url.rb' - # Offense count: 7 # Cop supports --auto-correct. Style/RedundantSelf: diff --git a/app/controllers/devise_token_auth/application_controller.rb b/app/controllers/devise_token_auth/application_controller.rb index 8d79e033e..558bb8feb 100644 --- a/app/controllers/devise_token_auth/application_controller.rb +++ b/app/controllers/devise_token_auth/application_controller.rb @@ -12,7 +12,7 @@ def resource_data(opts={}) end def resource_errors - return @resource.errors.to_hash.merge(full_messages: @resource.errors.full_messages) + @resource.errors.to_hash.merge(full_messages: @resource.errors.full_messages) end protected @@ -53,7 +53,7 @@ def json_api? return ActiveModel::Serializer.setup do |config| config.adapter == :json_api end if ActiveModel::Serializer.respond_to?(:setup) - return ActiveModelSerializers.config.adapter == :json_api + ActiveModelSerializers.config.adapter == :json_api end def recoverable_enabled? diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index 1f258b558..5314afc7c 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -172,7 +172,7 @@ def render_update_success end def render_update_error - return render json: { + render json: { success: false, errors: resource_errors }, status: 422 diff --git a/app/controllers/devise_token_auth/sessions_controller.rb b/app/controllers/devise_token_auth/sessions_controller.rb index a89d8f40e..613134347 100644 --- a/app/controllers/devise_token_auth/sessions_controller.rb +++ b/app/controllers/devise_token_auth/sessions_controller.rb @@ -85,10 +85,7 @@ def get_auth_params auth_val.downcase! end - return { - key: auth_key, - val: auth_val - } + { key: auth_key, val: auth_val } end def render_new_error diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 68d1cdf87..0831918b0 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -121,7 +121,7 @@ def valid_token?(token, client_id='default') return true if token_can_be_reused?(token, client_id) # return false if none of the above conditions are met - return false + false end # this must be done from the controller so that additional params diff --git a/lib/devise_token_auth/url.rb b/lib/devise_token_auth/url.rb index 76eae11f2..920ebb67f 100644 --- a/lib/devise_token_auth/url.rb +++ b/lib/devise_token_auth/url.rb @@ -10,7 +10,7 @@ def self.generate(url, params = {}) res += "?#{query}" res += "##{uri.fragment}" if uri.fragment - return res + res end def self.whitelisted?(url) From c470e2b1fe6fb387fc115232474933680faa0da3 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Wed, 28 Mar 2018 16:56:11 -0700 Subject: [PATCH 24/54] Partially fix Metrics/LineLength. - Custom configuration for cop: * Set max to 80 columns * Exclude all test files * Exclude `Guardfile` & `gemspec` * Ignore comments - Exclude remaining files with violations via `.rubocop_todo.yml`. NOTE: Some files need refactoring, others can be resolved by extending max LineLength from 80 to 100 columns. - Resolve some violations where obvious. --- .rubocop.yml | 14 ++++++++++ .rubocop_todo.yml | 27 ++++++++++++++----- config/initializers/devise.rb | 2 +- lib/devise_token_auth/controllers/helpers.rb | 14 ++++++++-- lib/devise_token_auth/url.rb | 5 +++- .../passwords_controller_test.rb | 10 ++++--- 6 files changed, 58 insertions(+), 14 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6264ff45d..a7aaa5f43 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -58,3 +58,17 @@ Style/SymbolArray: Enabled: true EnforcedStyle: percent MinSize: 3 + +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + inherit_mode: + merge: + - Exclude + Exclude: + - 'test/**/*' + - 'Guardfile' + - 'devise_token_auth.gemspec' + IgnoredPatterns: + - '(\A|\s)#' + Max: 80 \ No newline at end of file diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bd7e30804..78dc2eb69 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -302,7 +302,26 @@ Metrics/ClassLength: Metrics/CyclomaticComplexity: Max: 17 -# Offense count: 33 +# Offense count: 92 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Exclude: + - 'app/controllers/devise_token_auth/application_controller.rb' + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/registrations_controller.rb' + - 'app/controllers/devise_token_auth/sessions_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb' + - 'app/validators/email_validator.rb' + - 'lib/devise_token_auth/engine.rb' + - 'lib/devise_token_auth/rails/routes.rb' + - 'lib/generators/devise_token_auth/install_generator.rb' + +# Offense count: 35 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 63 @@ -714,9 +733,3 @@ Style/WordArray: - 'Rakefile' - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'test/dummy/db/schema.rb' - -# Offense count: 324 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 189 diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index e2c9d047b..d28126ebc 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -10,7 +10,7 @@ # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' + config.mailer_sender = 'no-reply@example.com' # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' diff --git a/lib/devise_token_auth/controllers/helpers.rb b/lib/devise_token_auth/controllers/helpers.rb index 3cc61801b..e2e646199 100644 --- a/lib/devise_token_auth/controllers/helpers.rb +++ b/lib/devise_token_auth/controllers/helpers.rb @@ -73,7 +73,12 @@ def render_authenticate_error end if respond_to?(:helper_method) - helper_method "current_#{group_name}", "current_#{group_name.to_s.pluralize}", "#{group_name}_signed_in?", "render_authenticate_error" + helper_method( + "current_#{group_name}", + "current_#{group_name.to_s.pluralize}", + "#{group_name}_signed_in?", + "render_authenticate_error" + ) end METHODS end @@ -140,7 +145,12 @@ def render_authenticate_error ActiveSupport.on_load(:action_controller) do if respond_to?(:helper_method) - helper_method "current_#{mapping}", "#{mapping}_signed_in?", "#{mapping}_session", 'render_authenticate_error' + helper_method( + "current_#{mapping}", + "#{mapping}_signed_in?", + "#{mapping}_session", + 'render_authenticate_error' + ) end end end diff --git a/lib/devise_token_auth/url.rb b/lib/devise_token_auth/url.rb index 920ebb67f..d7053afb2 100644 --- a/lib/devise_token_auth/url.rb +++ b/lib/devise_token_auth/url.rb @@ -14,7 +14,10 @@ def self.generate(url, params = {}) end def self.whitelisted?(url) - url.nil? || !!DeviseTokenAuth.redirect_whitelist.find { |pattern| !!Wildcat.new(pattern).match(url) } + url.nil? || \ + !!DeviseTokenAuth.redirect_whitelist.find do |pattern| + !!Wildcat.new(pattern).match(url) + end end # wildcard convenience class diff --git a/test/controllers/devise_token_auth/passwords_controller_test.rb b/test/controllers/devise_token_auth/passwords_controller_test.rb index 490be7da7..fb166266e 100644 --- a/test/controllers/devise_token_auth/passwords_controller_test.rb +++ b/test/controllers/devise_token_auth/passwords_controller_test.rb @@ -51,8 +51,10 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase test 'error message should be returned' do assert @data['errors'] - assert_equal @data['errors'], - [I18n.t('devise_token_auth.passwords.missing_redirect_url')] + assert_equal( + @data['errors'], + [I18n.t('devise_token_auth.passwords.missing_redirect_url')] + ) end end @@ -111,7 +113,9 @@ class DeviseTokenAuth::PasswordsControllerTest < ActionController::TestCase end test 'response should contains message' do - assert_equal @data['message'], I18n.t('devise_token_auth.passwords.sended', email: @resource.email) + assert_equal \ + @data['message'], + I18n.t('devise_token_auth.passwords.sended', email: @resource.email) end test 'action should send an email' do From 1afb2b2a30629bfd33d10534526d16bcef2a285a Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Wed, 28 Mar 2018 18:34:44 -0700 Subject: [PATCH 25/54] Partially (mostly) fix Metrics/BlockLength. - Custom configuration for cop: * Set max to 25 lines (default) * Exclude Rails Engine file * Exclude custom DSL files from test-dummy Rails app * Exclude `describe` blocks in tests * Exclude routing blocks - Exclude `app/models/devise_token_auth/concerns/user.rb` in `.rubocop_todo.yml`. NOTE: This file could use a bunch of refactoring. - Resolve violation in `test/controllers/overrides/passwords_controller_test.rb` by removing unused or single-use instance variables --- .rubocop.yml | 18 +++++++ .rubocop_todo.yml | 5 +- .../overrides/passwords_controller_test.rb | 50 ++++++++----------- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a7aaa5f43..ddddc1599 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -59,6 +59,24 @@ Style/SymbolArray: EnforcedStyle: percent MinSize: 3 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + inherit_mode: + merge: + - Exclude + - ExcludedMethod + Exclude: + - 'lib/devise_token_auth/engine.rb' + - 'test/dummy/config/**/*' + - 'test/dummy/db/**/*' + ExcludedMethods: + - describe + - draw + - namespace + - devise_scope + - unnest_namespace + Max: 25 + # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 78dc2eb69..488a52e28 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -288,10 +288,11 @@ Lint/UriEscapeUnescape: Metrics/AbcSize: Max: 76 -# Offense count: 97 +# Offense count: 1 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: - Max: 696 + Exclude: + - 'app/models/devise_token_auth/concerns/user.rb' # Offense count: 15 # Configuration parameters: CountComments. diff --git a/test/controllers/overrides/passwords_controller_test.rb b/test/controllers/overrides/passwords_controller_test.rb index b22def810..b08609174 100644 --- a/test/controllers/overrides/passwords_controller_test.rb +++ b/test/controllers/overrides/passwords_controller_test.rb @@ -10,38 +10,29 @@ class Overrides::PasswordsControllerTest < ActionDispatch::IntegrationTest describe Overrides::PasswordsController do before do @resource = evil_users(:confirmed_email_user) - @redirect_url = Faker::Internet.url post '/evil_user_auth/password', params: { email: @resource.email, - redirect_url: @redirect_url + redirect_url: Faker::Internet.url } - @mail = ActionMailer::Base.deliveries.last + mail = ActionMailer::Base.deliveries.last @resource.reload - @mail_config_name = CGI.unescape(@mail.body.match(/config=([^&]*)&/)[1]) - @mail_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)&/)[1]) - @mail_reset_token = @mail.body.match(/reset_password_token=(.*)\"/)[1] + mail_reset_token = mail.body.match(/reset_password_token=(.*)\"/)[1] + mail_redirect_url = CGI.unescape(mail.body.match(/redirect_url=([^&]*)&/)[1]) get '/evil_user_auth/password/edit', - params: { reset_password_token: @mail_reset_token, - redirect_url: @mail_redirect_url } + params: { + reset_password_token: mail_reset_token, + redirect_url: mail_redirect_url + } @resource.reload - raw_qs = response.location.split('?')[1] - @qs = Rack::Utils.parse_nested_query(raw_qs) - - @access_token = @qs['access-token'] - @client = @qs['client'] - @client_id = @qs['client_id'] - @expiry = @qs['expiry'] - @override_proof = @qs['override_proof'] - @reset_password = @qs['reset_password'] - @token = @qs['token'] - @uid = @qs['uid'] + _, raw_query_string = response.location.split('?') + @query_string = Rack::Utils.parse_nested_query(raw_query_string) end test 'response should have success redirect status' do @@ -49,18 +40,21 @@ class Overrides::PasswordsControllerTest < ActionDispatch::IntegrationTest end test 'response should contain auth params + override proof' do - assert @access_token - assert @client - assert @client_id - assert @expiry - assert @override_proof - assert @reset_password - assert @token - assert @uid + assert @query_string['access-token'] + assert @query_string['client'] + assert @query_string['client_id'] + assert @query_string['expiry'] + assert @query_string['override_proof'] + assert @query_string['reset_password'] + assert @query_string['token'] + assert @query_string['uid'] end test 'override proof is correct' do - assert_equal @override_proof, Overrides::PasswordsController::OVERRIDE_PROOF + assert_equal( + @query_string['override_proof'], + Overrides::PasswordsController::OVERRIDE_PROOF + ) end end end From e4a4c7b52c8118b868524b423bae98443453def0 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 02:51:54 -0700 Subject: [PATCH 26/54] Fix Style/ExpandPathArguments --- .rubocop_todo.yml | 18 ------------------ Rakefile | 2 +- bin/rails | 6 +++--- devise_token_auth.gemspec | 2 +- .../devise_token_auth/install_generator.rb | 2 +- .../install_views_generator.rb | 2 +- test/dummy/Rakefile | 2 +- test/dummy/bin/bundle | 2 +- test/dummy/bin/rails | 4 ++-- test/dummy/bin/rake | 2 +- test/dummy/config/application.rb | 2 +- test/dummy/config/boot.rb | 4 ++-- test/dummy/config/environment.rb | 2 +- test/test_helper.rb | 6 +++--- 14 files changed, 19 insertions(+), 37 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 488a52e28..803777302 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -498,24 +498,6 @@ Style/EmptyMethod: Exclude: - 'lib/devise_token_auth/controllers/url_helpers.rb' -# Offense count: 19 -# Cop supports --auto-correct. -Style/ExpandPathArguments: - Exclude: - - 'Rakefile' - - 'bin/rails' - - 'devise_token_auth.gemspec' - - 'lib/generators/devise_token_auth/install_generator.rb' - - 'lib/generators/devise_token_auth/install_views_generator.rb' - - 'test/dummy/Rakefile' - - 'test/dummy/bin/bundle' - - 'test/dummy/bin/rails' - - 'test/dummy/bin/rake' - - 'test/dummy/config/application.rb' - - 'test/dummy/config/boot.rb' - - 'test/dummy/config/environment.rb' - - 'test/test_helper.rb' - # Offense count: 13 # Configuration parameters: MinBodyLength. Style/GuardClause: diff --git a/Rakefile b/Rakefile index c9d09e87f..8b904d7e6 100644 --- a/Rakefile +++ b/Rakefile @@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_files.include('lib/**/*.rb') end -APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__) +APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__) load 'rails/tasks/engine.rake' Bundler::GemHelper.install_tasks diff --git a/bin/rails b/bin/rails index 39596cbd0..de0283e9a 100755 --- a/bin/rails +++ b/bin/rails @@ -1,11 +1,11 @@ #!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application. -ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/devise_token_auth/engine', __FILE__) +ENGINE_ROOT = File.expand_path('..', __dir__) +ENGINE_PATH = File.expand_path('../lib/devise_token_auth/engine', __dir__) # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) require 'rails/all' diff --git a/devise_token_auth.gemspec b/devise_token_auth.gemspec index 27e082fba..f81649951 100644 --- a/devise_token_auth.gemspec +++ b/devise_token_auth.gemspec @@ -1,4 +1,4 @@ -$:.push File.expand_path('../lib', __FILE__) +$:.push File.expand_path('lib', __dir__) # Maintain your gem's version: require 'devise_token_auth/version' diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index 3a1c9b837..07f27fad0 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -2,7 +2,7 @@ module DeviseTokenAuth class InstallGenerator < Rails::Generators::Base include Rails::Generators::Migration - source_root File.expand_path('../templates', __FILE__) + source_root File.expand_path('templates', __dir__) argument :user_class, type: :string, default: 'User' argument :mount_path, type: :string, default: 'auth' diff --git a/lib/generators/devise_token_auth/install_views_generator.rb b/lib/generators/devise_token_auth/install_views_generator.rb index 269369a03..10b38d959 100644 --- a/lib/generators/devise_token_auth/install_views_generator.rb +++ b/lib/generators/devise_token_auth/install_views_generator.rb @@ -1,6 +1,6 @@ module DeviseTokenAuth class InstallViewsGenerator < Rails::Generators::Base - source_root File.expand_path('../../../../app/views/devise/mailer', __FILE__) + source_root File.expand_path('../../../app/views/devise/mailer', __dir__) def copy_mailer_templates copy_file( diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile index ba6b733dd..f7a26ddaf 100644 --- a/test/dummy/Rakefile +++ b/test/dummy/Rakefile @@ -1,6 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require File.expand_path('config/application', __dir__) Rails.application.load_tasks diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle index 66e9889e8..f19acf5b5 100755 --- a/test/dummy/bin/bundle +++ b/test/dummy/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index b82341c98..1b99aac9c 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,8 +1,8 @@ #!/usr/bin/env ruby begin - load File.expand_path('../spring', __FILE__) + load File.expand_path('spring', __dir__) rescue LoadError end -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake index 2e9ece45c..5a81e454b 100755 --- a/test/dummy/bin/rake +++ b/test/dummy/bin/rake @@ -1,6 +1,6 @@ #!/usr/bin/env ruby begin - load File.expand_path('../spring', __FILE__) + load File.expand_path('spring', __dir__) rescue LoadError end require_relative '../config/boot' diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index e3eb919dd..1b6410f89 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -1,4 +1,4 @@ -require File.expand_path('../boot', __FILE__) +require File.expand_path('boot', __dir__) require 'rack/cors' require 'rails/all' diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index 6266cfc50..c9aef85d4 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,5 +1,5 @@ # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) -$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__) +$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__) diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb index ee8d90dc6..0b8bdd828 100644 --- a/test/dummy/config/environment.rb +++ b/test/dummy/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require File.expand_path('application', __dir__) # Initialize the Rails application. Rails.application.initialize! diff --git a/test/test_helper.rb b/test/test_helper.rb index 43b0f8017..d54e966d8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -9,7 +9,7 @@ ENV['RAILS_ENV'] = 'test' -require File.expand_path('../dummy/config/environment', __FILE__) +require File.expand_path('dummy/config/environment', __dir__) require 'rails/test_help' require 'minitest/rails' @@ -20,8 +20,8 @@ # Uncomment for awesome colorful output # require "minitest/pride" -ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__) -ActionDispatch::IntegrationTest.fixture_path = File.expand_path('../fixtures', __FILE__) +ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__) +ActionDispatch::IntegrationTest.fixture_path = File.expand_path('fixtures', __dir__) # I hate the default reporter. Use ProgressReporter instead. Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new From 67cff723aeb78f157e6d60cec47fdc192fa8364b Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 15:47:38 -0700 Subject: [PATCH 27/54] Fix Layout/IndentHash - Also partially fixes Style/BracesAroundHashParameters --- .rubocop_todo.yml | 13 +------------ .../omniauth_callbacks_controller.rb | 10 ++++------ .../devise_token_auth/passwords_controller.rb | 4 ++-- .../devise_token_auth/registrations_controller.rb | 4 ++-- .../devise_token_auth/unlocks_controller.rb | 4 ++-- .../overrides/omniauth_callbacks_controller.rb | 4 ++-- .../controllers/overrides/passwords_controller.rb | 4 ++-- 7 files changed, 15 insertions(+), 28 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 803777302..1af2267d5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -95,13 +95,6 @@ Layout/ExtraSpacing: - 'test/dummy/config/initializers/omniauth.rb' - 'test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb' -# Offense count: 14 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: - EnforcedStyle: consistent - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. @@ -413,18 +406,14 @@ Style/BlockDelimiters: - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' -# Offense count: 11 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: braces, no_braces, context_dependent Style/BracesAroundHashParameters: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/passwords_controller.rb' - 'app/controllers/devise_token_auth/registrations_controller.rb' - - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb' - - 'test/dummy/app/controllers/overrides/passwords_controller.rb' # Offense count: 1 # Cop supports --auto-correct. diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 30b2233e8..b3cd40b5d 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -173,9 +173,7 @@ def set_token_on_resource end def render_data(message, data) - @data = data.merge({ - message: message - }) + @data = data.merge(message: message) render layout: nil, template: 'devise_token_auth/omniauth_external_window' end @@ -219,10 +217,10 @@ def fallback_render(text) def get_resource_from_auth_hash # find or create user by provider and provider uid - @resource = resource_class.where({ - uid: auth_hash['uid'], + @resource = resource_class.where( + uid: auth_hash['uid'], provider: auth_hash['provider'] - }).first_or_initialize + ).first_or_initialize if @resource.new_record? @oauth_registration = true diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index 5314afc7c..d006c379b 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -32,12 +32,12 @@ def create if @resource yield @resource if block_given? - @resource.send_reset_password_instructions({ + @resource.send_reset_password_instructions( email: @email, provider: 'email', redirect_url: @redirect_url, client_config: params[:config_name] - }) + ) if @resource.errors.empty? return render_create_success diff --git a/app/controllers/devise_token_auth/registrations_controller.rb b/app/controllers/devise_token_auth/registrations_controller.rb index 19b064d07..e37f47f5d 100644 --- a/app/controllers/devise_token_auth/registrations_controller.rb +++ b/app/controllers/devise_token_auth/registrations_controller.rb @@ -54,10 +54,10 @@ def create update_auth_header else # user will require email authentication - @resource.send_confirmation_instructions({ + @resource.send_confirmation_instructions( client_config: params[:config_name], redirect_url: @redirect_url - }) + ) end render_create_success else diff --git a/app/controllers/devise_token_auth/unlocks_controller.rb b/app/controllers/devise_token_auth/unlocks_controller.rb index 1ce0d6c66..cfdb58664 100644 --- a/app/controllers/devise_token_auth/unlocks_controller.rb +++ b/app/controllers/devise_token_auth/unlocks_controller.rb @@ -15,11 +15,11 @@ def create if @resource yield @resource if block_given? - @resource.send_unlock_instructions({ + @resource.send_unlock_instructions( email: @email, provider: 'email', client_config: params[:config_name] - }) + ) if @resource.errors.empty? return render_create_success diff --git a/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb b/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb index 5ccc675e3..f59b89a5e 100644 --- a/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +++ b/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb @@ -3,12 +3,12 @@ class OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController DEFAULT_NICKNAME = 'stimpy' def assign_provider_attrs(user, auth_hash) - user.assign_attributes({ + user.assign_attributes( nickname: DEFAULT_NICKNAME, name: auth_hash['info']['name'], image: auth_hash['info']['image'], email: auth_hash['info']['email'] - }) + ) end end end diff --git a/test/dummy/app/controllers/overrides/passwords_controller.rb b/test/dummy/app/controllers/overrides/passwords_controller.rb index afbffdc98..f008d0733 100644 --- a/test/dummy/app/controllers/overrides/passwords_controller.rb +++ b/test/dummy/app/controllers/overrides/passwords_controller.rb @@ -4,9 +4,9 @@ class PasswordsController < DeviseTokenAuth::PasswordsController # this is where users arrive after visiting the email confirmation link def edit - @resource = resource_class.reset_password_by_token({ + @resource = resource_class.reset_password_by_token( reset_password_token: resource_params[:reset_password_token] - }) + ) if @resource and @resource.id client_id, token = @resource.create_token From be626444f89004caebeb6d547e3b4956f6e07bef Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 16:04:59 -0700 Subject: [PATCH 28/54] Fix Layout/SpaceInsideBlockBraces --- .rubocop_todo.yml | 12 ------------ .../omniauth_callbacks_controller.rb | 2 +- lib/devise_token_auth/rails/routes.rb | 6 +++--- .../devise_token_auth/install_generator_test.rb | 6 +++--- .../install_generator_with_namespace_test.rb | 6 +++--- 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1af2267d5..bf2d55889 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -194,18 +194,6 @@ Layout/SpaceInsideArrayLiteralBrackets: Exclude: - 'config/initializers/devise.rb' -# Offense count: 14 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Exclude: - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'lib/devise_token_auth/rails/routes.rb' - - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index b3cd40b5d..e8fdf91f6 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -86,7 +86,7 @@ def assign_provider_attrs(user, auth_hash) def whitelisted_params whitelist = params_for_resource(:sign_up) - whitelist.inject({}){|coll, key| + whitelist.inject({}){ |coll, key| param = omniauth_params[key.to_s] if param coll[key] = param diff --git a/lib/devise_token_auth/rails/routes.rb b/lib/devise_token_auth/rails/routes.rb index 19b62d2ed..f014d6d37 100644 --- a/lib/devise_token_auth/rails/routes.rb +++ b/lib/devise_token_auth/rails/routes.rb @@ -23,7 +23,7 @@ def mount_devise_token_auth_for(resource, opts) controllers[:unlocks] = unlocks_ctrl if unlocks_ctrl # remove any unwanted devise modules - opts[:skip].each{|item| controllers.delete(item)} + opts[:skip].each{ |item| controllers.delete(item) } devise_for resource.pluralize.underscore.gsub('/', '_').to_sym, class_name: resource, @@ -66,7 +66,7 @@ def mount_devise_token_auth_for(resource, opts) # preserve the resource class thru oauth authentication by setting name of # resource as "resource_class" param - match "#{full_path}/:provider", to: redirect{|params, request| + match "#{full_path}/:provider", to: redirect{ |params, request| # get the current querystring qs = CGI::parse(request.env['QUERY_STRING']) @@ -76,7 +76,7 @@ def mount_devise_token_auth_for(resource, opts) set_omniauth_path_prefix!(DeviseTokenAuth.omniauth_prefix) - redirect_params = {}.tap {|hash| qs.each{|k, v| hash[k] = v.first}} + redirect_params = {}.tap { |hash| qs.each{ |k, v| hash[k] = v.first } } if DeviseTokenAuth.redirect_whitelist redirect_url = request.params['auth_origin_url'] diff --git a/test/lib/generators/devise_token_auth/install_generator_test.rb b/test/lib/generators/devise_token_auth/install_generator_test.rb index 14d6fbeae..6a0bff709 100644 --- a/test/lib/generators/devise_token_auth/install_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_test.rb @@ -55,7 +55,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase # account for rails version 5 active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base' - @f = File.open(@fname, 'w') {|f| + @f = File.open(@fname, 'w') { |f| f.write <<-RUBY class User < #{active_record_needle} @@ -95,7 +95,7 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') {|f| + @f = File.open(@fname, 'w') { |f| f.write <<-RUBY Rails.application.routes.draw do patch '/chong', to: 'bong#index' @@ -155,7 +155,7 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') {|f| + @f = File.open(@fname, 'w') { |f| f.write <<-RUBY class ApplicationController < ActionController::Base def whatever diff --git a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb index fb89d1a43..b9c67de81 100644 --- a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb @@ -60,7 +60,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase # account for rails version 5 active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base' - @f = File.open(@fname, 'w') {|f| + @f = File.open(@fname, 'w') { |f| f.write <<-RUBY class User < #{active_record_needle} @@ -100,7 +100,7 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') {|f| + @f = File.open(@fname, 'w') { |f| f.write <<-RUBY Rails.application.routes.draw do patch '/chong', to: 'bong#index' @@ -160,7 +160,7 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') {|f| + @f = File.open(@fname, 'w') { |f| f.write <<-RUBY class ApplicationController < ActionController::Base def whatever From 98f6b039cd8991a86b67e863569bfce4ec18f468 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 16:07:40 -0700 Subject: [PATCH 29/54] Fix Layout/EmptyLinesAroundClassBody --- .rubocop_todo.yml | 14 -------------- .../omniauth_callbacks_controller.rb | 2 -- .../devise_token_auth/sessions_controller.rb | 1 - .../controllers/custom/confirmations_controller.rb | 2 -- .../app/controllers/custom/passwords_controller.rb | 2 -- .../controllers/custom/registrations_controller.rb | 2 -- .../app/controllers/custom/sessions_controller.rb | 2 -- .../custom/token_validations_controller.rb | 2 -- 8 files changed, 27 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bf2d55889..9484bd5e7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -53,20 +53,6 @@ Layout/EmptyLinesAroundBlockBody: - 'test/controllers/devise_token_auth/passwords_controller_test.rb' - 'test/dummy/db/schema.rb' -# Offense count: 13 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only -Layout/EmptyLinesAroundClassBody: - Exclude: - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/sessions_controller.rb' - - 'test/dummy/app/controllers/custom/confirmations_controller.rb' - - 'test/dummy/app/controllers/custom/passwords_controller.rb' - - 'test/dummy/app/controllers/custom/registrations_controller.rb' - - 'test/dummy/app/controllers/custom/sessions_controller.rb' - - 'test/dummy/app/controllers/custom/token_validations_controller.rb' - # Offense count: 5 # Cop supports --auto-correct. Layout/EmptyLinesAroundMethodBody: diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index e8fdf91f6..7d6ffecf9 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -1,6 +1,5 @@ module DeviseTokenAuth class OmniauthCallbacksController < DeviseTokenAuth::ApplicationController - attr_reader :auth_params skip_before_action :set_user_by_token, raise: false skip_after_action :update_auth_header @@ -236,6 +235,5 @@ def get_resource_from_auth_hash @resource end - end end diff --git a/app/controllers/devise_token_auth/sessions_controller.rb b/app/controllers/devise_token_auth/sessions_controller.rb index 613134347..3e70115e1 100644 --- a/app/controllers/devise_token_auth/sessions_controller.rb +++ b/app/controllers/devise_token_auth/sessions_controller.rb @@ -125,6 +125,5 @@ def render_destroy_error def resource_params params.permit(*params_for_resource(:sign_in)) end - end end diff --git a/test/dummy/app/controllers/custom/confirmations_controller.rb b/test/dummy/app/controllers/custom/confirmations_controller.rb index 8e29e8976..f2e9e8a8d 100644 --- a/test/dummy/app/controllers/custom/confirmations_controller.rb +++ b/test/dummy/app/controllers/custom/confirmations_controller.rb @@ -1,5 +1,4 @@ class Custom::ConfirmationsController < DeviseTokenAuth::ConfirmationsController - def show super do |resource| @show_block_called = true unless resource.nil? @@ -9,5 +8,4 @@ def show def show_block_called? @show_block_called == true end - end diff --git a/test/dummy/app/controllers/custom/passwords_controller.rb b/test/dummy/app/controllers/custom/passwords_controller.rb index 7ac364c03..456aece87 100644 --- a/test/dummy/app/controllers/custom/passwords_controller.rb +++ b/test/dummy/app/controllers/custom/passwords_controller.rb @@ -1,5 +1,4 @@ class Custom::PasswordsController < DeviseTokenAuth::PasswordsController - def create super do |resource| @create_block_called = true unless resource.nil? @@ -35,5 +34,4 @@ def update_block_called? def render_update_success render json: { custom: 'foo' } end - end diff --git a/test/dummy/app/controllers/custom/registrations_controller.rb b/test/dummy/app/controllers/custom/registrations_controller.rb index 760c33e90..2b749d831 100644 --- a/test/dummy/app/controllers/custom/registrations_controller.rb +++ b/test/dummy/app/controllers/custom/registrations_controller.rb @@ -1,5 +1,4 @@ class Custom::RegistrationsController < DeviseTokenAuth::RegistrationsController - def create super do |resource| @create_block_called = true @@ -35,5 +34,4 @@ def destroy_block_called? def render_create_success render json: { custom: 'foo' } end - end diff --git a/test/dummy/app/controllers/custom/sessions_controller.rb b/test/dummy/app/controllers/custom/sessions_controller.rb index d9bef07cb..2f83875c2 100644 --- a/test/dummy/app/controllers/custom/sessions_controller.rb +++ b/test/dummy/app/controllers/custom/sessions_controller.rb @@ -1,5 +1,4 @@ class Custom::SessionsController < DeviseTokenAuth::SessionsController - def create super do |resource| @create_block_called = true unless resource.nil? @@ -25,5 +24,4 @@ def destroy_block_called? def render_create_success render json: { custom: 'foo' } end - end diff --git a/test/dummy/app/controllers/custom/token_validations_controller.rb b/test/dummy/app/controllers/custom/token_validations_controller.rb index d395e0910..70078adf5 100644 --- a/test/dummy/app/controllers/custom/token_validations_controller.rb +++ b/test/dummy/app/controllers/custom/token_validations_controller.rb @@ -1,5 +1,4 @@ class Custom::TokenValidationsController < DeviseTokenAuth::TokenValidationsController - def validate_token super do |resource| @validate_token_block_called = true unless resource.nil? @@ -15,5 +14,4 @@ def validate_token_block_called? def render_validate_token_success render json: { custom: 'foo' } end - end From 0250c2717f77fe106bb22974f18ff248df0ad397 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 16:09:25 -0700 Subject: [PATCH 30/54] Fix Layout/SpaceAroundEqualsInParameterDefault --- .rubocop_todo.yml | 12 ------------ .../devise_token_auth/application_controller.rb | 4 ++-- .../devise_token_auth/concerns/resource_finder.rb | 2 +- .../concerns/set_user_by_token.rb | 2 +- app/models/devise_token_auth/concerns/user.rb | 14 +++++++------- lib/devise_token_auth/controllers/helpers.rb | 2 +- 6 files changed, 12 insertions(+), 24 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9484bd5e7..b9e946474 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -137,18 +137,6 @@ Layout/SpaceAfterComma: - 'lib/generators/devise_token_auth/install_generator.rb' - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' -# Offense count: 12 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'app/controllers/devise_token_auth/application_controller.rb' - - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/controllers/helpers.rb' - # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. diff --git a/app/controllers/devise_token_auth/application_controller.rb b/app/controllers/devise_token_auth/application_controller.rb index 558bb8feb..a072d7cbe 100644 --- a/app/controllers/devise_token_auth/application_controller.rb +++ b/app/controllers/devise_token_auth/application_controller.rb @@ -3,7 +3,7 @@ class ApplicationController < DeviseController include DeviseTokenAuth::Concerns::SetUserByToken include DeviseTokenAuth::Concerns::ResourceFinder - def resource_data(opts={}) + def resource_data(opts = {}) response_data = opts[:resource_json] || @resource.as_json if json_api? response_data['type'] = @resource.class.name.parameterize @@ -38,7 +38,7 @@ def params_for_resource(resource) devise_parameter_sanitizer.instance_values['permitted'][resource] end - def resource_class(m=nil) + def resource_class(m = nil) if m mapping = Devise.mappings[m] else diff --git a/app/controllers/devise_token_auth/concerns/resource_finder.rb b/app/controllers/devise_token_auth/concerns/resource_finder.rb index 529516441..ecd15b3c0 100644 --- a/app/controllers/devise_token_auth/concerns/resource_finder.rb +++ b/app/controllers/devise_token_auth/concerns/resource_finder.rb @@ -27,7 +27,7 @@ def find_resource(field, value) @resource = resource_class.where(q, value).first end - def resource_class(m=nil) + def resource_class(m = nil) if m mapping = Devise.mappings[m] else diff --git a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb index cfb55d483..92d298e69 100644 --- a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +++ b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb @@ -34,7 +34,7 @@ def ensure_pristine_resource end # user auth - def set_user_by_token(mapping=nil) + def set_user_by_token(mapping = nil) # determine target authentication class rc = resource_class(mapping) diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 0831918b0..627944f08 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -52,7 +52,7 @@ def password_required? end # override devise method to include additional info as opts hash - def send_confirmation_instructions(opts={}) + def send_confirmation_instructions(opts = {}) generate_confirmation_token! unless @raw_confirmation_token # fall back to "default" config name @@ -64,7 +64,7 @@ def send_confirmation_instructions(opts={}) end # override devise method to include additional info as opts hash - def send_reset_password_instructions(opts={}) + def send_reset_password_instructions(opts = {}) token = set_reset_password_token # fall back to "default" config name @@ -75,7 +75,7 @@ def send_reset_password_instructions(opts={}) end # override devise method to include additional info as opts hash - def send_unlock_instructions(opts={}) + def send_unlock_instructions(opts = {}) raw, enc = Devise.token_generator.generate(self.class, :unlock_token) self.unlock_token = enc save(validate: false) @@ -115,7 +115,7 @@ def database_exists? end end - def valid_token?(token, client_id='default') + def valid_token?(token, client_id = 'default') return false unless tokens[client_id] return true if token_is_current?(token, client_id) return true if token_can_be_reused?(token, client_id) @@ -164,7 +164,7 @@ def token_can_be_reused?(token, client_id) end # update user's auth token (should happen on each request) - def create_new_auth_token(client_id=nil) + def create_new_auth_token(client_id = nil) now = Time.zone.now client_id, token = create_token( @@ -177,7 +177,7 @@ def create_new_auth_token(client_id=nil) update_auth_header(token, client_id) end - def build_auth_header(token, client_id='default') + def build_auth_header(token, client_id = 'default') # client may use expiry to prevent validation request if expired # must be cast as string or headers will break expiry = tokens[client_id]['expiry'] || tokens[client_id][:expiry] @@ -191,7 +191,7 @@ def build_auth_header(token, client_id='default') } end - def update_auth_header(token, client_id='default') + def update_auth_header(token, client_id = 'default') headers = build_auth_header(token, client_id) clean_old_tokens save! diff --git a/lib/devise_token_auth/controllers/helpers.rb b/lib/devise_token_auth/controllers/helpers.rb index e2e646199..29ae8c32b 100644 --- a/lib/devise_token_auth/controllers/helpers.rb +++ b/lib/devise_token_auth/controllers/helpers.rb @@ -26,7 +26,7 @@ module ClassMethods # before_action ->{ authenticate_blogger! :admin } # Redirects to the admin login page # current_blogger :user # Preferably returns a User if one is signed in # - def devise_token_auth_group(group_name, opts={}) + def devise_token_auth_group(group_name, opts = {}) mappings = "[#{opts[:contains].map { |m| ":#{m}" }.join(',')}]" class_eval <<-METHODS, __FILE__, __LINE__ + 1 From db7dcf06fc800fbd0f92ef37c87377895b9ef252 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 16:11:03 -0700 Subject: [PATCH 31/54] Fix Style/BracesAroundHashParameters --- .rubocop_todo.yml | 9 --------- .../devise_token_auth/omniauth_callbacks_controller.rb | 2 +- .../devise_token_auth/registrations_controller.rb | 6 +++--- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b9e946474..7b87dfd70 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -368,15 +368,6 @@ Style/BlockDelimiters: - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: - Exclude: - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/registrations_controller.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/ColonMethodCall: diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 7d6ffecf9..5c2694f54 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -45,7 +45,7 @@ def omniauth_success def omniauth_failure @error = params[:message] - render_data_or_redirect('authFailure', { error: @error }) + render_data_or_redirect('authFailure', error: @error) end protected diff --git a/app/controllers/devise_token_auth/registrations_controller.rb b/app/controllers/devise_token_auth/registrations_controller.rb index e37f47f5d..9f68fcfbe 100644 --- a/app/controllers/devise_token_auth/registrations_controller.rb +++ b/app/controllers/devise_token_auth/registrations_controller.rb @@ -161,7 +161,7 @@ def render_update_error end def render_update_error_user_not_found - render_error(404, I18n.t('devise_token_auth.registrations.user_not_found'), { status: 'error' }) + render_error(404, I18n.t('devise_token_auth.registrations.user_not_found'), status: 'error') end def render_destroy_success @@ -172,7 +172,7 @@ def render_destroy_success end def render_destroy_error - render_error(404, I18n.t('devise_token_auth.registrations.account_to_destroy_not_found'), { status: 'error' }) + render_error(404, I18n.t('devise_token_auth.registrations.account_to_destroy_not_found'), status: 'error') end private @@ -198,7 +198,7 @@ def validate_account_update_params end def validate_post_data which, message - render_error(:unprocessable_entity, message, { status: 'error' }) if which.empty? + render_error(:unprocessable_entity, message, status: 'error') if which.empty? end end end From c3d093e52ae13cd6a8c9c909de4e0ab15de54681 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 17:22:46 -0700 Subject: [PATCH 32/54] Fix Layout/AlignParameters --- .rubocop_todo.yml | 15 --------------- app/models/devise_token_auth/concerns/user.rb | 2 +- lib/devise_token_auth/rails/routes.rb | 10 +++++----- test/dummy/app/models/nice_user.rb | 4 ++-- test/dummy/app/models/scoped_user.rb | 4 ++-- test/dummy/app/models/unregisterable_user.rb | 4 ++-- test/dummy/config.ru | 6 +++--- test/dummy/config/initializers/omniauth.rb | 4 ++-- test/dummy/config/routes.rb | 16 ++++++++-------- 9 files changed, 25 insertions(+), 40 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7b87dfd70..86b5f788c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -14,21 +14,6 @@ Gemspec/OrderedDependencies: Exclude: - 'devise_token_auth.gemspec' -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_parameter, with_fixed_indentation -Layout/AlignParameters: - Exclude: - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/rails/routes.rb' - - 'test/dummy/app/models/nice_user.rb' - - 'test/dummy/app/models/scoped_user.rb' - - 'test/dummy/app/models/unregisterable_user.rb' - - 'test/dummy/config.ru' - - 'test/dummy/config/initializers/omniauth.rb' - - 'test/dummy/config/routes.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 627944f08..d6b7f9f7a 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -20,7 +20,7 @@ def self.tokens_match?(token_hash, token) self.devise_modules.delete(:omniauthable) else devise :database_authenticatable, :registerable, - :recoverable, :trackable, :validatable, :confirmable + :recoverable, :trackable, :validatable, :confirmable end unless tokens_has_json_column_type? diff --git a/lib/devise_token_auth/rails/routes.rb b/lib/devise_token_auth/rails/routes.rb index f014d6d37..ffae88019 100644 --- a/lib/devise_token_auth/rails/routes.rb +++ b/lib/devise_token_auth/rails/routes.rb @@ -26,11 +26,11 @@ def mount_devise_token_auth_for(resource, opts) opts[:skip].each{ |item| controllers.delete(item) } devise_for resource.pluralize.underscore.gsub('/', '_').to_sym, - class_name: resource, - module: :devise, - path: opts[:at].to_s, - controllers: controllers, - skip: opts[:skip] + [:omniauth_callbacks] + class_name: resource, + module: :devise, + path: opts[:at].to_s, + controllers: controllers, + skip: opts[:skip] + [:omniauth_callbacks] unnest_namespace do # get full url path as if it were namespaced diff --git a/test/dummy/app/models/nice_user.rb b/test/dummy/app/models/nice_user.rb index a151ae1e2..2c77e229d 100644 --- a/test/dummy/app/models/nice_user.rb +++ b/test/dummy/app/models/nice_user.rb @@ -1,7 +1,7 @@ class NiceUser < ActiveRecord::Base # Include default devise modules. devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable, - :confirmable, :omniauthable + :recoverable, :rememberable, :trackable, :validatable, + :confirmable, :omniauthable include DeviseTokenAuth::Concerns::User end diff --git a/test/dummy/app/models/scoped_user.rb b/test/dummy/app/models/scoped_user.rb index 5dca1286f..519b875ea 100644 --- a/test/dummy/app/models/scoped_user.rb +++ b/test/dummy/app/models/scoped_user.rb @@ -1,7 +1,7 @@ class ScopedUser < ActiveRecord::Base # Include default devise modules. devise :database_authenticatable, :registerable, - :recoverable, :rememberable, :trackable, :validatable, - :confirmable, :omniauthable + :recoverable, :rememberable, :trackable, :validatable, + :confirmable, :omniauthable include DeviseTokenAuth::Concerns::User end diff --git a/test/dummy/app/models/unregisterable_user.rb b/test/dummy/app/models/unregisterable_user.rb index 44f596d40..7060e35e3 100644 --- a/test/dummy/app/models/unregisterable_user.rb +++ b/test/dummy/app/models/unregisterable_user.rb @@ -1,7 +1,7 @@ class UnregisterableUser < ActiveRecord::Base # Include default devise modules. devise :database_authenticatable, - :recoverable, :trackable, :validatable, - :confirmable, :omniauthable + :recoverable, :trackable, :validatable, + :confirmable, :omniauthable include DeviseTokenAuth::Concerns::User end diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 8c6d62ca3..2c4f92632 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -9,8 +9,8 @@ use Rack::Cors do allow do origins '*' resource '*', - headers: :any, - expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'], - methods: %i[get post options delete put] + headers: :any, + expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'], + methods: %i[get post options delete put] end end diff --git a/test/dummy/config/initializers/omniauth.rb b/test/dummy/config/initializers/omniauth.rb index 05591c8c9..59f5c16ca 100644 --- a/test/dummy/config/initializers/omniauth.rb +++ b/test/dummy/config/initializers/omniauth.rb @@ -3,6 +3,6 @@ provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'] provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'] provider :developer, - fields: [:first_name, :last_name], - uid_field: :last_name + fields: [:first_name, :last_name], + uid_field: :last_name end diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 9a778916a..f8be8fbd1 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -46,14 +46,14 @@ # test namespacing with not created devise mapping namespace :api_v2, defaults: { format: :json } do mount_devise_token_auth_for 'ScopedUser', - at: 'auth', - controllers: { - omniauth_callbacks: 'api_v2/omniauth_callbacks', - sessions: 'api_v2/sessions', - registrations: 'api_v2/registrations', - confirmations: 'api_v2/confirmations', - passwords: 'api_v2/passwords' - } + at: 'auth', + controllers: { + omniauth_callbacks: 'api_v2/omniauth_callbacks', + sessions: 'api_v2/sessions', + registrations: 'api_v2/registrations', + confirmations: 'api_v2/confirmations', + passwords: 'api_v2/passwords' + } end # this route will authorize visitors using the User class From 408d6c9da8bb0b4ae3ed3c47e7208058444af762 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 17:35:39 -0700 Subject: [PATCH 33/54] Fix Style/WordArray - Enforce for array literals of 3 or more elements --- .rubocop.yml | 8 ++++++++ .rubocop_todo.yml | 10 ---------- Rakefile | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ddddc1599..b422bf308 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -59,6 +59,14 @@ Style/SymbolArray: EnforcedStyle: percent MinSize: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + Enabled: true + EnforcedStyle: percent + MinSize: 3 + # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: inherit_mode: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 86b5f788c..27430fbdc 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -633,13 +633,3 @@ Style/TrailingUnderscoreVariable: Style/UnneededPercentQ: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, MinSize, WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - Exclude: - - 'Rakefile' - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'test/dummy/db/schema.rb' diff --git a/Rakefile b/Rakefile index 8b904d7e6..81fe125c4 100644 --- a/Rakefile +++ b/Rakefile @@ -35,6 +35,6 @@ require 'rubocop/rake_task' desc 'Run RuboCop' RuboCop::RakeTask.new(:rubocop) do |task| - task.formatters = ['fuubar', 'offenses', 'worst'] + task.formatters = %w[fuubar offenses worst] task.fail_on_error = false # don't abort rake on failure end From 06ca1beb8b5b48833dc14c412cb12b0d90e52989 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Thu, 29 Mar 2018 18:03:10 -0700 Subject: [PATCH 34/54] Fix Style/BlockDelimiters - Ignore violations for minitest assertion methods. --- .rubocop.yml | 17 +++++++++++++++++ .rubocop_todo.yml | 14 -------------- .../omniauth_callbacks_controller.rb | 4 ++-- .../devise_token_auth/install_generator_test.rb | 12 ++++++------ .../install_generator_with_namespace_test.rb | 12 ++++++------ 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b422bf308..d683f1a46 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,23 @@ AllCops: - 'test/dummy/tmp/**/*' - 'test/dummy/log/**/*' +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + IgnoredMethods: + - assert_output + - assert_raises + - assert_silent + - assert_throws + - refute_output + - refute_raises + - refute_silent + - refute_throws + # Offense count: 130 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 27430fbdc..53c044a0c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -339,20 +339,6 @@ Style/BarePercentLiterals: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. -# SupportedStyles: line_count_based, semantic, braces_for_chaining -# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object -# FunctionalMethods: let, let!, subject, watch -# IgnoredMethods: lambda, proc, it -Style/BlockDelimiters: - Exclude: - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'test/controllers/devise_token_auth/passwords_controller_test.rb' - - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/ColonMethodCall: diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 5c2694f54..5fb8d984f 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -85,13 +85,13 @@ def assign_provider_attrs(user, auth_hash) def whitelisted_params whitelist = params_for_resource(:sign_up) - whitelist.inject({}){ |coll, key| + whitelist.inject({}) do |coll, key| param = omniauth_params[key.to_s] if param coll[key] = param end coll - } + end end def resource_class(mapping = nil) diff --git a/test/lib/generators/devise_token_auth/install_generator_test.rb b/test/lib/generators/devise_token_auth/install_generator_test.rb index 6a0bff709..34ab7d6ff 100644 --- a/test/lib/generators/devise_token_auth/install_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_test.rb @@ -55,7 +55,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase # account for rails version 5 active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base' - @f = File.open(@fname, 'w') { |f| + @f = File.open(@fname, 'w') do |f| f.write <<-RUBY class User < #{active_record_needle} @@ -64,7 +64,7 @@ def whatever end end RUBY - } + end run_generator end @@ -95,13 +95,13 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') { |f| + @f = File.open(@fname, 'w') do |f| f.write <<-RUBY Rails.application.routes.draw do patch '/chong', to: 'bong#index' end RUBY - } + end run_generator end @@ -155,7 +155,7 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') { |f| + @f = File.open(@fname, 'w') do |f| f.write <<-RUBY class ApplicationController < ActionController::Base def whatever @@ -163,7 +163,7 @@ def whatever end end RUBY - } + end run_generator end diff --git a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb index b9c67de81..3a660a306 100644 --- a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb @@ -60,7 +60,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase # account for rails version 5 active_record_needle = (Rails::VERSION::MAJOR == 5) ? 'ApplicationRecord' : 'ActiveRecord::Base' - @f = File.open(@fname, 'w') { |f| + @f = File.open(@fname, 'w') do |f| f.write <<-RUBY class User < #{active_record_needle} @@ -69,7 +69,7 @@ def whatever end end RUBY - } + end run_generator end @@ -100,13 +100,13 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') { |f| + @f = File.open(@fname, 'w') do |f| f.write <<-RUBY Rails.application.routes.draw do patch '/chong', to: 'bong#index' end RUBY - } + end run_generator %W(#{user_class} auth) end @@ -160,7 +160,7 @@ def whatever # make dir if not exists FileUtils.mkdir_p(@dir) - @f = File.open(@fname, 'w') { |f| + @f = File.open(@fname, 'w') do |f| f.write <<-RUBY class ApplicationController < ActionController::Base def whatever @@ -168,7 +168,7 @@ def whatever end end RUBY - } + end run_generator %W(#{user_class} auth) end From 4b30adb918de1bbf8f0b1c4b769f91aeeeb27fa0 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 30 Mar 2018 00:31:25 -0700 Subject: [PATCH 35/54] Fix Style/IfUnlessModifier --- .rubocop_todo.yml | 17 ----------------- .../devise_token_auth/application_controller.rb | 4 +--- .../omniauth_callbacks_controller.rb | 4 +--- .../devise_token_auth/passwords_controller.rb | 12 +++--------- .../devise_token_auth/unlocks_controller.rb | 4 +--- app/models/devise_token_auth/concerns/user.rb | 8 ++------ .../devise_token_auth/install_generator.rb | 4 +--- 7 files changed, 9 insertions(+), 44 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 53c044a0c..9bc84f896 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -425,23 +425,6 @@ Style/GuardClause: - 'test/dummy/app/models/user.rb' - 'test/test_helper.rb' -# Offense count: 23 -# Cop supports --auto-correct. -Style/IfUnlessModifier: - Exclude: - - 'app/controllers/devise_token_auth/application_controller.rb' - - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' - - 'app/controllers/devise_token_auth/confirmations_controller.rb' - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/registrations_controller.rb' - - 'app/controllers/devise_token_auth/sessions_controller.rb' - - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'app/validators/email_validator.rb' - - 'lib/devise_token_auth/controllers/helpers.rb' - - 'lib/generators/devise_token_auth/install_generator.rb' - # Offense count: 5 # Cop supports --auto-correct. Style/LineEndConcatenation: diff --git a/app/controllers/devise_token_auth/application_controller.rb b/app/controllers/devise_token_auth/application_controller.rb index a072d7cbe..31e91aded 100644 --- a/app/controllers/devise_token_auth/application_controller.rb +++ b/app/controllers/devise_token_auth/application_controller.rb @@ -5,9 +5,7 @@ class ApplicationController < DeviseController def resource_data(opts = {}) response_data = opts[:resource_json] || @resource.as_json - if json_api? - response_data['type'] = @resource.class.name.parameterize - end + response_data['type'] = @resource.class.name.parameterize if json_api? response_data end diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 5fb8d984f..0c843a7db 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -87,9 +87,7 @@ def whitelisted_params whitelist.inject({}) do |coll, key| param = omniauth_params[key.to_s] - if param - coll[key] = param - end + coll[key] = param if param coll end end diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index d006c379b..83b4cb1a9 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -6,9 +6,7 @@ class PasswordsController < DeviseTokenAuth::ApplicationController # this action is responsible for generating password reset tokens and # sending emails def create - unless resource_params[:email] - return render_create_error_missing_email - end + return render_create_error_missing_email unless resource_params[:email] # give redirect value from params priority @redirect_url = params[:redirect_url] @@ -16,9 +14,7 @@ def create # fall back to default value if provided @redirect_url ||= DeviseTokenAuth.default_password_reset_url - unless @redirect_url - return render_create_error_missing_redirect_url - end + return render_create_error_missing_redirect_url unless @redirect_url # if whitelist is set, validate redirect_url against whitelist if DeviseTokenAuth.redirect_whitelist @@ -80,9 +76,7 @@ def edit def update # make sure user is authorized - unless @resource - return render_update_error_unauthorized - end + return render_update_error_unauthorized unless @resource # make sure account doesn't use oauth2 provider unless @resource.provider == 'email' diff --git a/app/controllers/devise_token_auth/unlocks_controller.rb b/app/controllers/devise_token_auth/unlocks_controller.rb index cfdb58664..897cd7fd3 100644 --- a/app/controllers/devise_token_auth/unlocks_controller.rb +++ b/app/controllers/devise_token_auth/unlocks_controller.rb @@ -5,9 +5,7 @@ class UnlocksController < DeviseTokenAuth::ApplicationController # this action is responsible for generating unlock tokens and # sending emails def create - unless resource_params[:email] - return render_create_error_missing_email - end + return render_create_error_missing_email unless resource_params[:email] @email = get_case_insensitive_field_from_resource_params(:email) @resource = find_resource(:email, @email) diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index d6b7f9f7a..bb3be2747 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -8,9 +8,7 @@ def self.tokens_match?(token_hash, token) key = "#{token_hash}/#{token}" result = @token_equality_cache[key] ||= (::BCrypt::Password.new(token_hash) == token) - if @token_equality_cache.size > 10000 - @token_equality_cache = {} - end + @token_equality_cache = {} if @token_equality_cache.size > 10000 result end @@ -23,9 +21,7 @@ def self.tokens_match?(token_hash, token) :recoverable, :trackable, :validatable, :confirmable end - unless tokens_has_json_column_type? - serialize :tokens, JSON - end + serialize :tokens, JSON unless tokens_has_json_column_type? if DeviseTokenAuth.default_callbacks include DeviseTokenAuth::Concerns::UserOmniauthCallbacks diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index 07f27fad0..45492e299 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -115,9 +115,7 @@ def parse_file_for_line(filename, str) File.open(File.join(destination_root, filename)) do |f| f.each_line do |line| - if line =~ /(#{Regexp.escape(str)})/mi - match = line - end + match = line if line =~ /(#{Regexp.escape(str)})/mi end end match From 6b5541460c8c8a03ce5445369a814901b37d1a9d Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 30 Mar 2018 00:36:13 -0700 Subject: [PATCH 36/54] Fix Style/PercentLiteralDelimiters --- .rubocop_todo.yml | 9 --------- .../omniauth_callbacks_controller.rb | 4 ++-- .../devise_token_auth/install_generator_test.rb | 2 +- .../install_generator_with_namespace_test.rb | 14 +++++++------- 4 files changed, 10 insertions(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9bc84f896..1ce7a190a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -520,15 +520,6 @@ Style/ParenthesesAroundCondition: - 'app/models/devise_token_auth/concerns/user.rb' - 'lib/devise_token_auth/url.rb' -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Exclude: - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' - # Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: . diff --git a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb index 0c843a7db..44585b524 100644 --- a/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb +++ b/app/controllers/devise_token_auth/omniauth_callbacks_controller.rb @@ -202,14 +202,14 @@ def render_data_or_redirect(message, data, user_data = {}) end def fallback_render(text) - render inline: %Q| + render inline: %Q( #{text} - | + ) end def get_resource_from_auth_hash diff --git a/test/lib/generators/devise_token_auth/install_generator_test.rb b/test/lib/generators/devise_token_auth/install_generator_test.rb index 34ab7d6ff..c987e31e8 100644 --- a/test/lib/generators/devise_token_auth/install_generator_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_test.rb @@ -122,7 +122,7 @@ def whatever describe 'subsequent models' do before do - run_generator %w(Mang mangs) + run_generator %w[Mang mangs] end test 'migration is created' do diff --git a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb index 3a660a306..443ddaac8 100644 --- a/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb +++ b/test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb @@ -16,7 +16,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase setup :prepare_destination before do - run_generator %W(#{user_class} auth) + run_generator %W[#{user_class} auth] end test 'user model (with namespace) is created, concern is included' do @@ -42,7 +42,7 @@ class InstallGeneratorTest < Rails::Generators::TestCase end test 'subsequent runs raise no errors' do - run_generator %W(#{user_class} auth) + run_generator %W[#{user_class} auth] end end @@ -108,7 +108,7 @@ def whatever RUBY end - run_generator %W(#{user_class} auth) + run_generator %W[#{user_class} auth] end test 'route method for user model with namespace is appended to routes file' do @@ -118,7 +118,7 @@ def whatever end test 'subsequent runs do not modify file' do - run_generator %W(#{user_class} auth) + run_generator %W[#{user_class} auth] assert_file 'config/routes.rb' do |routes| matches = routes.scan(/mount_devise_token_auth_for '#{user_class}', at: 'auth'/m).size assert_equal 1, matches @@ -127,7 +127,7 @@ def whatever describe 'subsequent models' do before do - run_generator %w(Mang mangs) + run_generator %w[Mang mangs] end test 'migration is created' do @@ -170,7 +170,7 @@ def whatever RUBY end - run_generator %W(#{user_class} auth) + run_generator %W[#{user_class} auth] end test 'controller concern is appended to application controller' do @@ -180,7 +180,7 @@ def whatever end test 'subsequent runs do not modify file' do - run_generator %W(#{user_class} auth) + run_generator %W[#{user_class} auth] assert_file 'app/controllers/application_controller.rb' do |controller| matches = controller.scan(/include DeviseTokenAuth::Concerns::SetUserByToken/m).size assert_equal 1, matches From 740c9703349696524505a402998df1d735dcdaa5 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 30 Mar 2018 00:41:28 -0700 Subject: [PATCH 37/54] Fix Style/MutableConstant --- .rubocop_todo.yml | 12 ------------ lib/devise_token_auth/version.rb | 2 +- .../overrides/omniauth_callbacks_controller.rb | 2 +- .../controllers/overrides/passwords_controller.rb | 2 +- .../overrides/registrations_controller.rb | 2 +- .../app/controllers/overrides/sessions_controller.rb | 2 +- .../overrides/token_validations_controller.rb | 2 +- test/dummy/app/helpers/application_helper.rb | 2 +- 8 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 1ce7a190a..103685698 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -471,18 +471,6 @@ Style/MultilineTernaryOperator: Exclude: - 'test/dummy/config/environments/test.rb' -# Offense count: 7 -# Cop supports --auto-correct. -Style/MutableConstant: - Exclude: - - 'lib/devise_token_auth/version.rb' - - 'test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb' - - 'test/dummy/app/controllers/overrides/passwords_controller.rb' - - 'test/dummy/app/controllers/overrides/registrations_controller.rb' - - 'test/dummy/app/controllers/overrides/sessions_controller.rb' - - 'test/dummy/app/controllers/overrides/token_validations_controller.rb' - - 'test/dummy/app/helpers/application_helper.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinBodyLength. diff --git a/lib/devise_token_auth/version.rb b/lib/devise_token_auth/version.rb index 03f22c59d..c67559c90 100644 --- a/lib/devise_token_auth/version.rb +++ b/lib/devise_token_auth/version.rb @@ -1,3 +1,3 @@ module DeviseTokenAuth - VERSION = '0.1.43' + VERSION = '0.1.43'.freeze end diff --git a/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb b/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb index f59b89a5e..083a9f606 100644 --- a/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +++ b/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb @@ -1,6 +1,6 @@ module Overrides class OmniauthCallbacksController < DeviseTokenAuth::OmniauthCallbacksController - DEFAULT_NICKNAME = 'stimpy' + DEFAULT_NICKNAME = 'stimpy'.freeze def assign_provider_attrs(user, auth_hash) user.assign_attributes( diff --git a/test/dummy/app/controllers/overrides/passwords_controller.rb b/test/dummy/app/controllers/overrides/passwords_controller.rb index f008d0733..9bcf5bf44 100644 --- a/test/dummy/app/controllers/overrides/passwords_controller.rb +++ b/test/dummy/app/controllers/overrides/passwords_controller.rb @@ -1,6 +1,6 @@ module Overrides class PasswordsController < DeviseTokenAuth::PasswordsController - OVERRIDE_PROOF = '(^^,)' + OVERRIDE_PROOF = '(^^,)'.freeze # this is where users arrive after visiting the email confirmation link def edit diff --git a/test/dummy/app/controllers/overrides/registrations_controller.rb b/test/dummy/app/controllers/overrides/registrations_controller.rb index e4f8e9013..426a72458 100644 --- a/test/dummy/app/controllers/overrides/registrations_controller.rb +++ b/test/dummy/app/controllers/overrides/registrations_controller.rb @@ -1,6 +1,6 @@ module Overrides class RegistrationsController < DeviseTokenAuth::RegistrationsController - OVERRIDE_PROOF = '(^^,)' + OVERRIDE_PROOF = '(^^,)'.freeze def update if @resource diff --git a/test/dummy/app/controllers/overrides/sessions_controller.rb b/test/dummy/app/controllers/overrides/sessions_controller.rb index 18178202f..dbef37839 100644 --- a/test/dummy/app/controllers/overrides/sessions_controller.rb +++ b/test/dummy/app/controllers/overrides/sessions_controller.rb @@ -1,6 +1,6 @@ module Overrides class SessionsController < DeviseTokenAuth::SessionsController - OVERRIDE_PROOF = '(^^,)' + OVERRIDE_PROOF = '(^^,)'.freeze def create @resource = resource_class.find_by(email: resource_params[:email]) diff --git a/test/dummy/app/controllers/overrides/token_validations_controller.rb b/test/dummy/app/controllers/overrides/token_validations_controller.rb index b8160cc2f..a5af64029 100644 --- a/test/dummy/app/controllers/overrides/token_validations_controller.rb +++ b/test/dummy/app/controllers/overrides/token_validations_controller.rb @@ -1,6 +1,6 @@ module Overrides class TokenValidationsController < DeviseTokenAuth::TokenValidationsController - OVERRIDE_PROOF = '(^^,)' + OVERRIDE_PROOF = '(^^,)'.freeze def validate_token # @resource will have been set by set_user_by_token concern diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb index c54abd778..0053fea46 100644 --- a/test/dummy/app/helpers/application_helper.rb +++ b/test/dummy/app/helpers/application_helper.rb @@ -1050,7 +1050,7 @@ module ApplicationHelper 'Zaffre', 'Zinnwaldite brown', 'Zomp' - ] + ].freeze COLOR_SEARCH = FuzzBall::Searcher.new(COLOR_NAMES) end From 323a4387838ee00fe43e25d20ab5850ac4b81ed7 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 30 Mar 2018 00:43:29 -0700 Subject: [PATCH 38/54] Fix Style/AndOr --- .rubocop_todo.yml | 11 ----------- .../controllers/overrides/confirmations_controller.rb | 2 +- .../app/controllers/overrides/passwords_controller.rb | 2 +- .../app/controllers/overrides/sessions_controller.rb | 4 ++-- test/dummy/app/models/user.rb | 2 +- 5 files changed, 5 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 103685698..19d2af726 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -320,17 +320,6 @@ Performance/StringReplacement: - 'lib/devise_token_auth/rails/routes.rb' - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: always, conditionals -Style/AndOr: - Exclude: - - 'test/dummy/app/controllers/overrides/confirmations_controller.rb' - - 'test/dummy/app/controllers/overrides/passwords_controller.rb' - - 'test/dummy/app/controllers/overrides/sessions_controller.rb' - - 'test/dummy/app/models/user.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. diff --git a/test/dummy/app/controllers/overrides/confirmations_controller.rb b/test/dummy/app/controllers/overrides/confirmations_controller.rb index a685e5202..f546a0cac 100644 --- a/test/dummy/app/controllers/overrides/confirmations_controller.rb +++ b/test/dummy/app/controllers/overrides/confirmations_controller.rb @@ -3,7 +3,7 @@ class ConfirmationsController < DeviseTokenAuth::ConfirmationsController def show @resource = resource_class.confirm_by_token(params[:confirmation_token]) - if @resource and @resource.id + if @resource && @resource.id client_id, token = @resource.create_token @resource.save! diff --git a/test/dummy/app/controllers/overrides/passwords_controller.rb b/test/dummy/app/controllers/overrides/passwords_controller.rb index 9bcf5bf44..c42039618 100644 --- a/test/dummy/app/controllers/overrides/passwords_controller.rb +++ b/test/dummy/app/controllers/overrides/passwords_controller.rb @@ -8,7 +8,7 @@ def edit reset_password_token: resource_params[:reset_password_token] ) - if @resource and @resource.id + if @resource && @resource.id client_id, token = @resource.create_token # ensure that user is confirmed diff --git a/test/dummy/app/controllers/overrides/sessions_controller.rb b/test/dummy/app/controllers/overrides/sessions_controller.rb index dbef37839..6865ce341 100644 --- a/test/dummy/app/controllers/overrides/sessions_controller.rb +++ b/test/dummy/app/controllers/overrides/sessions_controller.rb @@ -5,7 +5,7 @@ class SessionsController < DeviseTokenAuth::SessionsController def create @resource = resource_class.find_by(email: resource_params[:email]) - if @resource and valid_params?(:email, resource_params[:email]) and @resource.valid_password?(resource_params[:password]) and @resource.confirmed? + if @resource && valid_params?(:email, resource_params[:email]) && @resource.valid_password?(resource_params[:password]) && @resource.confirmed? @client_id, @token = @resource.create_token @resource.save @@ -14,7 +14,7 @@ def create override_proof: OVERRIDE_PROOF } - elsif @resource and not @resource.confirmed? + elsif @resource && (not @resource.confirmed?) render json: { success: false, errors: [ diff --git a/test/dummy/app/models/user.rb b/test/dummy/app/models/user.rb index 329656eba..e40ad5765 100644 --- a/test/dummy/app/models/user.rb +++ b/test/dummy/app/models/user.rb @@ -6,7 +6,7 @@ class User < ActiveRecord::Base def ensure_correct_favorite_color - if favorite_color and favorite_color != '' + if favorite_color && (favorite_color != '') unless ApplicationHelper::COLOR_NAMES.any?{ |s| s.casecmp(favorite_color)==0 } matches = ApplicationHelper::COLOR_SEARCH.search(favorite_color) closest_match = matches.last[:string] From cbb6def8620775db9bc9ff45084821c9b86c2ac6 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 30 Mar 2018 01:16:20 -0700 Subject: [PATCH 39/54] Fix Style/RedundantSelf --- .rubocop_todo.yml | 7 ------- .../devise_token_auth/concerns/set_user_by_token.rb | 2 +- app/models/devise_token_auth/concerns/user.rb | 10 +++++----- lib/devise_token_auth/engine.rb | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 19d2af726..4817f6ea2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -504,13 +504,6 @@ Style/ParenthesesAroundCondition: Style/RaiseArgs: EnforcedStyle: compact -# Offense count: 7 -# Cop supports --auto-correct. -Style/RedundantSelf: - Exclude: - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/RescueModifier: diff --git a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb index 92d298e69..7188c7c9b 100644 --- a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +++ b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb @@ -82,7 +82,7 @@ def set_user_by_token(mapping = nil) if user && user.valid_token?(@token, @client_id) # sign_in with bypass: true will be deprecated in the next version of Devise - if self.respond_to?(:bypass_sign_in) && DeviseTokenAuth.bypass_sign_in + if respond_to?(:bypass_sign_in) && DeviseTokenAuth.bypass_sign_in bypass_sign_in(user, scope: :user) else sign_in(:user, user, store: false, event: :fetch, bypass: DeviseTokenAuth.bypass_sign_in) diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index bb3be2747..19b21acd2 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -14,8 +14,8 @@ def self.tokens_match?(token_hash, token) included do # Hack to check if devise is already enabled - if self.method_defined?(:devise_modules) - self.devise_modules.delete(:omniauthable) + if method_defined?(:devise_modules) + devise_modules.delete(:omniauthable) else devise :database_authenticatable, :registerable, :recoverable, :trackable, :validatable, :confirmable @@ -89,7 +89,7 @@ def create_token(client_id: nil, token: nil, expiry: nil, **token_extras) token ||= SecureRandom.urlsafe_base64(nil, false) expiry ||= (Time.zone.now + token_lifespan).to_i - self.tokens[client_id] = { + tokens[client_id] = { token: BCrypt::Password.create(token), expiry: expiry }.merge!(token_extras) @@ -103,7 +103,7 @@ module ClassMethods protected def tokens_has_json_column_type? - database_exists? && table_exists? && self.columns_hash['tokens'] && self.columns_hash['tokens'].type.in?([:json, :jsonb]) + database_exists? && table_exists? && columns_hash['tokens'] && columns_hash['tokens'].type.in?([:json, :jsonb]) end def database_exists? @@ -203,7 +203,7 @@ def build_auth_url(base_url, args) end def extend_batch_buffer(token, client_id) - self.tokens[client_id]['updated_at'] = Time.zone.now + tokens[client_id]['updated_at'] = Time.zone.now update_auth_header(token, client_id) end diff --git a/lib/devise_token_auth/engine.rb b/lib/devise_token_auth/engine.rb index 89b581fce..019faf96b 100644 --- a/lib/devise_token_auth/engine.rb +++ b/lib/devise_token_auth/engine.rb @@ -48,7 +48,7 @@ def self.setup(&block) Rails.application.config.after_initialize do if defined?(::OmniAuth) - ::OmniAuth::config.path_prefix = Devise.omniauth_path_prefix = self.omniauth_prefix + ::OmniAuth::config.path_prefix = Devise.omniauth_path_prefix = omniauth_prefix # Omniauth currently does not pass along omniauth.params upon failure redirect # see also: https://github.com/intridea/omniauth/issues/626 From c6b2fda959d2ffbbc05dd6b3c0fa74f178bda599 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 30 Mar 2018 01:18:39 -0700 Subject: [PATCH 40/54] Fix Style/RaiseArgs --- .rubocop_todo.yml | 7 ------- .../devise_token_auth/confirmations_controller.rb | 2 +- app/controllers/devise_token_auth/passwords_controller.rb | 2 +- app/controllers/devise_token_auth/unlocks_controller.rb | 2 +- .../app/controllers/overrides/confirmations_controller.rb | 2 +- .../app/controllers/overrides/passwords_controller.rb | 2 +- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4817f6ea2..fcb0f36d1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -497,13 +497,6 @@ Style/ParenthesesAroundCondition: - 'app/models/devise_token_auth/concerns/user.rb' - 'lib/devise_token_auth/url.rb' -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: . -# SupportedStyles: compact, exploded -Style/RaiseArgs: - EnforcedStyle: compact - # Offense count: 1 # Cop supports --auto-correct. Style/RescueModifier: diff --git a/app/controllers/devise_token_auth/confirmations_controller.rb b/app/controllers/devise_token_auth/confirmations_controller.rb index 762801a5f..6d079e661 100644 --- a/app/controllers/devise_token_auth/confirmations_controller.rb +++ b/app/controllers/devise_token_auth/confirmations_controller.rb @@ -23,7 +23,7 @@ def show redirect_to(@resource.build_auth_url(params[:redirect_url], redirect_headers)) else - raise ActionController::RoutingError.new('Not Found') + raise ActionController::RoutingError, 'Not Found' end end end diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index 83b4cb1a9..b597c307f 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -142,7 +142,7 @@ def render_create_error(errors) end def render_edit_error - raise ActionController::RoutingError.new('Not Found') + raise ActionController::RoutingError, 'Not Found' end def render_update_error_unauthorized diff --git a/app/controllers/devise_token_auth/unlocks_controller.rb b/app/controllers/devise_token_auth/unlocks_controller.rb index 897cd7fd3..10da1db94 100644 --- a/app/controllers/devise_token_auth/unlocks_controller.rb +++ b/app/controllers/devise_token_auth/unlocks_controller.rb @@ -73,7 +73,7 @@ def render_create_error(errors) end def render_show_error - raise ActionController::RoutingError.new('Not Found') + raise ActionController::RoutingError, 'Not Found' end def render_not_found_error diff --git a/test/dummy/app/controllers/overrides/confirmations_controller.rb b/test/dummy/app/controllers/overrides/confirmations_controller.rb index f546a0cac..b1b75cece 100644 --- a/test/dummy/app/controllers/overrides/confirmations_controller.rb +++ b/test/dummy/app/controllers/overrides/confirmations_controller.rb @@ -19,7 +19,7 @@ def show redirect_to(@resource.build_auth_url(params[:redirect_url], redirect_headers)) else - raise ActionController::RoutingError.new('Not Found') + raise ActionController::RoutingError, 'Not Found' end end end diff --git a/test/dummy/app/controllers/overrides/passwords_controller.rb b/test/dummy/app/controllers/overrides/passwords_controller.rb index c42039618..7352872bb 100644 --- a/test/dummy/app/controllers/overrides/passwords_controller.rb +++ b/test/dummy/app/controllers/overrides/passwords_controller.rb @@ -26,7 +26,7 @@ def edit redirect_to(@resource.build_auth_url(params[:redirect_url], redirect_headers)) else - raise ActionController::RoutingError.new('Not Found') + raise ActionController::RoutingError, 'Not Found' end end end From f98035362ac13d274f18af8913abc69794c9c325 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Fri, 30 Mar 2018 01:44:38 -0700 Subject: [PATCH 41/54] Fix Style/LineEndConcatenation --- .rubocop_todo.yml | 7 ------- lib/generators/devise_token_auth/install_generator.rb | 6 +++--- .../dummy/app/controllers/overrides/sessions_controller.rb | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fcb0f36d1..bc2f77747 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -414,13 +414,6 @@ Style/GuardClause: - 'test/dummy/app/models/user.rb' - 'test/test_helper.rb' -# Offense count: 5 -# Cop supports --auto-correct. -Style/LineEndConcatenation: - Exclude: - - 'lib/generators/devise_token_auth/install_generator.rb' - - 'test/dummy/app/controllers/overrides/sessions_controller.rb' - # Offense count: 1 # Cop supports --auto-correct. Style/MethodCallWithoutArgsParentheses: diff --git a/lib/generators/devise_token_auth/install_generator.rb b/lib/generators/devise_token_auth/install_generator.rb index 45492e299..49568f8b8 100644 --- a/lib/generators/devise_token_auth/install_generator.rb +++ b/lib/generators/devise_token_auth/install_generator.rb @@ -86,9 +86,9 @@ def add_route_mount insert_after_line(f, line, str) if existing_user_class - scoped_routes = ''+ - "as :#{user_class.underscore} do\n"+ - " # Define routes for #{user_class} within this block.\n"+ + scoped_routes = ''\ + "as :#{user_class.underscore} do\n"\ + " # Define routes for #{user_class} within this block.\n"\ " end\n" insert_after_line(f, str, scoped_routes) end diff --git a/test/dummy/app/controllers/overrides/sessions_controller.rb b/test/dummy/app/controllers/overrides/sessions_controller.rb index 6865ce341..6d87c7740 100644 --- a/test/dummy/app/controllers/overrides/sessions_controller.rb +++ b/test/dummy/app/controllers/overrides/sessions_controller.rb @@ -18,8 +18,8 @@ def create render json: { success: false, errors: [ - "A confirmation email was sent to your account at #{@resource.email}. "+ - 'You must follow the instructions in the email before your account '+ + "A confirmation email was sent to your account at #{@resource.email}. "\ + 'You must follow the instructions in the email before your account '\ 'can be activated' ] }, status: 401 From 424bef0c664189130870b56b2b4dfa7bf30f019f Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Mon, 9 Apr 2018 18:29:02 -0700 Subject: [PATCH 42/54] Update rubocop todo list. --- .rubocop_todo.yml | 54 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bc2f77747..22a450353 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --exclude-limit 30` -# on 2018-04-02 18:53:29 +0300 using RuboCop version 0.54.0. +# `rubocop --auto-gen-config --exclude-limit 100` +# on 2018-04-09 16:05:53 -0700 using RuboCop version 0.54.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 @@ -97,7 +97,7 @@ Layout/MultilineMethodCallIndentation: Exclude: - 'test/controllers/devise_token_auth/sessions_controller_test.rb' -# Offense count: 7 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented @@ -105,7 +105,6 @@ Layout/MultilineOperationIndentation: Exclude: - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/generators/devise_token_auth/install_generator.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -122,25 +121,22 @@ Layout/SpaceAfterComma: - 'lib/generators/devise_token_auth/install_generator.rb' - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' -# Offense count: 8 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. Layout/SpaceAroundOperators: Exclude: - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'lib/generators/devise_token_auth/install_generator.rb' - - 'test/dummy/app/controllers/overrides/sessions_controller.rb' - 'test/dummy/app/models/user.rb' - 'test/dummy/config/environments/test.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceBeforeBlockBraces: Exclude: - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'lib/devise_token_auth/rails/routes.rb' - 'test/dummy/app/models/user.rb' @@ -208,13 +204,14 @@ Lint/UnusedBlockArgument: - 'test/dummy/app/controllers/custom/registrations_controller.rb' - 'test/dummy/config/initializers/omniauth.rb' -# Offense count: 3 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. Lint/UnusedMethodArgument: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'lib/devise_token_auth/engine.rb' - 'lib/generators/devise_token_auth/install_generator.rb' # Offense count: 3 @@ -224,7 +221,7 @@ Lint/UriEscapeUnescape: - 'test/controllers/devise_token_auth/registrations_controller_test.rb' - 'test/controllers/overrides/confirmations_controller_test.rb' -# Offense count: 32 +# Offense count: 35 Metrics/AbcSize: Max: 76 @@ -239,7 +236,7 @@ Metrics/BlockLength: Metrics/ClassLength: Max: 698 -# Offense count: 13 +# Offense count: 14 Metrics/CyclomaticComplexity: Max: 17 @@ -272,7 +269,7 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 1037 -# Offense count: 12 +# Offense count: 13 Metrics/PerceivedComplexity: Max: 19 @@ -312,6 +309,12 @@ Performance/RedundantMerge: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' +# Offense count: 1 +# Cop supports --auto-correct. +Performance/RegexpMatch: + Exclude: + - 'app/validators/email_validator.rb' + # Offense count: 4 # Cop supports --auto-correct. Performance/StringReplacement: @@ -328,10 +331,11 @@ Style/BarePercentLiterals: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. Style/ColonMethodCall: Exclude: + - 'lib/devise_token_auth/engine.rb' - 'lib/devise_token_auth/rails/routes.rb' # Offense count: 3 @@ -355,7 +359,7 @@ Style/DateTime: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 22 +# Offense count: 24 Style/Documentation: Exclude: - 'spec/**/*' @@ -376,6 +380,7 @@ Style/Documentation: - 'lib/devise_token_auth.rb' - 'lib/devise_token_auth/controllers/helpers.rb' - 'lib/devise_token_auth/controllers/url_helpers.rb' + - 'lib/devise_token_auth/engine.rb' - 'lib/devise_token_auth/rails/routes.rb' - 'lib/devise_token_auth/url.rb' - 'lib/generators/devise_token_auth/install_generator.rb' @@ -473,13 +478,14 @@ Style/Not: Style/NumericLiterals: MinDigits: 15 -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'spec/**/*' + - 'app/controllers/devise_token_auth/confirmations_controller.rb' - 'test/dummy/app/models/user.rb' # Offense count: 3 @@ -496,6 +502,22 @@ Style/RescueModifier: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. +# Whitelist: present?, blank?, presence, try +Style/SafeNavigation: + Exclude: + - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' + - 'app/controllers/devise_token_auth/confirmations_controller.rb' + - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + - 'app/controllers/devise_token_auth/passwords_controller.rb' + - 'app/controllers/devise_token_auth/unlocks_controller.rb' + - 'app/models/devise_token_auth/concerns/user.rb' + - 'lib/devise_token_auth/engine.rb' + - 'test/dummy/app/controllers/overrides/confirmations_controller.rb' + - 'test/dummy/app/controllers/overrides/passwords_controller.rb' + # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowIfMethodIsEmpty. From a35e4c757f374b41e66c5aebb4064b473722ccbc Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Mon, 9 Apr 2018 23:16:17 -0700 Subject: [PATCH 43/54] Fix Layout/MultilineOperationIndentation. --- .rubocop_todo.yml | 9 --------- .../devise_token_auth/concerns/set_user_by_token.rb | 6 +++--- app/models/devise_token_auth/concerns/user.rb | 4 ++-- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 22a450353..f7b580b0a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -97,15 +97,6 @@ Layout/MultilineMethodCallIndentation: Exclude: - 'test/controllers/devise_token_auth/sessions_controller_test.rb' -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/MultilineOperationIndentation: - Exclude: - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - # Offense count: 1 # Cop supports --auto-correct. Layout/SpaceAfterColon: diff --git a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb index 7188c7c9b..6c65f42a6 100644 --- a/app/controllers/devise_token_auth/concerns/set_user_by_token.rb +++ b/app/controllers/devise_token_auth/concerns/set_user_by_token.rb @@ -159,8 +159,8 @@ def update_auth_header def is_batch_request?(user, client_id) !params[:unbatch] && - user.tokens[client_id] && - user.tokens[client_id]['updated_at'] && - Time.parse(user.tokens[client_id]['updated_at']) > @request_started_at - DeviseTokenAuth.batch_request_buffer_throttle + user.tokens[client_id] && + user.tokens[client_id]['updated_at'] && + Time.parse(user.tokens[client_id]['updated_at']) > @request_started_at - DeviseTokenAuth.batch_request_buffer_throttle end end diff --git a/app/models/devise_token_auth/concerns/user.rb b/app/models/devise_token_auth/concerns/user.rb index 19b21acd2..3982f4f52 100644 --- a/app/models/devise_token_auth/concerns/user.rb +++ b/app/models/devise_token_auth/concerns/user.rb @@ -237,10 +237,10 @@ def destroy_expired_tokens def should_remove_tokens_after_password_reset? if Rails::VERSION::MAJOR <= 5 encrypted_password_changed? && - DeviseTokenAuth.remove_tokens_after_password_reset + DeviseTokenAuth.remove_tokens_after_password_reset else saved_change_to_encrypted_password? && - DeviseTokenAuth.remove_tokens_after_password_reset + DeviseTokenAuth.remove_tokens_after_password_reset end end From 1e3b2ff43fd58f7c45beb2185f31e1a782e8a3d1 Mon Sep 17 00:00:00 2001 From: Evan Marell Date: Mon, 9 Apr 2018 23:17:53 -0700 Subject: [PATCH 44/54] Update Layout/MultilineMethodCallIndentation to enforce `indents_relative_to_receiver` --- .rubocop.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index d683f1a46..aa0941b73 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,6 +6,19 @@ AllCops: - 'test/dummy/tmp/**/*' - 'test/dummy/log/**/*' +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +# +# Description from Rubocop Manual: +# This cop checks the indentation of the method name part in method calls +# that span more than one line. +# +# https://rubocop.readthedocs.io/en/latest/cops_layout/#layoutmultilinemethodcallindentation +Layout/MultilineMethodCallIndentation: + Enabled: true + EnforcedStyle: indented_relative_to_receiver + # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining From 08652f899bd696efae31b08588b4535e7703576d Mon Sep 17 00:00:00 2001 From: Krzysztof Rybka Date: Wed, 4 Apr 2018 21:42:31 +0200 Subject: [PATCH 45/54] Setup appraisal for Rails 4.2 --- .travis.yml | 1 + Appraisals | 10 ++++++++++ gemfiles/rails_4_2.gemfile | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 gemfiles/rails_4_2.gemfile diff --git a/.travis.yml b/.travis.yml index 9f35d3a8a..2fc1215a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ rvm: - 2.5.0 gemfile: + - gemfiles/rails_4_2.gemfile - gemfiles/rails_5_0.gemfile - gemfiles/rails_5_1.gemfile diff --git a/Appraisals b/Appraisals index 0f7f81c32..4558c869b 100644 --- a/Appraisals +++ b/Appraisals @@ -1,3 +1,13 @@ +[ + { name: '4-2', version: '4.2.10' } +].each do |rails| + appraise "rails-#{rails[:name]}" do + gem "mysql2", "~> 0.4.10" + gem "pg", "~> 0.21" + gem "rails", "~> #{rails[:version]}" + end +end + [ { name: '5-0', version: '5.0.7' }, { name: '5-1', version: '5.1.6' }, diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile new file mode 100644 index 000000000..1bc7c37ed --- /dev/null +++ b/gemfiles/rails_4_2.gemfile @@ -0,0 +1,39 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "mysql2", "~> 0.4.10" +gem "pg", "~> 0.21" +gem "rails", "~> 4.2.10" + +group :development, :test do + gem "attr_encrypted" + gem "figaro", git: "https://github.com/laserlemon/figaro" + gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook" + gem "omniauth-github", git: "https://github.com/intridea/omniauth-github" + gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2" + gem "rack-cors", require: "rack/cors" + gem "thor" + gem "faker" + gem "fuzz_ball" + gem "guard" + gem "guard-minitest" + gem "minitest" + gem "minitest-focus" + gem "minitest-rails" + gem "minitest-reporters" + gem "mocha" + gem "pry" + gem "pry-remote" +end + +group :test do + gem "codeclimate-test-reporter", require: nil + gem "rails-controller-testing" +end + +group :development do + gem "github_changelog_generator" +end + +gemspec path: "../" From e534e0de29308cf23b407096aa8ec0c3a3aff706 Mon Sep 17 00:00:00 2001 From: Krzysztof Rybka Date: Thu, 5 Apr 2018 20:17:32 +0200 Subject: [PATCH 46/54] Polyfill Rails 5 versioned migrations --- test/dummy/lib/migration_database_helper.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/dummy/lib/migration_database_helper.rb b/test/dummy/lib/migration_database_helper.rb index bdfc3f517..fba916c25 100644 --- a/test/dummy/lib/migration_database_helper.rb +++ b/test/dummy/lib/migration_database_helper.rb @@ -1,3 +1,15 @@ +# polyfill Rails >= 5 versioned migrations + +unless ActiveRecord::Migration.respond_to?(:[]) + module ActiveRecord + class Migration + def self.[](_version) + self + end + end + end +end + module MigrationDatabaseHelper def json_supported_database? (postgres? && postgres_correct_version?) || (mysql? && mysql_correct_version?) From 24b92086321a5a96461de9f987704f24d4905ed6 Mon Sep 17 00:00:00 2001 From: Krzysztof Rybka Date: Wed, 11 Apr 2018 20:00:28 +0200 Subject: [PATCH 47/54] Fallback http helpers for Rails 4 in tests --- test/test_helper.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/test_helper.rb b/test/test_helper.rb index d54e966d8..c323fd867 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -75,3 +75,28 @@ class ActionController::TestCase @request.env['devise.mapping'] = Devise.mappings[:user] end end + +# TODO: remove it when support for Rails < 5 has been dropped +module Rails + module Controller + module Testing + module Integration + %w[get post patch put head delete get_via_redirect post_via_redirect].each do |method| + define_method(method) do |path_or_action, **args| + if Rails::VERSION::MAJOR >= 5 + super path_or_action, args + else + super path_or_action, args[:params], args[:headers] + end + end + end + end + end + end +end + +module ActionController + class TestCase + include Rails::Controller::Testing::Integration + end +end From b982db4c303149c7e72af370ca21b87c68c7a796 Mon Sep 17 00:00:00 2001 From: Krzysztof Rybka Date: Wed, 11 Apr 2018 20:00:40 +0200 Subject: [PATCH 48/54] Fix tests on Rails 4 --- .../devise_token_auth/omniauth_callbacks_controller_test.rb | 2 +- .../devise_token_auth/registrations_controller_test.rb | 2 +- test/models/user_test.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb b/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb index 908e2ed2c..dbd106299 100644 --- a/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +++ b/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb @@ -57,7 +57,7 @@ def get_parsed_data_json expiry = controller.auth_params[:expiry] # the expiry should have been set - assert_equal expiry, @resource.tokens[client_id]['expiry'] + assert_equal expiry, @resource.tokens[client_id]['expiry'] || @resource.tokens[client_id][:expiry] # the token sent down to the client should now be valid assert @resource.valid_token?(token, client_id) diff --git a/test/controllers/devise_token_auth/registrations_controller_test.rb b/test/controllers/devise_token_auth/registrations_controller_test.rb index b89cd7e38..ee987ba10 100644 --- a/test/controllers/devise_token_auth/registrations_controller_test.rb +++ b/test/controllers/devise_token_auth/registrations_controller_test.rb @@ -177,7 +177,7 @@ class DeviseTokenAuth::RegistrationsControllerTest < ActionDispatch::Integration @resource = assigns(:resource) @data = JSON.parse(response.body) @mail = ActionMailer::Base.deliveries.last - @sent_redirect_url = URI.decode(@mail.body.match(/redirect_url=([^&]*)(&|\")/)[1]) + @sent_redirect_url = CGI.unescape(@mail.body.match(/redirect_url=([^&]*)(&|\")/)[1]) end teardown do diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 1689383b2..635eca626 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -122,12 +122,12 @@ def @resource.token_lifespan assert @resource.token_is_current?(@token_global, @client_id_global) time = Time.zone.now.to_i - expiry_global = @resource.tokens[@client_id_global]['expiry'] + expiry_global = @resource.tokens[@client_id_global]['expiry'] || @resource.tokens[@client_id_global][:expiry] assert expiry_global > time + DeviseTokenAuth.token_lifespan - 5.seconds assert expiry_global < time + DeviseTokenAuth.token_lifespan + 5.seconds - expiry_specific = @resource.tokens[@client_id_specific]['expiry'] + expiry_specific = @resource.tokens[@client_id_specific]['expiry'] || @resource.tokens[@client_id_specific][:expiry] assert expiry_specific > time + 55.seconds assert expiry_specific < time + 65.seconds end From 6f41e18d0a864efb58982b514cdd9a858c84b913 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 27 Apr 2018 22:42:26 +0300 Subject: [PATCH 49/54] rebase --- .../application_controller.rb | 4 ++ .../devise_token_auth/passwords_controller.rb | 16 ++---- .../registrations_controller.rb | 51 ++++++++++------- lib/devise_token_auth.rb | 11 ++-- lib/devise_token_auth/errors.rb | 5 ++ .../custom_registrations_controller_test.rb | 9 +++ .../omniauth_callbacks_controller_test.rb | 2 - .../registrations_controller_test.rb | 56 ++++++++++--------- test/test_helper.rb | 13 +---- 9 files changed, 89 insertions(+), 78 deletions(-) create mode 100644 lib/devise_token_auth/errors.rb diff --git a/app/controllers/devise_token_auth/application_controller.rb b/app/controllers/devise_token_auth/application_controller.rb index 31e91aded..72965dd46 100644 --- a/app/controllers/devise_token_auth/application_controller.rb +++ b/app/controllers/devise_token_auth/application_controller.rb @@ -15,6 +15,10 @@ def resource_errors protected + def blacklisted_redirect_url? + DeviseTokenAuth.redirect_whitelist && !DeviseTokenAuth::Url.whitelisted?(@redirect_url) + end + def build_redirect_headers(access_token, client, redirect_header_options = {}) { DeviseTokenAuth.headers_names[:"access-token"] => access_token, diff --git a/app/controllers/devise_token_auth/passwords_controller.rb b/app/controllers/devise_token_auth/passwords_controller.rb index b597c307f..adae405b0 100644 --- a/app/controllers/devise_token_auth/passwords_controller.rb +++ b/app/controllers/devise_token_auth/passwords_controller.rb @@ -9,19 +9,13 @@ def create return render_create_error_missing_email unless resource_params[:email] # give redirect value from params priority - @redirect_url = params[:redirect_url] - - # fall back to default value if provided - @redirect_url ||= DeviseTokenAuth.default_password_reset_url + @redirect_url = params.fetch( + :redirect_url, + DeviseTokenAuth.default_password_reset_url + ) return render_create_error_missing_redirect_url unless @redirect_url - - # if whitelist is set, validate redirect_url against whitelist - if DeviseTokenAuth.redirect_whitelist - unless DeviseTokenAuth::Url.whitelisted?(@redirect_url) - return render_create_error_not_allowed_redirect_url - end - end + return render_create_error_not_allowed_redirect_url if blacklisted_redirect_url? @email = get_case_insensitive_field_from_resource_params(:email) @resource = find_resource(:uid, @email) diff --git a/app/controllers/devise_token_auth/registrations_controller.rb b/app/controllers/devise_token_auth/registrations_controller.rb index 9f68fcfbe..54e060706 100644 --- a/app/controllers/devise_token_auth/registrations_controller.rb +++ b/app/controllers/devise_token_auth/registrations_controller.rb @@ -6,21 +6,18 @@ class RegistrationsController < DeviseTokenAuth::ApplicationController skip_after_action :update_auth_header, only: [:create, :destroy] def create - @resource = resource_class.new(sign_up_params.except(:confirm_success_url)) - @resource.provider = provider + build_resource - # honor devise configuration for case_insensitive_keys - if resource_class.case_insensitive_keys.include?(:email) - @resource.email = sign_up_params[:email].try :downcase - else - @resource.email = sign_up_params[:email] + unless @resource.present? + raise DeviseTokenAuth::Errors::NoResourceDefinedError, + "#{self.class.name} #build_resource does not define @resource, execution stopped" end # give redirect value from params priority - @redirect_url = sign_up_params[:confirm_success_url] - - # fall back to default value if provided - @redirect_url ||= DeviseTokenAuth.default_confirm_success_url + @redirect_url = params.fetch( + :confirm_success_url, + DeviseTokenAuth.default_confirm_success_url + ) # success redirect url is required if confirmable_enabled? && !@redirect_url @@ -28,11 +25,7 @@ def create end # if whitelist is set, validate redirect_url against whitelist - if DeviseTokenAuth.redirect_whitelist - unless DeviseTokenAuth::Url.whitelisted?(@redirect_url) - return render_create_error_redirect_url_not_allowed - end - end + return render_create_error_redirect_url_not_allowed if blacklisted_redirect_url? begin # override email confirmation, must be sent manually from ctrl @@ -42,15 +35,20 @@ def create # Fix duplicate e-mails by disabling Devise confirmation e-mail @resource.skip_confirmation_notification! end + if @resource.save yield @resource if block_given? - if @resource.confirmed? + unless @resource.confirmed? + # user will require email authentication + @resource.send_confirmation_instructions({ + client_config: params[:config_name], + redirect_url: @redirect_url + }) + else # email auth has been bypassed, authenticate user @client_id, @token = @resource.create_token - @resource.save! - update_auth_header else # user will require email authentication @@ -87,7 +85,6 @@ def destroy if @resource @resource.destroy yield @resource if block_given? - render_destroy_success else render_destroy_error @@ -95,7 +92,7 @@ def destroy end def sign_up_params - params.permit([*params_for_resource(:sign_up), :confirm_success_url]) + params.permit(*params_for_resource(:sign_up)) end def account_update_params @@ -104,6 +101,18 @@ def account_update_params protected + def build_resource + @resource = resource_class.new(sign_up_params) + @resource.provider = provider + + # honor devise configuration for case_insensitive_keys + if resource_class.case_insensitive_keys.include?(:email) + @resource.email = sign_up_params[:email].try(:downcase) + else + @resource.email = sign_up_params[:email] + end + end + def render_create_error_missing_confirm_success_url response = { status: 'error', diff --git a/lib/devise_token_auth.rb b/lib/devise_token_auth.rb index b22490928..e80ecf04e 100644 --- a/lib/devise_token_auth.rb +++ b/lib/devise_token_auth.rb @@ -1,8 +1,9 @@ -require 'devise' -require 'devise_token_auth/engine' -require 'devise_token_auth/controllers/helpers' -require 'devise_token_auth/controllers/url_helpers' -require 'devise_token_auth/url' +require "devise" +require "devise_token_auth/engine" +require "devise_token_auth/controllers/helpers" +require "devise_token_auth/controllers/url_helpers" +require "devise_token_auth/url" +require "devise_token_auth/errors" module DeviseTokenAuth end diff --git a/lib/devise_token_auth/errors.rb b/lib/devise_token_auth/errors.rb new file mode 100644 index 000000000..33762593b --- /dev/null +++ b/lib/devise_token_auth/errors.rb @@ -0,0 +1,5 @@ +module DeviseTokenAuth + module Errors + class NoResourceDefinedError < StandardError ; end + end +end diff --git a/test/controllers/custom/custom_registrations_controller_test.rb b/test/controllers/custom/custom_registrations_controller_test.rb index cd25a49b3..16c68b989 100644 --- a/test/controllers/custom/custom_registrations_controller_test.rb +++ b/test/controllers/custom/custom_registrations_controller_test.rb @@ -50,5 +50,14 @@ class Custom::RegistrationsControllerTest < ActionDispatch::IntegrationTest assert @controller.destroy_block_called?, 'destroy failed to yield resource to provided block' end + + describe 'when overriding #build_resource' do + test 'it fails' do + Custom::RegistrationsController.any_instance.stubs(:build_resource).returns(nil) + assert_raises DeviseTokenAuth::Errors::NoResourceDefinedError do + post '/nice_user_auth', params: @create_params + end + end + end end end diff --git a/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb b/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb index dbd106299..40ba9881c 100644 --- a/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb +++ b/test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb @@ -1,6 +1,4 @@ require 'test_helper' -require 'mocha/minitest' - # was the web request successful? # was the user redirected to the right page? # was the user successfully authenticated? diff --git a/test/controllers/overrides/registrations_controller_test.rb b/test/controllers/overrides/registrations_controller_test.rb index 66c41fbf4..d8e55a8c9 100644 --- a/test/controllers/overrides/registrations_controller_test.rb +++ b/test/controllers/overrides/registrations_controller_test.rb @@ -8,33 +8,35 @@ class Overrides::RegistrationsControllerTest < ActionDispatch::IntegrationTest describe Overrides::RegistrationsController do - setup do - @existing_user = evil_users(:confirmed_email_user) - @auth_headers = @existing_user.create_new_auth_token - @client_id = @auth_headers['client'] - @favorite_color = 'pink' - - # ensure request is not treated as batch request - age_token(@existing_user, @client_id) - - # test valid update param - @new_operating_thetan = 1_000_000 - - put '/evil_user_auth', - params: { favorite_color: @favorite_color }, - headers: @auth_headers - - @data = JSON.parse(response.body) - @existing_user.reload - end - - test 'user was updated' do - assert_equal @favorite_color, @existing_user.favorite_color - end - - test 'controller was overridden' do - assert_equal Overrides::RegistrationsController::OVERRIDE_PROOF, - @data['override_proof'] + describe 'Succesful Registration update' do + setup do + @existing_user = evil_users(:confirmed_email_user) + @auth_headers = @existing_user.create_new_auth_token + @client_id = @auth_headers['client'] + @favorite_color = 'pink' + + # ensure request is not treated as batch request + age_token(@existing_user, @client_id) + + # test valid update param + @new_operating_thetan = 1_000_000 + + put '/evil_user_auth', + params: { favorite_color: @favorite_color }, + headers: @auth_headers + + @data = JSON.parse(response.body) + @existing_user.reload + end + + test 'user was updated' do + assert_equal @favorite_color, @existing_user.favorite_color + end + + test 'controller was overridden' do + assert_equal Overrides::RegistrationsController::OVERRIDE_PROOF, + @data['override_proof'] + end end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index c323fd867..d4a1c73f6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,5 @@ require 'simplecov' -# SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[ -# SimpleCov::Formatter::HTMLFormatter, -# CodeClimate::TestReporter::Formatter -# ] - SimpleCov.start 'rails' ENV['RAILS_ENV'] = 'test' @@ -12,13 +7,7 @@ require File.expand_path('dummy/config/environment', __dir__) require 'rails/test_help' require 'minitest/rails' - -# To add Capybara feature tests add `gem "minitest-rails-capybara"` -# to the test group in the Gemfile and uncomment the following: -# require "minitest/rails/capybara" - -# Uncomment for awesome colorful output -# require "minitest/pride" +require 'mocha/minitest' ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__) ActionDispatch::IntegrationTest.fixture_path = File.expand_path('fixtures', __dir__) From a2a67f0f25e89ebd780a1dc1e77a776efd120435 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 27 Apr 2018 22:48:28 +0300 Subject: [PATCH 50/54] update rubocop --- Gemfile.lock | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 973312084..175c8a887 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -195,7 +195,7 @@ GEM omniauth (~> 1.2) orm_adapter (0.5.0) parallel (1.12.1) - parser (2.5.0.5) + parser (2.5.1.0) ast (~> 2.4.0) pg (0.20.0) powerpack (0.1.1) @@ -238,9 +238,8 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.2.2) - rake - rake (12.3.0) + rainbow (3.0.0) + rake (12.3.1) rb-fsevent (0.9.8) rb-inotify (0.9.8) ffi (>= 0.5.0) @@ -248,7 +247,7 @@ GEM actionpack (>= 4.2.0, < 5.3) railties (>= 4.2.0, < 5.3) retriable (2.1.0) - rubocop (0.54.0) + rubocop (0.55.0) parallel (~> 1.10) parser (>= 2.5) powerpack (~> 0.1) @@ -279,7 +278,7 @@ GEM thread_safe (0.3.6) tzinfo (1.2.4) thread_safe (~> 0.1) - unicode-display_width (1.3.0) + unicode-display_width (1.3.2) warden (1.2.7) rack (>= 1.0) websocket-driver (0.6.5) From 5c96cb86eeb63ec6cddf1c0a9bd864b5b67af557 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 27 Apr 2018 22:50:18 +0300 Subject: [PATCH 51/54] update todo list rubocop --auto-gen-config --exclude-limit 100 --- .rubocop_todo.yml | 143 ++++++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 69 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f7b580b0a..0b2de271b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,21 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 100` -# on 2018-04-09 16:05:53 -0700 using RuboCop version 0.54.0. +# on 2018-04-27 22:49:03 +0300 using RuboCop version 0.55.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 +# Cop supports --auto-correct. +# Configuration parameters: Include, TreatCommentsAsGroupSeparators. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'gemfiles/rails_4_2.gemfile' + - 'gemfiles/rails_5_0.gemfile' + - 'gemfiles/rails_5_1.gemfile' + # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: Include, TreatCommentsAsGroupSeparators. @@ -14,6 +24,12 @@ Gemspec/OrderedDependencies: Exclude: - 'devise_token_auth.gemspec' +# Offense count: 1 +# Cop supports --auto-correct. +Layout/ClosingParenthesisIndentation: + Exclude: + - 'app/controllers/devise_token_auth/passwords_controller.rb' + # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. @@ -66,6 +82,14 @@ Layout/ExtraSpacing: - 'test/dummy/config/initializers/omniauth.rb' - 'test/dummy/db/migrate/20141222035835_devise_token_auth_create_only_email_users.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstParameterIndentation: + Exclude: + - 'app/controllers/devise_token_auth/passwords_controller.rb' + # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. @@ -89,14 +113,6 @@ Layout/MultilineBlockLayout: Exclude: - 'lib/generators/devise_token_auth/install_generator.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'test/controllers/devise_token_auth/sessions_controller_test.rb' - # Offense count: 1 # Cop supports --auto-correct. Layout/SpaceAfterColon: @@ -131,6 +147,12 @@ Layout/SpaceBeforeBlockBraces: - 'lib/devise_token_auth/rails/routes.rb' - 'test/dummy/app/models/user.rb' +# Offense count: 1 +# Cop supports --auto-correct. +Layout/SpaceBeforeSemicolon: + Exclude: + - 'lib/devise_token_auth/errors.rb' + # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. @@ -195,62 +217,46 @@ Lint/UnusedBlockArgument: - 'test/dummy/app/controllers/custom/registrations_controller.rb' - 'test/dummy/config/initializers/omniauth.rb' -# Offense count: 4 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. Lint/UnusedMethodArgument: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'lib/devise_token_auth/engine.rb' - 'lib/generators/devise_token_auth/install_generator.rb' -# Offense count: 3 +# Offense count: 2 Lint/UriEscapeUnescape: Exclude: - 'test/controllers/devise_token_auth/omniauth_callbacks_controller_test.rb' - - 'test/controllers/devise_token_auth/registrations_controller_test.rb' - 'test/controllers/overrides/confirmations_controller_test.rb' -# Offense count: 35 +# Offense count: 31 Metrics/AbcSize: Max: 76 # Offense count: 1 # Configuration parameters: CountComments, ExcludedMethods. Metrics/BlockLength: - Exclude: - - 'app/models/devise_token_auth/concerns/user.rb' + Max: 42 -# Offense count: 15 +# Offense count: 14 # Configuration parameters: CountComments. Metrics/ClassLength: Max: 698 -# Offense count: 14 +# Offense count: 12 Metrics/CyclomaticComplexity: Max: 17 -# Offense count: 92 +# Offense count: 74 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: - Exclude: - - 'app/controllers/devise_token_auth/application_controller.rb' - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/registrations_controller.rb' - - 'app/controllers/devise_token_auth/sessions_controller.rb' - - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'app/models/devise_token_auth/concerns/user_omniauth_callbacks.rb' - - 'app/validators/email_validator.rb' - - 'lib/devise_token_auth/engine.rb' - - 'lib/devise_token_auth/rails/routes.rb' - - 'lib/generators/devise_token_auth/install_generator.rb' + Max: 189 -# Offense count: 35 +# Offense count: 32 # Configuration parameters: CountComments. Metrics/MethodLength: Max: 63 @@ -260,7 +266,7 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 1037 -# Offense count: 13 +# Offense count: 11 Metrics/PerceivedComplexity: Max: 19 @@ -287,7 +293,7 @@ Naming/PredicateName: # Offense count: 2 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: io, id, to +# AllowedNames: io, id, to, by, on, in, at Naming/UncommunicativeMethodParamName: Exclude: - 'app/controllers/devise_token_auth/application_controller.rb' @@ -300,12 +306,6 @@ Performance/RedundantMerge: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Performance/RegexpMatch: - Exclude: - - 'app/validators/email_validator.rb' - # Offense count: 4 # Cop supports --auto-correct. Performance/StringReplacement: @@ -322,11 +322,10 @@ Style/BarePercentLiterals: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. Style/ColonMethodCall: Exclude: - - 'lib/devise_token_auth/engine.rb' - 'lib/devise_token_auth/rails/routes.rb' # Offense count: 3 @@ -335,7 +334,7 @@ Style/CommentedKeyword: - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - 'test/controllers/demo_user_controller_test.rb' -# Offense count: 3 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition @@ -343,14 +342,13 @@ Style/ConditionalAssignment: Exclude: - 'app/controllers/devise_token_auth/application_controller.rb' - 'app/controllers/devise_token_auth/concerns/resource_finder.rb' - - 'app/controllers/devise_token_auth/registrations_controller.rb' # Offense count: 2 Style/DateTime: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 24 +# Offense count: 21 Style/Documentation: Exclude: - 'spec/**/*' @@ -361,7 +359,6 @@ Style/Documentation: - 'app/controllers/devise_token_auth/confirmations_controller.rb' - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/registrations_controller.rb' - 'app/controllers/devise_token_auth/sessions_controller.rb' - 'app/controllers/devise_token_auth/token_validations_controller.rb' - 'app/controllers/devise_token_auth/unlocks_controller.rb' @@ -371,7 +368,6 @@ Style/Documentation: - 'lib/devise_token_auth.rb' - 'lib/devise_token_auth/controllers/helpers.rb' - 'lib/devise_token_auth/controllers/url_helpers.rb' - - 'lib/devise_token_auth/engine.rb' - 'lib/devise_token_auth/rails/routes.rb' - 'lib/devise_token_auth/url.rb' - 'lib/generators/devise_token_auth/install_generator.rb' @@ -412,18 +408,18 @@ Style/GuardClause: # Offense count: 1 # Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. Style/MethodCallWithoutArgsParentheses: Exclude: - 'test/models/user_test.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline Style/MethodDefParentheses: Exclude: - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/registrations_controller.rb' # Offense count: 9 Style/MixinUsage: @@ -469,14 +465,13 @@ Style/Not: Style/NumericLiterals: MinDigits: 15 -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: - 'spec/**/*' - - 'app/controllers/devise_token_auth/confirmations_controller.rb' - 'test/dummy/app/models/user.rb' # Offense count: 3 @@ -493,22 +488,6 @@ Style/RescueModifier: Exclude: - 'app/models/devise_token_auth/concerns/user.rb' -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist. -# Whitelist: present?, blank?, presence, try -Style/SafeNavigation: - Exclude: - - 'app/controllers/devise_token_auth/concerns/set_user_by_token.rb' - - 'app/controllers/devise_token_auth/confirmations_controller.rb' - - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' - - 'app/controllers/devise_token_auth/passwords_controller.rb' - - 'app/controllers/devise_token_auth/unlocks_controller.rb' - - 'app/models/devise_token_auth/concerns/user.rb' - - 'lib/devise_token_auth/engine.rb' - - 'test/dummy/app/controllers/overrides/confirmations_controller.rb' - - 'test/dummy/app/controllers/overrides/passwords_controller.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: AllowIfMethodIsEmpty. @@ -524,6 +503,18 @@ Style/SpecialGlobalVars: Exclude: - 'devise_token_auth.gemspec' +# Offense count: 106 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'Appraisals' + - 'gemfiles/rails_4_2.gemfile' + - 'gemfiles/rails_5_0.gemfile' + - 'gemfiles/rails_5_1.gemfile' + - 'lib/devise_token_auth.rb' + # Offense count: 7 # Cop supports --auto-correct. Style/SymbolLiteral: @@ -550,6 +541,14 @@ Style/TernaryParentheses: - 'test/lib/generators/devise_token_auth/install_generator_test.rb' - 'test/lib/generators/devise_token_auth/install_generator_with_namespace_test.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'Appraisals' + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: AllowNamedUnderscoreVariables. @@ -562,3 +561,9 @@ Style/TrailingUnderscoreVariable: Style/UnneededPercentQ: Exclude: - 'app/controllers/devise_token_auth/omniauth_callbacks_controller.rb' + +# Offense count: 74 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 189 From 61c582b0454e497c313766b2aa091fbcd9dac35b Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 27 Apr 2018 22:57:04 +0300 Subject: [PATCH 52/54] Fix Style/StringLiterals --- .rubocop_todo.yml | 14 +--------- Appraisals | 8 +++--- gemfiles/rails_4_2.gemfile | 52 +++++++++++++++++++------------------- gemfiles/rails_5_0.gemfile | 48 +++++++++++++++++------------------ gemfiles/rails_5_1.gemfile | 48 +++++++++++++++++------------------ lib/devise_token_auth.rb | 12 ++++----- 6 files changed, 85 insertions(+), 97 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0b2de271b..fddcaa8f6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 100` -# on 2018-04-27 22:49:03 +0300 using RuboCop version 0.55.0. +# on 2018-04-27 22:54:41 +0300 using RuboCop version 0.55.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 @@ -503,18 +503,6 @@ Style/SpecialGlobalVars: Exclude: - 'devise_token_auth.gemspec' -# Offense count: 106 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiterals: - Exclude: - - 'Appraisals' - - 'gemfiles/rails_4_2.gemfile' - - 'gemfiles/rails_5_0.gemfile' - - 'gemfiles/rails_5_1.gemfile' - - 'lib/devise_token_auth.rb' - # Offense count: 7 # Cop supports --auto-correct. Style/SymbolLiteral: diff --git a/Appraisals b/Appraisals index 4558c869b..e293ca2e4 100644 --- a/Appraisals +++ b/Appraisals @@ -2,9 +2,9 @@ { name: '4-2', version: '4.2.10' } ].each do |rails| appraise "rails-#{rails[:name]}" do - gem "mysql2", "~> 0.4.10" - gem "pg", "~> 0.21" - gem "rails", "~> #{rails[:version]}" + gem 'mysql2', '~> 0.4.10' + gem 'pg', '~> 0.21' + gem 'rails', "~> #{rails[:version]}" end end @@ -13,6 +13,6 @@ end { name: '5-1', version: '5.1.6' }, ].each do |rails| appraise "rails-#{rails[:name]}" do - gem "rails", "~> #{rails[:version]}" + gem 'rails', "~> #{rails[:version]}" end end diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile index 1bc7c37ed..c09e9c9cf 100644 --- a/gemfiles/rails_4_2.gemfile +++ b/gemfiles/rails_4_2.gemfile @@ -1,39 +1,39 @@ # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "mysql2", "~> 0.4.10" -gem "pg", "~> 0.21" -gem "rails", "~> 4.2.10" +gem 'mysql2', '~> 0.4.10' +gem 'pg', '~> 0.21' +gem 'rails', '~> 4.2.10' group :development, :test do - gem "attr_encrypted" - gem "figaro", git: "https://github.com/laserlemon/figaro" - gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook" - gem "omniauth-github", git: "https://github.com/intridea/omniauth-github" - gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2" - gem "rack-cors", require: "rack/cors" - gem "thor" - gem "faker" - gem "fuzz_ball" - gem "guard" - gem "guard-minitest" - gem "minitest" - gem "minitest-focus" - gem "minitest-rails" - gem "minitest-reporters" - gem "mocha" - gem "pry" - gem "pry-remote" + gem 'attr_encrypted' + gem 'figaro', git: 'https://github.com/laserlemon/figaro' + gem 'omniauth-facebook', git: 'https://github.com/mkdynamic/omniauth-facebook' + gem 'omniauth-github', git: 'https://github.com/intridea/omniauth-github' + gem 'omniauth-google-oauth2', git: 'https://github.com/zquestz/omniauth-google-oauth2' + gem 'rack-cors', require: 'rack/cors' + gem 'thor' + gem 'faker' + gem 'fuzz_ball' + gem 'guard' + gem 'guard-minitest' + gem 'minitest' + gem 'minitest-focus' + gem 'minitest-rails' + gem 'minitest-reporters' + gem 'mocha' + gem 'pry' + gem 'pry-remote' end group :test do - gem "codeclimate-test-reporter", require: nil - gem "rails-controller-testing" + gem 'codeclimate-test-reporter', require: nil + gem 'rails-controller-testing' end group :development do - gem "github_changelog_generator" + gem 'github_changelog_generator' end -gemspec path: "../" +gemspec path: '../' diff --git a/gemfiles/rails_5_0.gemfile b/gemfiles/rails_5_0.gemfile index 8ff29fc8a..5ec13451b 100644 --- a/gemfiles/rails_5_0.gemfile +++ b/gemfiles/rails_5_0.gemfile @@ -1,37 +1,37 @@ # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "rails", "~> 5.0.7" +gem 'rails', '~> 5.0.7' group :development, :test do - gem "attr_encrypted" - gem "figaro", git: "https://github.com/laserlemon/figaro" - gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook" - gem "omniauth-github", git: "https://github.com/intridea/omniauth-github" - gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2" - gem "rack-cors", require: "rack/cors" - gem "thor" - gem "faker" - gem "fuzz_ball" - gem "guard" - gem "guard-minitest" - gem "minitest" - gem "minitest-focus" - gem "minitest-rails" - gem "minitest-reporters" - gem "mocha" - gem "pry" - gem "pry-remote" + gem 'attr_encrypted' + gem 'figaro', git: 'https://github.com/laserlemon/figaro' + gem 'omniauth-facebook', git: 'https://github.com/mkdynamic/omniauth-facebook' + gem 'omniauth-github', git: 'https://github.com/intridea/omniauth-github' + gem 'omniauth-google-oauth2', git: 'https://github.com/zquestz/omniauth-google-oauth2' + gem 'rack-cors', require: 'rack/cors' + gem 'thor' + gem 'faker' + gem 'fuzz_ball' + gem 'guard' + gem 'guard-minitest' + gem 'minitest' + gem 'minitest-focus' + gem 'minitest-rails' + gem 'minitest-reporters' + gem 'mocha' + gem 'pry' + gem 'pry-remote' end group :test do - gem "codeclimate-test-reporter", require: nil - gem "rails-controller-testing" + gem 'codeclimate-test-reporter', require: nil + gem 'rails-controller-testing' end group :development do - gem "github_changelog_generator" + gem 'github_changelog_generator' end -gemspec path: "../" +gemspec path: '../' diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile index 8e4189419..d6056a442 100644 --- a/gemfiles/rails_5_1.gemfile +++ b/gemfiles/rails_5_1.gemfile @@ -1,37 +1,37 @@ # This file was generated by Appraisal -source "https://rubygems.org" +source 'https://rubygems.org' -gem "rails", "~> 5.1.6" +gem 'rails', '~> 5.1.6' group :development, :test do - gem "attr_encrypted" - gem "figaro", git: "https://github.com/laserlemon/figaro" - gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook" - gem "omniauth-github", git: "https://github.com/intridea/omniauth-github" - gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2" - gem "rack-cors", require: "rack/cors" - gem "thor" - gem "faker" - gem "fuzz_ball" - gem "guard" - gem "guard-minitest" - gem "minitest" - gem "minitest-focus" - gem "minitest-rails" - gem "minitest-reporters" - gem "mocha" - gem "pry" - gem "pry-remote" + gem 'attr_encrypted' + gem 'figaro', git: 'https://github.com/laserlemon/figaro' + gem 'omniauth-facebook', git: 'https://github.com/mkdynamic/omniauth-facebook' + gem 'omniauth-github', git: 'https://github.com/intridea/omniauth-github' + gem 'omniauth-google-oauth2', git: 'https://github.com/zquestz/omniauth-google-oauth2' + gem 'rack-cors', require: 'rack/cors' + gem 'thor' + gem 'faker' + gem 'fuzz_ball' + gem 'guard' + gem 'guard-minitest' + gem 'minitest' + gem 'minitest-focus' + gem 'minitest-rails' + gem 'minitest-reporters' + gem 'mocha' + gem 'pry' + gem 'pry-remote' end group :test do - gem "codeclimate-test-reporter", require: nil - gem "rails-controller-testing" + gem 'codeclimate-test-reporter', require: nil + gem 'rails-controller-testing' end group :development do - gem "github_changelog_generator" + gem 'github_changelog_generator' end -gemspec path: "../" +gemspec path: '../' diff --git a/lib/devise_token_auth.rb b/lib/devise_token_auth.rb index e80ecf04e..38c1390e3 100644 --- a/lib/devise_token_auth.rb +++ b/lib/devise_token_auth.rb @@ -1,9 +1,9 @@ -require "devise" -require "devise_token_auth/engine" -require "devise_token_auth/controllers/helpers" -require "devise_token_auth/controllers/url_helpers" -require "devise_token_auth/url" -require "devise_token_auth/errors" +require 'devise' +require 'devise_token_auth/engine' +require 'devise_token_auth/controllers/helpers' +require 'devise_token_auth/controllers/url_helpers' +require 'devise_token_auth/url' +require 'devise_token_auth/errors' module DeviseTokenAuth end From 8f46f259828572697a624d4f54cb912f68fbaf9b Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 28 Apr 2018 00:13:21 +0300 Subject: [PATCH 53/54] Fix wrong resolves of conflict --- .../devise_token_auth/registrations_controller.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/controllers/devise_token_auth/registrations_controller.rb b/app/controllers/devise_token_auth/registrations_controller.rb index 54e060706..da59a2701 100644 --- a/app/controllers/devise_token_auth/registrations_controller.rb +++ b/app/controllers/devise_token_auth/registrations_controller.rb @@ -50,12 +50,6 @@ def create @client_id, @token = @resource.create_token @resource.save! update_auth_header - else - # user will require email authentication - @resource.send_confirmation_instructions( - client_config: params[:config_name], - redirect_url: @redirect_url - ) end render_create_success else From 4be88a145d07819141eaf46e3c43c2afb855e637 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Sat, 28 Apr 2018 00:25:13 +0300 Subject: [PATCH 54/54] Add rubocop gem into rails_version_gemfiles --- gemfiles/rails_4_2.gemfile | 2 ++ gemfiles/rails_5_0.gemfile | 2 ++ gemfiles/rails_5_1.gemfile | 2 ++ 3 files changed, 6 insertions(+) diff --git a/gemfiles/rails_4_2.gemfile b/gemfiles/rails_4_2.gemfile index c09e9c9cf..3cfa680b5 100644 --- a/gemfiles/rails_4_2.gemfile +++ b/gemfiles/rails_4_2.gemfile @@ -25,6 +25,8 @@ group :development, :test do gem 'mocha' gem 'pry' gem 'pry-remote' + + gem 'rubocop', require: false end group :test do diff --git a/gemfiles/rails_5_0.gemfile b/gemfiles/rails_5_0.gemfile index 5ec13451b..0151565f7 100644 --- a/gemfiles/rails_5_0.gemfile +++ b/gemfiles/rails_5_0.gemfile @@ -23,6 +23,8 @@ group :development, :test do gem 'mocha' gem 'pry' gem 'pry-remote' + + gem 'rubocop', require: false end group :test do diff --git a/gemfiles/rails_5_1.gemfile b/gemfiles/rails_5_1.gemfile index d6056a442..6cad02f05 100644 --- a/gemfiles/rails_5_1.gemfile +++ b/gemfiles/rails_5_1.gemfile @@ -23,6 +23,8 @@ group :development, :test do gem 'mocha' gem 'pry' gem 'pry-remote' + + gem 'rubocop', require: false end group :test do