Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run Rubocop on a Ruby file named example.rb.
Ruby
rubocop [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using options like --fix or --version instead of the file name.
Not specifying any file to check.
✗ Incorrect
To check a Ruby file with Rubocop, you run
rubocop example.rb.2fill in blank
mediumComplete the command to automatically fix offenses in script.rb using Rubocop.
Ruby
rubocop [1] script.rb Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using --fix which is not a valid Rubocop option.
Using --version or --help which do not fix code.
✗ Incorrect
The
--auto-correct option tells Rubocop to fix offenses automatically.3fill in blank
hardFix the error in the Rubocop command to check all Ruby files in the current directory.
Ruby
rubocop [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using file extensions for other languages like .py.
Using incorrect file names or folder names.
✗ Incorrect
Using
*.rb tells Rubocop to check all Ruby files in the current folder.4fill in blank
hardFill both blanks to create a Rubocop configuration file that disables the Style/StringLiterals cop.
Ruby
Style/StringLiterals: Enabled: [1] EnforcedStyle: [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting Enabled to true when wanting to disable.
Confusing quote styles.
✗ Incorrect
Setting
Enabled: false disables the cop. EnforcedStyle: single_quotes sets preferred quotes style.5fill in blank
hardFill all three blanks to write a Rubocop command that checks app.rb, shows only offenses with severity 'error', and uses color output.
Ruby
rubocop [1] app.rb --severity [2] --[3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using --auto-correct instead of --color for colored output.
Not specifying severity correctly.
✗ Incorrect
The
--only option limits checks, error filters severity, and --color enables colored output.