diff --git a/.rubocop.yml b/.rubocop.yml index 0e5d326b..6c4f976b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,1176 +2,131 @@ AllCops: Exclude: - 'db/schema.rb' - 'vendor/**/*' - DisabledByDefault: true + DisabledByDefault: false TargetRubyVersion: 2.5 -Layout/AccessModifierIndentation: - EnforcedStyle: indent - SupportedStyles: - - outdent - - indent - IndentationWidth: +# Gems within groups in the Gemfile should be alphabetically sorted. +Bundler/OrderedGems: + Enabled: false -Style/Alias: - EnforcedStyle: prefer_alias_method - SupportedStyles: - - prefer_alias - - prefer_alias_method +# Checks if uses of quotes match the configured preference. +Style/StringLiterals: + Enabled: false -Layout/AlignHash: - EnforcedHashRocketStyle: key - EnforcedColonStyle: key - EnforcedLastArgumentHashStyle: ignore_implicit - SupportedLastArgumentHashStyles: - - always_inspect - - always_ignore - - ignore_implicit - - ignore_explicit +# Document classes and non-namespace modules. +Style/Documentation: + Enabled: false -Layout/AlignParameters: - EnforcedStyle: with_fixed_indentation - SupportedStyles: - - with_first_parameter - - with_fixed_indentation - IndentationWidth: +# Check for conditionals that can be replaced with guard clauses +Style/GuardClause: + Enabled: false -Style/AndOr: - EnforcedStyle: always - SupportedStyles: - - always - - conditionals +# Checks the formatting of empty method definitions. +Style/EmptyMethod: + Enabled: false -Style/BarePercentLiterals: - EnforcedStyle: bare_percent - SupportedStyles: - - percent_q - - bare_percent +# Checks for trailing comma in hash literals. +Style/TrailingCommaInHashLiteral: + Enabled: false -Style/BlockDelimiters: - EnforcedStyle: line_count_based - 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 +# Checks for trailing comma in argument lists. +Style/TrailingCommaInArguments: + Enabled: false -Style/BracesAroundHashParameters: - EnforcedStyle: no_braces - SupportedStyles: - - braces - - no_braces - - context_dependent +# Checks that `include`, `extend` and `prepend` exists at the top level. +Style/MixinUsage: + Enabled: false -Layout/CaseIndentation: - EnforcedStyle: end - SupportedStyles: - - case - - end - IndentOneStep: false - IndentationWidth: - -Style/ClassAndModuleChildren: - EnforcedStyle: nested - SupportedStyles: - - nested - - compact - -Style/ClassCheck: - EnforcedStyle: is_a? - SupportedStyles: - - is_a? - - kind_of? - -Style/CommandLiteral: - EnforcedStyle: backticks - SupportedStyles: - - backticks - - percent_x - - mixed - AllowInnerBackticks: false - -Style/CommentAnnotation: - Keywords: - - TODO - - FIXME - - OPTIMIZE - - HACK - - REVIEW - -Style/ConditionalAssignment: - EnforcedStyle: assign_to_condition - SupportedStyles: - - assign_to_condition - - assign_inside_condition - SingleLineConditionsOnly: true - -Layout/DotPosition: - EnforcedStyle: leading - SupportedStyles: - - leading - - trailing - -Style/EmptyElse: - EnforcedStyle: both - SupportedStyles: - - empty - - nil - - both - -Layout/EmptyLineBetweenDefs: - AllowAdjacentOneLineDefs: false - -Layout/EmptyLinesAroundBlockBody: - EnforcedStyle: no_empty_lines - SupportedStyles: - - empty_lines - - no_empty_lines - -Layout/EmptyLinesAroundClassBody: - EnforcedStyle: no_empty_lines - SupportedStyles: - - empty_lines - - empty_lines_except_namespace - - no_empty_lines - -Layout/EmptyLinesAroundModuleBody: - EnforcedStyle: no_empty_lines - SupportedStyles: - - empty_lines - - empty_lines_except_namespace - - no_empty_lines - -Layout/ExtraSpacing: - AllowForAlignment: true - ForceEqualSignAlignment: false - -Naming/FileName: - Exclude: [] - ExpectMatchingDefinition: false - Regex: - IgnoreExecutableScripts: true - -Layout/FirstParameterIndentation: - EnforcedStyle: consistent - SupportedStyles: - - consistent - - special_for_inner_method_call - - special_for_inner_method_call_in_parentheses - IndentationWidth: - -Style/For: - EnforcedStyle: each - SupportedStyles: - - for - - each - -Style/FormatString: - EnforcedStyle: format - SupportedStyles: - - format - - sprintf - - percent - -Style/FrozenStringLiteralComment: - Details: >- - Add `# frozen_string_literal: true` to the top of the file. Frozen string - literals will become the default in a future Ruby version, and we want to - make sure we're ready. - EnforcedStyle: when_needed - SupportedStyles: - - when_needed - - always - - never - -Style/GlobalVars: - AllowedVariables: [] - -Style/HashSyntax: - EnforcedStyle: ruby19 - SupportedStyles: - - ruby19 - - hash_rockets - - no_mixed_keys - - ruby19_no_mixed_keys - UseHashRocketsWithSymbolValues: false - PreferHashRocketsForNonAlnumEndingSymbols: false - -Layout/IndentationConsistency: - EnforcedStyle: normal - SupportedStyles: - - normal - - rails - -Layout/IndentationWidth: - Width: 2 - -Layout/IndentArray: - EnforcedStyle: consistent - SupportedStyles: - - special_inside_parentheses - - consistent - - align_brackets - IndentationWidth: - -Layout/IndentAssignment: - IndentationWidth: - -Layout/IndentHash: - EnforcedStyle: consistent - SupportedStyles: - - special_inside_parentheses - - consistent - - align_braces - IndentationWidth: - -Style/LambdaCall: - EnforcedStyle: call - SupportedStyles: - - call - - braces - -Style/Next: - EnforcedStyle: skip_modifier_ifs - MinBodyLength: 3 - SupportedStyles: - - skip_modifier_ifs - - always - -Style/NonNilCheck: - IncludeSemanticChanges: false - -Style/MethodDefParentheses: - EnforcedStyle: require_parentheses - SupportedStyles: - - require_parentheses - - require_no_parentheses - - require_no_parentheses_except_multiline - -Naming/MethodName: - EnforcedStyle: snake_case - SupportedStyles: - - snake_case - - camelCase - -Layout/MultilineArrayBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Layout/MultilineHashBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Layout/MultilineMethodCallBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Layout/MultilineMethodCallIndentation: - EnforcedStyle: indented - SupportedStyles: - - aligned - - indented - - indented_relative_to_receiver - IndentationWidth: 2 - -Layout/MultilineMethodDefinitionBraceLayout: - EnforcedStyle: symmetrical - SupportedStyles: - - symmetrical - - new_line - - same_line - -Style/NumericLiteralPrefix: - EnforcedOctalStyle: zero_only - SupportedOctalStyles: - - zero_with_o - - zero_only - -Style/ParenthesesAroundCondition: - AllowSafeAssignment: true +# Use %i or %I for arrays of symbols. +Style/SymbolArray: + Enabled: false +# Use `%`-literal delimiters consistently Style/PercentLiteralDelimiters: - PreferredDelimiters: - '%': '()' - '%i': '()' - '%q': '()' - '%Q': '()' - '%r': '{}' - '%s': '()' - '%w': '()' - '%W': '()' - '%x': '()' + Enabled: false -Style/PercentQLiterals: - EnforcedStyle: lower_case_q - SupportedStyles: - - lower_case_q - - upper_case_q +# Only use if/unless modifiers on single line statements. +Style/MultilineIfModifier: + Enabled: false -Naming/PredicateName: - NamePrefix: - - is_ - NamePrefixBlacklist: - - is_ - NameWhitelist: - - is_a? - Exclude: - - 'spec/**/*' +# Checks for trailing comma in array literals. +Style/TrailingCommaInArrayLiteral: + Enabled: false -Style/PreferredHashMethods: - EnforcedStyle: short - SupportedStyles: - - short - - verbose +# Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`. +Style/ExpandPathArguments: + Enabled: false -Style/RaiseArgs: - EnforcedStyle: exploded - SupportedStyles: - - compact - - exploded +# Do not assign mutable objects to constants. +Style/MutableConstant: + Enabled: false -Style/RedundantReturn: - AllowMultipleReturnValues: false +# Avoid rescuing without specifying an error class. +Style/RescueStandardError: + Enabled: false -Style/RegexpLiteral: - EnforcedStyle: mixed - SupportedStyles: - - slashes - - percent_r - - mixed - AllowInnerSlashes: false +# Align the elements of a hash literal if they span more than one line. +Layout/AlignHash: + Enabled: false -Style/SafeNavigation: - ConvertCodeThatCanStartToReturnNil: false - Enabled: true +# Align the parameters of a method definition if they span more than one line. +Layout/AlignParameters: + Enabled: false -Lint/SafeNavigationChain: - Enabled: true +# Align ends corresponding to defs correctly. +Layout/EndAlignment: + Enabled: false -Style/Semicolon: - AllowAsExpressionSeparator: false +# Align elses and elsifs correctly. +Layout/ElseAlignment: + Enabled: false -Style/SignalException: - EnforcedStyle: only_raise - SupportedStyles: - - only_raise - - only_fail - - semantic +# Add empty line after guard clause. +Layout/EmptyLineAfterGuardClause: + Enabled: false -Style/SingleLineMethods: - AllowIfMethodIsEmpty: true +# Align the arguments of a method call if they span more than one line. +Layout/AlignArguments: + Enabled: false -Layout/SpaceBeforeFirstArg: - AllowForAlignment: true +# +Layout/IndentationWidth: + Enabled: false -Style/SpecialGlobalVars: - EnforcedStyle: use_english_names - SupportedStyles: - - use_perl_names - - use_english_names +# Checks for ambiguous block association with method when param passed without parentheses. +Lint/AmbiguousBlockAssociation: + Enabled: false -Style/StabbyLambdaParentheses: - EnforcedStyle: require_parentheses - SupportedStyles: - - require_parentheses - - require_no_parentheses +# Avoid long blocks with many lines. +Metrics/BlockLength: + Enabled: false -Style/StringLiteralsInInterpolation: - EnforcedStyle: single_quotes - SupportedStyles: - - single_quotes - - double_quotes +# A complexity metric geared towards measuring complexity for a human reader. +Metrics/PerceivedComplexity: + Max: 17 -Style/Strip: - Enabled: true - -Layout/SpaceAroundBlockParameters: - EnforcedStyleInsidePipes: no_space - SupportedStylesInsidePipes: - - space - - no_space - -Layout/SpaceAroundEqualsInParameterDefault: - EnforcedStyle: space - SupportedStyles: - - space - - no_space - -Layout/SpaceAroundOperators: - AllowForAlignment: true - -Layout/SpaceBeforeBlockBraces: - EnforcedStyle: space - EnforcedStyleForEmptyBraces: space - SupportedStyles: - - space - - no_space - -Layout/SpaceInsideBlockBraces: - EnforcedStyle: space - SupportedStyles: - - space - - no_space - EnforcedStyleForEmptyBraces: no_space - SpaceBeforeBlockParameters: true - -Layout/SpaceInsideHashLiteralBraces: - EnforcedStyle: space - EnforcedStyleForEmptyBraces: no_space - SupportedStyles: - - space - - no_space - - compact - -Layout/SpaceInsideStringInterpolation: - EnforcedStyle: no_space - SupportedStyles: - - space - - no_space - -Style/SymbolProc: - IgnoredMethods: - - respond_to - - define_method - -Style/TernaryParentheses: - EnforcedStyle: require_no_parentheses - SupportedStyles: - - require_parentheses - - require_no_parentheses - AllowSafeAssignment: true - -Layout/TrailingBlankLines: - EnforcedStyle: final_newline - SupportedStyles: - - final_newline - - final_blank_line - -Style/TrivialAccessors: - ExactNameMatch: true - AllowPredicates: true - AllowDSLWriters: false - IgnoreClassMethods: false - Whitelist: - - to_ary - - to_a - - to_c - - to_enum - - to_h - - to_hash - - to_i - - to_int - - to_io - - to_open - - to_path - - to_proc - - to_r - - to_regexp - - to_str - - to_s - - to_sym - -Naming/VariableName: - EnforcedStyle: snake_case - SupportedStyles: - - snake_case - - camelCase - -Style/WhileUntilModifier: - Enabled: true - -Style/WordArray: - EnforcedStyle: percent - SupportedStyles: - - percent - - brackets - MinSize: 0 - WordRegex: !ruby/regexp /\A[\p{Word}\n\t]+\z/ - -Metrics/BlockNesting: - Max: 3 +# Avoid classes longer than 100 lines of code. +Metrics/ClassLength: + Enabled: false +# Limit lines to 80 characters. Metrics/LineLength: Max: 120 - AllowHeredoc: true - AllowURI: true - URISchemes: - - http - - https - IgnoreCopDirectives: false - IgnoredPatterns: - - '\A\s*(remote_)?test(_\w+)?\s.*(do|->)(\s|\Z)' -Metrics/ParameterLists: - Max: 5 - CountKeywordArgs: false +# Avoid methods longer than 10 lines of code. +Metrics/MethodLength: + Enabled: false -Layout/BlockAlignment: - EnforcedStyleAlignWith: either - SupportedStylesAlignWith: - - either - - start_of_block - - start_of_line +# A calculated magnitude based on number of assignments, +# branches, and conditions. +Metrics/AbcSize: + Max: 60 -Layout/EndAlignment: - EnforcedStyleAlignWith: variable - SupportedStylesAlignWith: - - keyword - - variable - - start_of_line +# A complexity metric that is strongly correlated to the number +# of test cases needed to validate a method. +Metrics/CyclomaticComplexity: + Max: 17 -Layout/DefEndAlignment: - EnforcedStyleAlignWith: start_of_line - SupportedStylesAlignWith: - - start_of_line - - def - -Lint/InheritException: - EnforcedStyle: runtime_error - SupportedStyles: - - runtime_error - - standard_error - -Lint/UnusedBlockArgument: - IgnoreEmptyBlocks: true - AllowUnusedKeywordArguments: false - -Lint/UnusedMethodArgument: - AllowUnusedKeywordArguments: false - IgnoreEmptyMethods: true - -Performance/RedundantMerge: - MaxKeyValuePairs: 2 - -Rails/ActionFilter: - EnforcedStyle: action - SupportedStyles: - - action - - filter - Include: - - app/controllers/**/*.rb - -Rails/Date: - EnforcedStyle: flexible - SupportedStyles: - - strict - - flexible - -Rails/DynamicFindBy: - Whitelist: - - find_by_sql - -Rails/Exit: - Include: - - app/**/*.rb - - config/**/*.rb - - lib/**/*.rb - Exclude: - - 'lib/**/*.rake' - -Rails/FindBy: - Include: - - app/models/**/*.rb - -Rails/FindEach: - Include: - - app/models/**/*.rb - -Rails/HasAndBelongsToMany: - Include: - - app/models/**/*.rb - -Rails/NotNullColumn: - Include: - - db/migrate/*.rb - -Rails/Output: - Include: - - app/**/*.rb - - config/**/*.rb - - db/**/*.rb - - lib/**/*.rb - -Rails/ReadWriteAttribute: - Include: - - app/models/**/*.rb - -Rails/RequestReferer: - EnforcedStyle: referer - SupportedStyles: - - referer - - referrer - -Rails/SafeNavigation: - ConvertTry: false - -Rails/ScopeArgs: - Include: - - app/models/**/*.rb - -Rails/TimeZone: - EnforcedStyle: flexible - SupportedStyles: - - strict - - flexible - -Rails/UniqBeforePluck: - EnforcedStyle: conservative - SupportedStyles: - - conservative - - aggressive - -Rails/Validation: - Include: - - app/models/**/*.rb - -Naming/AccessorMethodName: - Enabled: true - -Layout/AlignArray: - Enabled: true - -Style/ArrayJoin: - Enabled: true - -Naming/AsciiIdentifiers: - Enabled: true - -Style/Attr: - Enabled: true - -Style/BeginBlock: - Enabled: true - -Style/BlockComments: - Enabled: true - -Layout/BlockEndNewline: - Enabled: true - -Style/CaseEquality: - Enabled: true - -Style/CharacterLiteral: - Enabled: true - -Naming/ClassAndModuleCamelCase: - Enabled: true - -Style/ClassMethods: - Enabled: true - -Style/ClassVars: - Enabled: true - -Layout/ClosingParenthesisIndentation: - Enabled: true - -Style/ColonMethodCall: - Enabled: true - -Layout/CommentIndentation: - Enabled: true - -Naming/ConstantName: - Enabled: true - -Style/DefWithParentheses: - Enabled: true - -Style/EachForSimpleLoop: - Enabled: true - -Style/EachWithObject: - Enabled: true - -Layout/ElseAlignment: - Enabled: true - -Style/EmptyCaseCondition: - Enabled: true - -Layout/EmptyLines: - Enabled: true - -Layout/EmptyLinesAroundAccessModifier: - Enabled: true - -Layout/EmptyLinesAroundMethodBody: - Enabled: true - -Style/EmptyLiteral: - Enabled: true - -Style/EndBlock: - Enabled: true - -Layout/EndOfLine: - Enabled: true - -Style/EvenOdd: - Enabled: true - -Layout/InitialIndentation: - Enabled: true - -Style/FlipFlop: - Enabled: true - -Style/IfInsideElse: - Enabled: true - -Style/IfUnlessModifierOfIfUnless: - Enabled: true - -Style/IfWithSemicolon: - Enabled: true - -Style/IdenticalConditionalBranches: - Enabled: true - -Style/InfiniteLoop: - Enabled: true - -Layout/LeadingCommentSpace: - Enabled: true - -Style/LineEndConcatenation: - Enabled: true - -Style/MethodCallWithoutArgsParentheses: - Enabled: true - -Style/MethodMissingSuper: - Enabled: true - -Style/MissingRespondToMissing: - Enabled: true - -Style/MultilineBlockChain: - Enabled: true - -Layout/MultilineBlockLayout: - Enabled: true - -Style/MultilineIfThen: - Enabled: true - -Style/MultilineMemoization: - Enabled: true - -Style/MultilineTernaryOperator: - Enabled: true - -Style/NegatedIf: - Enabled: true - -Style/NegatedWhile: - Enabled: true - -Style/NestedModifier: - Enabled: true - -Style/NestedParenthesizedCalls: - Enabled: true - -Style/NestedTernaryOperator: - Enabled: true - -Style/NilComparison: - Enabled: true - -Style/Not: - Enabled: true - -Style/OneLineConditional: - Enabled: true - -Naming/BinaryOperatorParameterName: - Enabled: true - -Style/OptionalArguments: - Enabled: true - -Style/ParallelAssignment: - Enabled: true - -Style/PerlBackrefs: - Enabled: true - -Style/Proc: - Enabled: true - -Style/RedundantBegin: - Enabled: true - -Style/RedundantException: - Enabled: true - -Style/RedundantFreeze: - Enabled: true - -Style/RedundantParentheses: - Enabled: true - -Style/RedundantSelf: - Enabled: true - -Layout/RescueEnsureAlignment: - Enabled: true - -Style/RescueModifier: - Enabled: true - -Style/SelfAssignment: - Enabled: true - -Layout/SpaceAfterColon: - Enabled: true - -Layout/SpaceAfterComma: - Enabled: true - -Layout/SpaceAfterMethodName: - Enabled: true - -Layout/SpaceAfterNot: - Enabled: true - -Layout/SpaceAfterSemicolon: - Enabled: true - -Layout/SpaceBeforeComma: - Enabled: true - -Layout/SpaceBeforeComment: - Enabled: true - -Layout/SpaceBeforeSemicolon: - Enabled: true - -Layout/SpaceAroundKeyword: - Enabled: true - -Layout/SpaceInsideArrayPercentLiteral: - Enabled: true - -Layout/SpaceInsidePercentLiteralDelimiters: - Enabled: true - -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: true - -Layout/SpaceInsideParens: - Enabled: true - -Layout/SpaceInsideRangeLiteral: - Enabled: true - -Style/SymbolLiteral: - Enabled: true - -Layout/Tab: - Enabled: true - -Layout/TrailingWhitespace: - Enabled: true - -Style/UnlessElse: - Enabled: true - -Style/UnneededCapitalW: - Enabled: true - -Style/UnneededInterpolation: - Enabled: true - -Style/UnneededPercentQ: - Enabled: true - -Style/VariableInterpolation: - Enabled: true - -Style/WhenThen: - Enabled: true - -Style/WhileUntilDo: - Enabled: true - -Style/ZeroLengthPredicate: - Enabled: true - -Layout/IndentHeredoc: - EnforcedStyle: squiggly - -Lint/AmbiguousOperator: - Enabled: true - -Lint/AmbiguousRegexpLiteral: - Enabled: true - -Lint/CircularArgumentReference: - Enabled: true - -Layout/ConditionPosition: - Enabled: true - -Lint/Debugger: - Enabled: true - -Lint/DeprecatedClassMethods: - Enabled: true - -Lint/DuplicateMethods: - Enabled: true - -Lint/DuplicatedKey: - Enabled: true - -Lint/EachWithObjectArgument: - Enabled: true - -Lint/ElseLayout: - Enabled: true - -Lint/EmptyEnsure: - Enabled: true - -Lint/EmptyInterpolation: - Enabled: true - -Lint/EndInMethod: - Enabled: true - -Lint/EnsureReturn: - Enabled: true - -Lint/FloatOutOfRange: - Enabled: true - -Lint/FormatParameterMismatch: - Enabled: true - -Lint/HandleExceptions: - Enabled: true - -Lint/ImplicitStringConcatenation: - Description: Checks for adjacent string literals on the same line, which could - better be represented as a single string literal. - -Lint/IneffectiveAccessModifier: - Description: Checks for attempts to use `private` or `protected` to set the visibility - of a class method, which does not work. - -Lint/LiteralAsCondition: - Enabled: true - -Lint/LiteralInInterpolation: - Enabled: true - -Lint/Loop: - Description: Use Kernel#loop with break rather than begin/end/until or begin/end/while - for post-loop tests. - -Lint/NestedMethodDefinition: - Enabled: true - -Lint/NextWithoutAccumulator: - Description: Do not omit the accumulator when calling `next` in a `reduce`/`inject` - block. - -Lint/NonLocalExitFromIterator: - Enabled: true - -Lint/ParenthesesAsGroupedExpression: - Enabled: true - -Lint/PercentStringArray: - Enabled: true - -Lint/PercentSymbolArray: - Enabled: true - -Lint/RandOne: - Description: Checks for `rand(1)` calls. Such calls always return `0` and most - likely a mistake. - -Lint/RequireParentheses: - Enabled: true - -Lint/RescueException: - Enabled: true - -Lint/ShadowedException: - Enabled: true - -Lint/ShadowingOuterLocalVariable: - Enabled: true - -Lint/StringConversionInInterpolation: - Enabled: true - -Lint/UnderscorePrefixedVariableName: - Enabled: true - -Lint/UnifiedInteger: - Enabled: true - -Lint/UnneededCopDisableDirective: - Enabled: true - -Lint/UnneededCopEnableDirective: - Enabled: true - -Lint/UnneededSplatExpansion: - Enabled: true - -Lint/UnreachableCode: - Enabled: true - -Lint/UselessAccessModifier: - ContextCreatingMethods: [] - -Lint/UselessAssignment: - Enabled: true - -Lint/UselessComparison: - Enabled: true - -Lint/UselessElseWithoutRescue: - Enabled: true - -Lint/UselessSetterCall: - Enabled: true - -Lint/Void: - Enabled: true - -Performance/CaseWhenSplat: - Enabled: true - -Performance/Count: - SafeMode: true - -Performance/Detect: - SafeMode: true - -Performance/DoubleStartEndWith: - Enabled: true - -Performance/EndWith: - Enabled: true - -Performance/FixedSize: - Enabled: true - -Performance/FlatMap: - EnabledForFlattenWithoutParams: false - -Performance/RangeInclude: - Enabled: true - -Performance/RedundantBlockCall: - Enabled: true - -Performance/RedundantMatch: - Enabled: true - -Performance/RedundantSortBy: - Enabled: true - -Performance/ReverseEach: - Enabled: true - -Performance/Sample: - Enabled: true - -Performance/Size: - Enabled: true - -Performance/CompareWithBlock: - Enabled: true - -Performance/StartWith: - Enabled: true - -Performance/StringReplacement: - Enabled: true - -Rails/DelegateAllowBlank: - Enabled: true - -Rails/HttpPositionalArguments: - Include: - - spec/**/* - - test/**/* - -Rails/OutputSafety: - Enabled: true - -Rails/PluralizationGrammar: - Enabled: true - -Security/Eval: - Enabled: true - -Security/JSONLoad: - Enabled: true - -Security/Open: - Enabled: true - -Lint/BigDecimalNew: - Enabled: true - -Style/TrailingBodyOnClass: - Enabled: true - -Style/TrailingBodyOnModule: - Enabled: true - -Style/TrailingCommaInArrayLiteral: - EnforcedStyleForMultiline: comma - Enabled: true - -Style/TrailingCommaInHashLiteral: - EnforcedStyleForMultiline: comma - Enabled: true - -Layout/SpaceInsideReferenceBrackets: - EnforcedStyle: no_space - EnforcedStyleForEmptyBrackets: no_space - Enabled: true - -Style/ModuleFunction: - EnforcedStyle: extend_self - -Lint/OrderedMagicComments: - Enabled: true +# Checks for method parameter names that contain capital letters, end in numbers, or do not meet a minimal length. +Naming/UncommunicativeMethodParamName: + Enabled: false diff --git a/Gemfile b/Gemfile index 11f3692d..a58166de 100644 --- a/Gemfile +++ b/Gemfile @@ -76,7 +76,7 @@ group :production do end # Ruby linting. -gem 'rubocop', '0.57.1' +gem 'rubocop' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index 3dba1598..db2fbd1f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -179,7 +179,6 @@ GEM ast (~> 2.4.0) pg (0.21.0) popper_js (1.14.5) - powerpack (0.1.2) public_suffix (3.0.3) puma (3.11.4) pyu-ruby-sasl (0.0.3.3) @@ -244,14 +243,13 @@ GEM rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) rspec-support (3.7.1) - rubocop (0.57.1) + rubocop (0.68.1) jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.5) - powerpack (~> 0.1) + parser (>= 2.5, != 2.5.1.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) + unicode-display_width (>= 1.4.0, < 1.6) ruby-progressbar (1.10.0) rubyntlm (0.6.2) safe_yaml (1.0.4) @@ -364,7 +362,7 @@ DEPENDENCIES redis (~> 3.0) remote_syslog_logger rspec-rails (~> 3.7) - rubocop (= 0.57.1) + rubocop sass-rails (~> 5.0) shoulda-matchers (~> 3.1) spring diff --git a/app/controllers/password_resets_controller.rb b/app/controllers/password_resets_controller.rb index caf978ef..4cf87adb 100644 --- a/app/controllers/password_resets_controller.rb +++ b/app/controllers/password_resets_controller.rb @@ -75,9 +75,7 @@ class PasswordResetsController < ApplicationController # Checks expiration of reset token. def check_expiration - if current_user.password_reset_expired? - redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token") - end + redirect_to new_password_reset_url, alert: I18n.t("expired_reset_token") if current_user.password_reset_expired? end def reset_link diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index e7cfc477..17bc0f8d 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -144,8 +144,8 @@ class RoomsController < ApplicationController begin redirect_to @room.join_path(current_user.name, opts, current_user.uid) - rescue BigBlueButton::BigBlueButtonException => exc - redirect_to room_path, alert: I18n.t(exc.key.to_s.underscore, default: I18n.t("bigbluebutton_exception")) + rescue BigBlueButton::BigBlueButtonException => e + redirect_to room_path, alert: I18n.t(e.key.to_s.underscore, default: I18n.t("bigbluebutton_exception")) end # Notify users that the room has started. @@ -192,7 +192,7 @@ class RoomsController < ApplicationController def create_room_settings_string(mute_res, client_res) room_settings = {} - room_settings["muteOnStart"] = mute_res == "1" ? true : false + room_settings["muteOnStart"] = mute_res == "1" if client_res.eql? "html5" room_settings["joinViaHtml5"] = true diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 09e14627..440a3c1f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -84,8 +84,8 @@ module ApplicationHelper begin provider_info = retrieve_provider_info(@user_domain, 'api2', 'getUserGreenlightCredentials') provider_info['provider'] == 'greenlight' - rescue => ex - logger.info ex + rescue => e + logger.info e false end end diff --git a/app/helpers/recordings_helper.rb b/app/helpers/recordings_helper.rb index 51fee958..1775307d 100644 --- a/app/helpers/recordings_helper.rb +++ b/app/helpers/recordings_helper.rb @@ -31,7 +31,7 @@ module RecordingsHelper len = valid_playbacks.first[:length] if len > 60 "#{(len / 60).to_i} hrs #{len % 60} mins" - elsif len == 0 + elsif len.zero? "< 1 min" else "#{len} min" diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index 011742ad..9c76c731 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -60,22 +60,20 @@ module SessionsHelper def generate_checksum(user_domain, redirect_url, secret) string = user_domain + redirect_url + secret - OpenSSL::Digest.digest('sha1', string).unpack("H*").first + OpenSSL::Digest.digest('sha1', string).unpack1("H*") end def parse_user_domain(hostname) return hostname.split('.').first if Rails.configuration.url_host.empty? Rails.configuration.url_host.split(',').each do |url_host| - if hostname.include?(url_host) - return hostname.chomp(url_host).chomp('.') - end + return hostname.chomp(url_host).chomp('.') if hostname.include?(url_host) end '' end def omniauth_options(env) gl_redirect_url = (Rails.env.production? ? "https" : env["rack.url_scheme"]) + "://" + env["SERVER_NAME"] + ":" + - env["SERVER_PORT"] + env["SERVER_PORT"] user_domain = parse_user_domain(env["SERVER_NAME"]) env['omniauth.strategy'].options[:customer] = user_domain env['omniauth.strategy'].options[:gl_redirect_url] = gl_redirect_url diff --git a/app/models/room.rb b/app/models/room.rb index 72c756e4..5e01e2d7 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -67,9 +67,9 @@ class Room < ApplicationRecord unless meeting[:messageKey] == 'duplicateWarning' update_attributes(sessions: sessions + 1, last_session: DateTime.now) end - rescue BigBlueButton::BigBlueButtonException => exc - puts "BigBlueButton failed on create: #{exc.key}: #{exc.message}" - raise exc + rescue BigBlueButton::BigBlueButtonException => e + puts "BigBlueButton failed on create: #{e.key}: #{e.message}" + raise e end end diff --git a/app/models/user.rb b/app/models/user.rb index 21176374..7e446f80 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -225,7 +225,7 @@ class User < ApplicationRecord # Initializes a room for the user and assign a BigBlueButton user id. def initialize_main_room - self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}" + self.uid = "gl-#{(0...12).map { rand(65..90).chr }.join.downcase}" self.main_room = Room.create!(owner: self, name: I18n.t("home_room")) save end diff --git a/config/application.rb b/config/application.rb index 8ddcc67b..d53284c0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -101,6 +101,6 @@ module Greenlight config.room_features = ENV['ROOM_FEATURES'] || "" # The maximum number of rooms included in one bbbapi call - config.pagination_number = ENV['PAGINATION_NUMBER'].to_i == 0 ? 25 : ENV['PAGINATION_NUMBER'].to_i + config.pagination_number = ENV['PAGINATION_NUMBER'].to_i.zero? ? 25 : ENV['PAGINATION_NUMBER'].to_i end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 10743429..837327dc 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -113,7 +113,5 @@ Rails.application.configure do config.active_record.dump_schema_after_migration = false # Set the relative url root for deployment to a subdirectory. - if ENV['RELATIVE_URL_ROOT'] != "/" - config.relative_url_root = ENV['RELATIVE_URL_ROOT'] || "/b" - end + config.relative_url_root = ENV['RELATIVE_URL_ROOT'] || "/b" if ENV['RELATIVE_URL_ROOT'] != "/" end diff --git a/lib/bbb_api.rb b/lib/bbb_api.rb index 09c601ad..d6b12fd2 100644 --- a/lib/bbb_api.rb +++ b/lib/bbb_api.rb @@ -64,7 +64,7 @@ module BbbApi def encode_bbb_url(base_url, secret, params, route = 'getUser') encoded_params = params.to_param string = route + encoded_params + secret - checksum = OpenSSL::Digest.digest('sha1', string).unpack('H*').first + checksum = OpenSSL::Digest.digest('sha1', string).unpack1('H*') URI.parse("#{base_url}#{route}?#{encoded_params}&checksum=#{checksum}") end diff --git a/lib/tasks/configuration.rake b/lib/tasks/configuration.rake index ac36df0b..0e9573ee 100644 --- a/lib/tasks/configuration.rake +++ b/lib/tasks/configuration.rake @@ -12,9 +12,7 @@ namespace :conf do # Initial check that variables are set print "\nChecking environment" ENV_VARIABLES.each do |var| - if ENV[var].blank? - failed("#{var} not set correctly") - end + failed("#{var} not set correctly") if ENV[var].blank? end passed @@ -48,8 +46,8 @@ def test_smtp ENV['SMTP_AUTH']) do |s| s.sendmail('test', ENV['SMTP_USERNAME'], 'notifications@example.com') end -rescue => exc - failed("Error connecting to SMTP - #{exc}") +rescue => e + failed("Error connecting to SMTP - #{e}") end # Takes the full URL including the protocol @@ -58,11 +56,9 @@ def test_request(url) res = Net::HTTP.get(uri) doc = Nokogiri::XML(res) - if doc.css("returncode").text != "SUCCESS" - failed("Could not get a valid response from BigBlueButton server - #{res}") - end -rescue => exc - failed("Error connecting to BigBlueButton server - #{exc}") + failed("Could not get a valid response from BigBlueButton server - #{res}") if doc.css("returncode").text != "SUCCESS" +rescue => e + failed("Error connecting to BigBlueButton server - #{e}") end def failed(msg) diff --git a/spec/models/room_spec.rb b/spec/models/room_spec.rb index dfcc714b..d418b043 100644 --- a/spec/models/room_spec.rb +++ b/spec/models/room_spec.rb @@ -102,7 +102,7 @@ describe Room, type: :model do query = fullname + meeting_id + password checksum_string = "join#{query + secret}" - checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack("H*").first + checksum = OpenSSL::Digest.digest('sha1', checksum_string).unpack1("H*") expect(@room.join_path("Example")).to eql("#{endpoint}join?#{query}&checksum=#{checksum}") end end