You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code causes the Style/ConditionalAssignment cop to crash, when the cop is configured to use EnforcedStyle: assign_inside_condition. This is not the default style and must be configured.
...
1 error occurred:
An error occurred while Style/ConditionalAssignment cop was inspecting /tmp/sample.rb:3:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.50.2 (using Parser 3.2.2.1, rubocop-ast 1.28.0, running on ruby 2.7.4) [x86_64-linux-gnu]
Long version:
fhanson@fhanson-eng:/tmp$ rubocop --debug sample.rb
For /tmp: configuration from /tmp/.rubocop.yml
Default configuration from /var/lib/gems/2.7.0/gems/rubocop-1.50.2/config/default.yml
The following cops were added to RuboCop, but are not configured. Please set Enabled to either `true` or `false` in your `.rubocop.yml` file.
Please also note that you can opt-in to new cops by default by adding this to your config:
AllCops:
NewCops: enable
Gemspec/DeprecatedAttributeAssignment: # new in 1.30
Enabled: true
Gemspec/DevelopmentDependencies: # new in 1.44
Enabled: true
Gemspec/RequireMFA: # new in 1.23
Enabled: true
Layout/LineContinuationLeadingSpace: # new in 1.31
Enabled: true
Layout/LineContinuationSpacing: # new in 1.31
Enabled: true
Layout/LineEndStringConcatenationIndentation: # new in 1.18
Enabled: true
Layout/SpaceBeforeBrackets: # new in 1.7
Enabled: true
Lint/AmbiguousAssignment: # new in 1.7
Enabled: true
Lint/AmbiguousOperatorPrecedence: # new in 1.21
Enabled: true
Lint/AmbiguousRange: # new in 1.19
Enabled: true
Lint/ConstantOverwrittenInRescue: # new in 1.31
Enabled: true
Lint/DeprecatedConstants: # new in 1.8
Enabled: true
Lint/DuplicateBranch: # new in 1.3
Enabled: true
Lint/DuplicateMagicComment: # new in 1.37
Enabled: true
Lint/DuplicateMatchPattern: # new in 1.50
Enabled: true
Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
Enabled: true
Lint/EmptyBlock: # new in 1.1
Enabled: true
Lint/EmptyClass: # new in 1.3
Enabled: true
Lint/EmptyInPattern: # new in 1.16
Enabled: true
Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
Enabled: true
Lint/LambdaWithoutLiteralBlock: # new in 1.8
Enabled: true
Lint/NoReturnInBeginEndBlocks: # new in 1.2
Enabled: true
Lint/NonAtomicFileOperation: # new in 1.31
Enabled: true
Lint/NumberedParameterAssignment: # new in 1.9
Enabled: true
Lint/OrAssignmentToConstant: # new in 1.9
Enabled: true
Lint/RedundantDirGlobSort: # new in 1.8
Enabled: true
Lint/RefinementImportMethods: # new in 1.27
Enabled: true
Lint/RequireRangeParentheses: # new in 1.32
Enabled: true
Lint/RequireRelativeSelfPath: # new in 1.22
Enabled: true
Lint/SymbolConversion: # new in 1.9
Enabled: true
Lint/ToEnumArguments: # new in 1.1
Enabled: true
Lint/TripleQuotes: # new in 1.9
Enabled: true
Lint/UnexpectedBlockArity: # new in 1.5
Enabled: true
Lint/UnmodifiedReduceAccumulator: # new in 1.1
Enabled: true
Lint/UselessRescue: # new in 1.43
Enabled: true
Lint/UselessRuby2Keywords: # new in 1.23
Enabled: true
Metrics/CollectionLiteralLength: # new in 1.47
Enabled: true
Naming/BlockForwarding: # new in 1.24
Enabled: true
Security/CompoundHash: # new in 1.28
Enabled: true
Security/IoMethods: # new in 1.22
Enabled: true
Style/ArgumentsForwarding: # new in 1.1
Enabled: true
Style/ArrayIntersect: # new in 1.40
Enabled: true
Style/CollectionCompact: # new in 1.2
Enabled: true
Style/ComparableClamp: # new in 1.44
Enabled: true
Style/ConcatArrayLiterals: # new in 1.41
Enabled: true
Style/DataInheritance: # new in 1.49
Enabled: true
Style/DirEmpty: # new in 1.48
Enabled: true
Style/DocumentDynamicEvalDefinition: # new in 1.1
Enabled: true
Style/EmptyHeredoc: # new in 1.32
Enabled: true
Style/EndlessMethod: # new in 1.8
Enabled: true
Style/EnvHome: # new in 1.29
Enabled: true
Style/FetchEnvVar: # new in 1.28
Enabled: true
Style/FileEmpty: # new in 1.48
Enabled: true
Style/FileRead: # new in 1.24
Enabled: true
Style/FileWrite: # new in 1.24
Enabled: true
Style/HashConversion: # new in 1.10
Enabled: true
Style/HashExcept: # new in 1.7
Enabled: true
Style/IfWithBooleanLiteralBranches: # new in 1.9
Enabled: true
Style/InPatternThen: # new in 1.16
Enabled: true
Style/MagicCommentFormat: # new in 1.35
Enabled: true
Style/MapCompactWithConditionalBlock: # new in 1.30
Enabled: true
Style/MapToHash: # new in 1.24
Enabled: true
Style/MapToSet: # new in 1.42
Enabled: true
Style/MinMaxComparison: # new in 1.42
Enabled: true
Style/MultilineInPatternThen: # new in 1.16
Enabled: true
Style/NegatedIfElseCondition: # new in 1.2
Enabled: true
Style/NestedFileDirname: # new in 1.26
Enabled: true
Style/NilLambda: # new in 1.3
Enabled: true
Style/NumberedParameters: # new in 1.22
Enabled: true
Style/NumberedParametersLimit: # new in 1.22
Enabled: true
Style/ObjectThen: # new in 1.28
Enabled: true
Style/OpenStructUse: # new in 1.23
Enabled: true
Style/OperatorMethodCall: # new in 1.37
Enabled: true
Style/QuotedSymbols: # new in 1.16
Enabled: true
Style/RedundantArgument: # new in 1.4
Enabled: true
Style/RedundantConstantBase: # new in 1.40
Enabled: true
Style/RedundantDoubleSplatHashBraces: # new in 1.41
Enabled: true
Style/RedundantEach: # new in 1.38
Enabled: true
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
Enabled: true
Style/RedundantInitialize: # new in 1.27
Enabled: true
Style/RedundantLineContinuation: # new in 1.49
Enabled: true
Style/RedundantSelfAssignmentBranch: # new in 1.19
Enabled: true
Style/RedundantStringEscape: # new in 1.37
Enabled: true
Style/SelectByRegexp: # new in 1.22
Enabled: true
Style/StringChars: # new in 1.12
Enabled: true
Style/SwapValues: # new in 1.1
Enabled: true
For more information: https://docs.rubocop.org/rubocop/versioning.html
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /tmp/sample.rb
An error occurred while Style/ConditionalAssignment cop was inspecting /tmp/sample.rb:3:0.
undefined method `if_type?' for nil:NilClass
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:353:in `block in ternary_condition?'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:353:in `any?'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:353:in `ternary_condition?'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:343:in `move_assignment_inside_condition'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:380:in `autocorrect'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:300:in `block in check_assignment_to_condition'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/base.rb:373:in `correct'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/base.rb:181:in `add_offense'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:299:in `check_assignment_to_condition'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/style/conditional_assignment.rb:240:in `block (2 levels) in <class:ConditionalAssignment>'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:105:in `each'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:69:in `on_ivasgn'
/var/lib/gems/2.7.0/gems/rubocop-ast-1.28.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cop/team.rb:98:in `investigate'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:345:in `block in inspect_file'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:344:in `each'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:344:in `flat_map'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:344:in `inspect_file'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:314:in `loop'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:164:in `block in file_offenses'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:189:in `file_offense_cache'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:163:in `file_offenses'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:154:in `process_file'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:134:in `each'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:134:in `reduce'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:134:in `each_inspected_file'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:120:in `inspect_files'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/runner.rb:73:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli/command.rb:11:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli/environment.rb:18:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli.rb:118:in `run_command'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli.rb:125:in `execute_runners'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli.rb:51:in `block in run'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli.rb:77:in `profile_if_needed'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/lib/rubocop/cli.rb:43:in `run'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/exe/rubocop:19:in `block in <top (required)>'
/var/lib/gems/2.7.0/gems/benchmark-0.2.0/lib/benchmark.rb:311:in `realtime'
/var/lib/gems/2.7.0/gems/rubocop-1.50.2/exe/rubocop:19:in `<top (required)>'
/usr/local/bin/rubocop:23:in `load'
/usr/local/bin/rubocop:23:in `<main>'
W
Offenses:
sample.rb:1:1: W: Lint/ScriptPermission: Script file sample.rb doesn't have execute permission.
#!/usr/bin/ruby
^^^^^^^^^^^^^^^
sample.rb:1:1: C: [Correctable] Style/FrozenStringLiteralComment: Missing frozen string literal comment.
#!/usr/bin/ruby
^
sample.rb:4:3: C: [Correctable] Style/EmptyCaseCondition: Do not use empty case condition, instead use an if expression.
case
^^^^
sample.rb:8:11: C: [Correctable] Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
raise "Unhandled delimiter specification"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 file inspected, 4 offenses detected, 3 offenses autocorrectable
1 error occurred:
An error occurred while Style/ConditionalAssignment cop was inspecting /tmp/sample.rb:3:0.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.50.2 (using Parser 3.2.2.1, rubocop-ast 1.28.0, running on ruby 2.7.4) [x86_64-linux-gnu]
Finished in 0.22492295783013105 seconds
Steps to reproduce the problem
Create the .rubocop.yml file and sample.rb file shown above.
Fixesrubocop#11849.
This PR fixes an error for `Style/ConditionalAssignment`
when `EnforcedStyle: assign_inside_condition` and using empty `case` condition.
This code causes the Style/ConditionalAssignment cop to crash, when the cop is configured to use
EnforcedStyle: assign_inside_condition
. This is not the default style and must be configured.fhanson@fhanson-eng:/tmp$ cat .rubocop.yml
fhanson@fhanson-eng:/tmp$ cat sample.rb
Expected behavior
I expect the cop to flag the code as a violation.
Actual behavior
The cop crashes.
Short version:
Long version:
Steps to reproduce the problem
.rubocop.yml
file andsample.rb
file shown above.RuboCop version
The text was updated successfully, but these errors were encountered: