├── .codeclimate.yml ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ └── ubuntu.yml ├── .gitignore ├── .mdlrc ├── .rubocop.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Rakefile ├── bin ├── bundle ├── rake └── rubocop ├── code_of_conduct.md ├── lib ├── byebug │ └── processors │ │ └── pry_processor.rb ├── pry-byebug.rb ├── pry-byebug │ ├── base.rb │ ├── cli.rb │ ├── commands.rb │ ├── commands │ │ ├── backtrace.rb │ │ ├── breakpoint.rb │ │ ├── continue.rb │ │ ├── down.rb │ │ ├── exit_all.rb │ │ ├── finish.rb │ │ ├── frame.rb │ │ ├── next.rb │ │ ├── step.rb │ │ └── up.rb │ ├── control_d_handler.rb │ ├── helpers │ │ ├── breakpoints.rb │ │ ├── location.rb │ │ ├── multiline.rb │ │ └── navigation.rb │ ├── pry_ext.rb │ ├── pry_remote_ext.rb │ └── version.rb └── pry │ └── byebug │ └── breakpoints.rb ├── pry-byebug.gemspec └── test ├── base_test.rb ├── breakpoints_test.rb ├── commands ├── breakpoints_test.rb ├── frames_test.rb └── stepping_test.rb ├── examples ├── break1.rb ├── break2.rb ├── deep_stepping.rb ├── echo_thread.rb ├── frames.rb ├── multiple.rb └── stepping.rb ├── processor_test.rb ├── pry_ext_test.rb ├── pry_remote_ext_test.rb ├── test_helper.rb └── thread_lock_test.rb /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | version: "2" 4 | 5 | checks: 6 | method-complexity: 7 | config: 8 | threshold: 6 9 | 10 | similar-code: 11 | enabled: false 12 | 13 | plugins: 14 | grep: 15 | enabled: true 16 | 17 | config: 18 | patterns: 19 | no-trailing-whitespace: 20 | pattern: \s*$ 21 | annotation: "Don't leave trailing whitespace" 22 | severity: minor 23 | categories: Style 24 | path_patterns: 25 | - .rubocop.yml 26 | 27 | no-tabs: 28 | pattern: " " 29 | annotation: "Don't use hard tabs" 30 | severity: minor 31 | categories: Style 32 | path_patterns: 33 | - .rubocop.yml 34 | 35 | exclude_patterns: 36 | - .bundle/ 37 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | liberapay: pry-byebug 4 | tidelift: rubygems/pry-byebug 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: bundler 5 | directory: / 6 | schedule: 7 | interval: monthly 8 | versioning-strategy: increase-if-necessary 9 | 10 | - package-ecosystem: github-actions 11 | directory: / 12 | schedule: 13 | interval: monthly 14 | -------------------------------------------------------------------------------- /.github/workflows/ubuntu.yml: -------------------------------------------------------------------------------- 1 | name: ubuntu 2 | 3 | on: 4 | pull_request: 5 | 6 | push: 7 | branches: 8 | - master 9 | 10 | jobs: 11 | test: 12 | name: Ruby ${{ matrix.ruby.name }} 13 | runs-on: ubuntu-24.04 14 | 15 | strategy: 16 | matrix: 17 | ruby: 18 | - { name: 3.1, value: 3.1.7 } 19 | - { name: 3.2, value: 3.2.8 } 20 | - { name: 3.3, value: 3.3.7 } 21 | 22 | env: 23 | BUNDLE_PATH: .bundle 24 | 25 | steps: 26 | - uses: actions/checkout@v4 27 | 28 | - name: Setup ruby 29 | uses: ruby/setup-ruby@v1 30 | with: 31 | ruby-version: ${{ matrix.ruby.value }} 32 | 33 | - name: Install dependencies 34 | run: | 35 | bundle install 36 | 37 | - name: Run tests 38 | run: RUBYOPT="-E UTF-8" bundle exec rake 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # 2 | # Only generated pry-byebug specific files to be kept here. 3 | # 4 | tmp 5 | pkg 6 | doc 7 | 8 | .bundle 9 | 10 | .ruby-gemset 11 | .ruby-version 12 | -------------------------------------------------------------------------------- /.mdlrc: -------------------------------------------------------------------------------- 1 | rules '~MD013,~MD024' 2 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | DisabledByDefault: true 3 | DisplayCopNames: true 4 | DisplayStyleGuide: true 5 | SuggestExtensions: false 6 | 7 | TargetRubyVersion: 3.1 8 | 9 | # Department 'Bundler' (4): 10 | Bundler/DuplicatedGem: 11 | Description: Checks for duplicate gem entries in Gemfile. 12 | Enabled: true 13 | VersionAdded: '0.46' 14 | Include: 15 | - "**/*.gemfile" 16 | - "**/Gemfile" 17 | - "**/gems.rb" 18 | 19 | # Supports --auto-correct 20 | Bundler/InsecureProtocolSource: 21 | Description: The source `:gemcutter`, `:rubygems` and `:rubyforge` are deprecated 22 | because HTTP requests are insecure. Please change your source to 'https://rubygems.org' 23 | if possible, or 'http://rubygems.org' if not. 24 | Enabled: true 25 | VersionAdded: '0.50' 26 | Include: 27 | - "**/*.gemfile" 28 | - "**/Gemfile" 29 | - "**/gems.rb" 30 | 31 | # Supports --auto-correct 32 | Bundler/OrderedGems: 33 | Description: Gems within groups in the Gemfile should be alphabetically sorted. 34 | Enabled: true 35 | VersionAdded: '0.46' 36 | VersionChanged: '0.47' 37 | TreatCommentsAsGroupSeparators: true 38 | ConsiderPunctuation: false 39 | Include: 40 | - "**/*.gemfile" 41 | - "**/Gemfile" 42 | - "**/gems.rb" 43 | 44 | # Department 'Gemspec' (4): 45 | Gemspec/DuplicatedAssignment: 46 | Description: An attribute assignment method calls should be listed only once in a 47 | gemspec. 48 | Enabled: true 49 | VersionAdded: '0.52' 50 | Include: 51 | - "**/*.gemspec" 52 | 53 | # Supports --auto-correct 54 | Gemspec/OrderedDependencies: 55 | Description: Dependencies in the gemspec should be alphabetically sorted. 56 | Enabled: true 57 | VersionAdded: '0.51' 58 | TreatCommentsAsGroupSeparators: true 59 | ConsiderPunctuation: false 60 | Include: 61 | - "**/*.gemspec" 62 | 63 | Gemspec/RequiredRubyVersion: 64 | Description: Checks that `required_ruby_version` of gemspec is specified and equal 65 | to `TargetRubyVersion` of .rubocop.yml. 66 | Enabled: true 67 | VersionAdded: '0.52' 68 | VersionChanged: '0.89' 69 | Include: 70 | - "**/*.gemspec" 71 | 72 | Gemspec/RubyVersionGlobalsUsage: 73 | Description: Checks usage of RUBY_VERSION in gemspec. 74 | StyleGuide: "#no-ruby-version-in-the-gemspec" 75 | Enabled: true 76 | VersionAdded: '0.72' 77 | Include: 78 | - "**/*.gemspec" 79 | 80 | # Department 'Layout' (92): 81 | # Supports --auto-correct 82 | Layout/AccessModifierIndentation: 83 | Description: Check indentation of private/protected visibility modifiers. 84 | StyleGuide: "#indent-public-private-protected" 85 | Enabled: true 86 | VersionAdded: '0.49' 87 | EnforcedStyle: indent 88 | SupportedStyles: 89 | - outdent 90 | - indent 91 | IndentationWidth: 92 | 93 | # Supports --auto-correct 94 | Layout/ArgumentAlignment: 95 | Description: Align the arguments of a method call if they span more than one line. 96 | StyleGuide: "#no-double-indent" 97 | Enabled: true 98 | VersionAdded: '0.68' 99 | VersionChanged: '0.77' 100 | EnforcedStyle: with_first_argument 101 | SupportedStyles: 102 | - with_first_argument 103 | - with_fixed_indentation 104 | IndentationWidth: 105 | 106 | # Supports --auto-correct 107 | Layout/ArrayAlignment: 108 | Description: Align the elements of an array literal if they span more than one line. 109 | StyleGuide: "#no-double-indent" 110 | Enabled: true 111 | VersionAdded: '0.49' 112 | VersionChanged: '0.77' 113 | EnforcedStyle: with_first_element 114 | SupportedStyles: 115 | - with_first_element 116 | - with_fixed_indentation 117 | IndentationWidth: 118 | 119 | # Supports --auto-correct 120 | Layout/AssignmentIndentation: 121 | Description: Checks the indentation of the first line of the right-hand-side of a 122 | multi-line assignment. 123 | Enabled: true 124 | VersionAdded: '0.49' 125 | VersionChanged: '0.77' 126 | IndentationWidth: 127 | 128 | # Supports --auto-correct 129 | Layout/BeginEndAlignment: 130 | Description: Align ends corresponding to begins correctly. 131 | Enabled: true 132 | VersionAdded: '0.91' 133 | EnforcedStyleAlignWith: start_of_line 134 | SupportedStylesAlignWith: 135 | - start_of_line 136 | - begin 137 | Severity: warning 138 | 139 | # Supports --auto-correct 140 | Layout/BlockAlignment: 141 | Description: Align block ends correctly. 142 | Enabled: true 143 | VersionAdded: '0.53' 144 | EnforcedStyleAlignWith: either 145 | SupportedStylesAlignWith: 146 | - either 147 | - start_of_block 148 | - start_of_line 149 | 150 | # Supports --auto-correct 151 | Layout/BlockEndNewline: 152 | Description: Put end statement of multiline block on its own line. 153 | Enabled: true 154 | VersionAdded: '0.49' 155 | 156 | # Supports --auto-correct 157 | Layout/CaseIndentation: 158 | Description: Indentation of when in a case/when/[else/]end. 159 | StyleGuide: "#indent-when-to-case" 160 | Enabled: true 161 | VersionAdded: '0.49' 162 | EnforcedStyle: case 163 | SupportedStyles: 164 | - case 165 | - end 166 | IndentOneStep: false 167 | IndentationWidth: 168 | 169 | # Supports --auto-correct 170 | Layout/ClosingHeredocIndentation: 171 | Description: Checks the indentation of here document closings. 172 | Enabled: true 173 | VersionAdded: '0.57' 174 | 175 | # Supports --auto-correct 176 | Layout/ClosingParenthesisIndentation: 177 | Description: Checks the indentation of hanging closing parentheses. 178 | Enabled: true 179 | VersionAdded: '0.49' 180 | 181 | # Supports --auto-correct 182 | Layout/CommentIndentation: 183 | Description: Indentation of comments. 184 | Enabled: true 185 | VersionAdded: '0.49' 186 | 187 | # Supports --auto-correct 188 | Layout/ConditionPosition: 189 | Description: Checks for condition placed in a confusing position relative to the keyword. 190 | StyleGuide: "#same-line-condition" 191 | Enabled: true 192 | VersionAdded: '0.53' 193 | VersionChanged: '0.83' 194 | 195 | # Supports --auto-correct 196 | Layout/DefEndAlignment: 197 | Description: Align ends corresponding to defs correctly. 198 | Enabled: true 199 | VersionAdded: '0.53' 200 | EnforcedStyleAlignWith: start_of_line 201 | SupportedStylesAlignWith: 202 | - start_of_line 203 | - def 204 | Severity: warning 205 | 206 | # Supports --auto-correct 207 | Layout/DotPosition: 208 | Description: Checks the position of the dot in multi-line method calls. 209 | StyleGuide: "#consistent-multi-line-chains" 210 | Enabled: true 211 | VersionAdded: '0.49' 212 | EnforcedStyle: leading 213 | SupportedStyles: 214 | - leading 215 | - trailing 216 | 217 | # Supports --auto-correct 218 | Layout/ElseAlignment: 219 | Description: Align elses and elsifs correctly. 220 | Enabled: true 221 | VersionAdded: '0.49' 222 | 223 | # Supports --auto-correct 224 | Layout/EmptyComment: 225 | Description: Checks empty comment. 226 | Enabled: true 227 | VersionAdded: '0.53' 228 | AllowBorderComment: true 229 | AllowMarginComment: true 230 | 231 | # Supports --auto-correct 232 | Layout/EmptyLineAfterGuardClause: 233 | Description: Add empty line after guard clause. 234 | Enabled: true 235 | VersionAdded: '0.56' 236 | VersionChanged: '0.59' 237 | 238 | # Supports --auto-correct 239 | Layout/EmptyLineAfterMagicComment: 240 | Description: Add an empty line after magic comments to separate them from code. 241 | StyleGuide: "#separate-magic-comments-from-code" 242 | Enabled: true 243 | VersionAdded: '0.49' 244 | 245 | # Supports --auto-correct 246 | Layout/EmptyLineBetweenDefs: 247 | Description: Use empty lines between defs. 248 | StyleGuide: "#empty-lines-between-methods" 249 | Enabled: true 250 | VersionAdded: '0.49' 251 | AllowAdjacentOneLineDefs: false 252 | NumberOfEmptyLines: 1 253 | 254 | # Supports --auto-correct 255 | Layout/EmptyLines: 256 | Description: Don't use several empty lines in a row. 257 | StyleGuide: "#two-or-more-empty-lines" 258 | Enabled: true 259 | VersionAdded: '0.49' 260 | 261 | # Supports --auto-correct 262 | Layout/EmptyLinesAroundAccessModifier: 263 | Description: Keep blank lines around access modifiers. 264 | StyleGuide: "#empty-lines-around-access-modifier" 265 | Enabled: true 266 | VersionAdded: '0.49' 267 | EnforcedStyle: around 268 | SupportedStyles: 269 | - around 270 | - only_before 271 | Reference: 272 | - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions 273 | 274 | # Supports --auto-correct 275 | Layout/EmptyLinesAroundArguments: 276 | Description: Keeps track of empty lines around method arguments. 277 | Enabled: true 278 | VersionAdded: '0.52' 279 | 280 | # Supports --auto-correct 281 | Layout/EmptyLinesAroundAttributeAccessor: 282 | Description: Keep blank lines around attribute accessors. 283 | StyleGuide: "#empty-lines-around-attribute-accessor" 284 | Enabled: true 285 | VersionAdded: '0.83' 286 | VersionChanged: '0.84' 287 | AllowAliasSyntax: true 288 | AllowedMethods: 289 | - alias_method 290 | - public 291 | - protected 292 | - private 293 | 294 | # Supports --auto-correct 295 | Layout/EmptyLinesAroundBeginBody: 296 | Description: Keeps track of empty lines around begin-end bodies. 297 | StyleGuide: "#empty-lines-around-bodies" 298 | Enabled: true 299 | VersionAdded: '0.49' 300 | 301 | # Supports --auto-correct 302 | Layout/EmptyLinesAroundBlockBody: 303 | Description: Keeps track of empty lines around block bodies. 304 | StyleGuide: "#empty-lines-around-bodies" 305 | Enabled: true 306 | VersionAdded: '0.49' 307 | EnforcedStyle: no_empty_lines 308 | SupportedStyles: 309 | - empty_lines 310 | - no_empty_lines 311 | 312 | # Supports --auto-correct 313 | Layout/EmptyLinesAroundClassBody: 314 | Description: Keeps track of empty lines around class bodies. 315 | StyleGuide: "#empty-lines-around-bodies" 316 | Enabled: true 317 | VersionAdded: '0.49' 318 | VersionChanged: '0.53' 319 | EnforcedStyle: no_empty_lines 320 | SupportedStyles: 321 | - empty_lines 322 | - empty_lines_except_namespace 323 | - empty_lines_special 324 | - no_empty_lines 325 | - beginning_only 326 | - ending_only 327 | 328 | # Supports --auto-correct 329 | Layout/EmptyLinesAroundExceptionHandlingKeywords: 330 | Description: Keeps track of empty lines around exception handling keywords. 331 | StyleGuide: "#empty-lines-around-bodies" 332 | Enabled: true 333 | VersionAdded: '0.49' 334 | 335 | # Supports --auto-correct 336 | Layout/EmptyLinesAroundMethodBody: 337 | Description: Keeps track of empty lines around method bodies. 338 | StyleGuide: "#empty-lines-around-bodies" 339 | Enabled: true 340 | VersionAdded: '0.49' 341 | 342 | # Supports --auto-correct 343 | Layout/EmptyLinesAroundModuleBody: 344 | Description: Keeps track of empty lines around module bodies. 345 | StyleGuide: "#empty-lines-around-bodies" 346 | Enabled: true 347 | VersionAdded: '0.49' 348 | EnforcedStyle: no_empty_lines 349 | SupportedStyles: 350 | - empty_lines 351 | - empty_lines_except_namespace 352 | - empty_lines_special 353 | - no_empty_lines 354 | 355 | # Supports --auto-correct 356 | Layout/EndAlignment: 357 | Description: Align ends correctly. 358 | Enabled: true 359 | VersionAdded: '0.53' 360 | EnforcedStyleAlignWith: keyword 361 | SupportedStylesAlignWith: 362 | - keyword 363 | - variable 364 | - start_of_line 365 | Severity: warning 366 | 367 | Layout/EndOfLine: 368 | Description: Use Unix-style line endings. 369 | StyleGuide: "#crlf" 370 | Enabled: true 371 | VersionAdded: '0.49' 372 | EnforcedStyle: native 373 | SupportedStyles: 374 | - native 375 | - lf 376 | - crlf 377 | 378 | # Supports --auto-correct 379 | Layout/ExtraSpacing: 380 | Description: Do not use unnecessary spacing. 381 | Enabled: true 382 | VersionAdded: '0.49' 383 | AllowForAlignment: false 384 | AllowBeforeTrailingComments: false 385 | ForceEqualSignAlignment: false 386 | 387 | # Supports --auto-correct 388 | Layout/FirstArgumentIndentation: 389 | Description: Checks the indentation of the first argument in a method call. 390 | Enabled: true 391 | VersionAdded: '0.68' 392 | VersionChanged: '0.77' 393 | EnforcedStyle: special_for_inner_method_call_in_parentheses 394 | SupportedStyles: 395 | - consistent 396 | - consistent_relative_to_receiver 397 | - special_for_inner_method_call 398 | - special_for_inner_method_call_in_parentheses 399 | IndentationWidth: 400 | 401 | # Supports --auto-correct 402 | Layout/FirstArrayElementIndentation: 403 | Description: Checks the indentation of the first element in an array literal. 404 | Enabled: true 405 | VersionAdded: '0.68' 406 | VersionChanged: '0.77' 407 | EnforcedStyle: special_inside_parentheses 408 | SupportedStyles: 409 | - special_inside_parentheses 410 | - consistent 411 | - align_brackets 412 | IndentationWidth: 413 | 414 | # Supports --auto-correct 415 | Layout/FirstHashElementIndentation: 416 | Description: Checks the indentation of the first key in a hash literal. 417 | Enabled: true 418 | VersionAdded: '0.68' 419 | VersionChanged: '0.77' 420 | EnforcedStyle: special_inside_parentheses 421 | SupportedStyles: 422 | - special_inside_parentheses 423 | - consistent 424 | - align_braces 425 | IndentationWidth: 426 | 427 | # Supports --auto-correct 428 | Layout/FirstParameterIndentation: 429 | Description: Checks the indentation of the first parameter in a method definition. 430 | Enabled: true 431 | VersionAdded: '0.49' 432 | VersionChanged: '0.77' 433 | EnforcedStyle: consistent 434 | SupportedStyles: 435 | - consistent 436 | - align_parentheses 437 | IndentationWidth: 438 | 439 | # Supports --auto-correct 440 | Layout/HashAlignment: 441 | Description: Align the elements of a hash literal if they span more than one line. 442 | Enabled: true 443 | AllowMultipleStyles: true 444 | VersionAdded: '0.49' 445 | VersionChanged: '0.77' 446 | EnforcedHashRocketStyle: key 447 | SupportedHashRocketStyles: 448 | - key 449 | - separator 450 | - table 451 | EnforcedColonStyle: key 452 | SupportedColonStyles: 453 | - key 454 | - separator 455 | - table 456 | EnforcedLastArgumentHashStyle: always_inspect 457 | SupportedLastArgumentHashStyles: 458 | - always_inspect 459 | - always_ignore 460 | - ignore_implicit 461 | - ignore_explicit 462 | 463 | # Supports --auto-correct 464 | Layout/HeredocIndentation: 465 | Description: This cop checks the indentation of the here document bodies. 466 | StyleGuide: "#squiggly-heredocs" 467 | Enabled: true 468 | VersionAdded: '0.49' 469 | VersionChanged: '0.85' 470 | 471 | # Supports --auto-correct 472 | Layout/IndentationConsistency: 473 | Description: Keep indentation straight. 474 | StyleGuide: "#spaces-indentation" 475 | Enabled: true 476 | VersionAdded: '0.49' 477 | EnforcedStyle: normal 478 | SupportedStyles: 479 | - normal 480 | - indented_internal_methods 481 | Reference: 482 | - https://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions 483 | 484 | # Supports --auto-correct 485 | Layout/IndentationStyle: 486 | Description: Consistent indentation either with tabs only or spaces only. 487 | StyleGuide: "#spaces-indentation" 488 | Enabled: true 489 | VersionAdded: '0.49' 490 | VersionChanged: '0.82' 491 | IndentationWidth: 492 | EnforcedStyle: spaces 493 | SupportedStyles: 494 | - spaces 495 | - tabs 496 | 497 | # Supports --auto-correct 498 | Layout/IndentationWidth: 499 | Description: Use 2 spaces for indentation. 500 | StyleGuide: "#spaces-indentation" 501 | Enabled: true 502 | VersionAdded: '0.49' 503 | Width: 2 504 | AllowedPatterns: [] 505 | 506 | # Supports --auto-correct 507 | Layout/InitialIndentation: 508 | Description: Checks the indentation of the first non-blank non-comment line in a file. 509 | Enabled: true 510 | VersionAdded: '0.49' 511 | 512 | # Supports --auto-correct 513 | Layout/LeadingCommentSpace: 514 | Description: Comments should start with a space. 515 | StyleGuide: "#hash-space" 516 | Enabled: true 517 | VersionAdded: '0.49' 518 | VersionChanged: '0.73' 519 | AllowDoxygenCommentStyle: false 520 | AllowGemfileRubyComment: false 521 | 522 | # Supports --auto-correct 523 | Layout/LeadingEmptyLines: 524 | Description: Check for unnecessary blank lines at the beginning of a file. 525 | Enabled: true 526 | VersionAdded: '0.57' 527 | VersionChanged: '0.77' 528 | 529 | # Supports --auto-correct 530 | Layout/MultilineArrayBraceLayout: 531 | Description: Checks that the closing brace in an array literal is either on the same 532 | line as the last array element, or a new line. 533 | Enabled: true 534 | VersionAdded: '0.49' 535 | EnforcedStyle: symmetrical 536 | SupportedStyles: 537 | - symmetrical 538 | - new_line 539 | - same_line 540 | 541 | # Supports --auto-correct 542 | Layout/MultilineBlockLayout: 543 | Description: Ensures newlines after multiline block do statements. 544 | Enabled: true 545 | VersionAdded: '0.49' 546 | 547 | # Supports --auto-correct 548 | Layout/MultilineHashBraceLayout: 549 | Description: Checks that the closing brace in a hash literal is either on the same 550 | line as the last hash element, or a new line. 551 | Enabled: true 552 | VersionAdded: '0.49' 553 | EnforcedStyle: symmetrical 554 | SupportedStyles: 555 | - symmetrical 556 | - new_line 557 | - same_line 558 | 559 | # Supports --auto-correct 560 | Layout/MultilineMethodCallBraceLayout: 561 | Description: Checks that the closing brace in a method call is either on the same 562 | line as the last method argument, or a new line. 563 | Enabled: true 564 | VersionAdded: '0.49' 565 | EnforcedStyle: symmetrical 566 | SupportedStyles: 567 | - symmetrical 568 | - new_line 569 | - same_line 570 | 571 | # Supports --auto-correct 572 | Layout/MultilineMethodCallIndentation: 573 | Description: Checks indentation of method calls with the dot operator that span more 574 | than one line. 575 | Enabled: true 576 | VersionAdded: '0.49' 577 | EnforcedStyle: aligned 578 | SupportedStyles: 579 | - aligned 580 | - indented 581 | - indented_relative_to_receiver 582 | IndentationWidth: 583 | 584 | # Supports --auto-correct 585 | Layout/MultilineMethodDefinitionBraceLayout: 586 | Description: Checks that the closing brace in a method definition is either on the 587 | same line as the last method parameter, or a new line. 588 | Enabled: true 589 | VersionAdded: '0.49' 590 | EnforcedStyle: symmetrical 591 | SupportedStyles: 592 | - symmetrical 593 | - new_line 594 | - same_line 595 | 596 | # Supports --auto-correct 597 | Layout/MultilineOperationIndentation: 598 | Description: Checks indentation of binary operations that span more than one line. 599 | Enabled: true 600 | VersionAdded: '0.49' 601 | EnforcedStyle: aligned 602 | SupportedStyles: 603 | - aligned 604 | - indented 605 | IndentationWidth: 606 | 607 | # Supports --auto-correct 608 | Layout/ParameterAlignment: 609 | Description: Align the parameters of a method definition if they span more than one 610 | line. 611 | StyleGuide: "#no-double-indent" 612 | Enabled: true 613 | VersionAdded: '0.49' 614 | VersionChanged: '0.77' 615 | EnforcedStyle: with_first_parameter 616 | SupportedStyles: 617 | - with_first_parameter 618 | - with_fixed_indentation 619 | IndentationWidth: 620 | 621 | # Supports --auto-correct 622 | Layout/RescueEnsureAlignment: 623 | Description: Align rescues and ensures correctly. 624 | Enabled: true 625 | VersionAdded: '0.49' 626 | 627 | # Supports --auto-correct 628 | Layout/SpaceAfterColon: 629 | Description: Use spaces after colons. 630 | StyleGuide: "#spaces-operators" 631 | Enabled: true 632 | VersionAdded: '0.49' 633 | 634 | # Supports --auto-correct 635 | Layout/SpaceAfterComma: 636 | Description: Use spaces after commas. 637 | StyleGuide: "#spaces-operators" 638 | Enabled: true 639 | VersionAdded: '0.49' 640 | 641 | # Supports --auto-correct 642 | Layout/SpaceAfterMethodName: 643 | Description: Do not put a space between a method name and the opening parenthesis 644 | in a method definition. 645 | StyleGuide: "#parens-no-spaces" 646 | Enabled: true 647 | VersionAdded: '0.49' 648 | 649 | # Supports --auto-correct 650 | Layout/SpaceAfterNot: 651 | Description: Tracks redundant space after the ! operator. 652 | StyleGuide: "#no-space-bang" 653 | Enabled: true 654 | VersionAdded: '0.49' 655 | 656 | # Supports --auto-correct 657 | Layout/SpaceAfterSemicolon: 658 | Description: Use spaces after semicolons. 659 | StyleGuide: "#spaces-operators" 660 | Enabled: true 661 | VersionAdded: '0.49' 662 | 663 | # Supports --auto-correct 664 | Layout/SpaceAroundBlockParameters: 665 | Description: Checks the spacing inside and after block parameters pipes. 666 | Enabled: true 667 | VersionAdded: '0.49' 668 | EnforcedStyleInsidePipes: no_space 669 | SupportedStylesInsidePipes: 670 | - space 671 | - no_space 672 | 673 | # Supports --auto-correct 674 | Layout/SpaceAroundEqualsInParameterDefault: 675 | Description: Checks that the equals signs in parameter default assignments have or 676 | don't have surrounding space de on configuration. 677 | StyleGuide: "#spaces-around-equals" 678 | Enabled: true 679 | VersionAdded: '0.49' 680 | EnforcedStyle: space 681 | SupportedStyles: 682 | - space 683 | - no_space 684 | 685 | # Supports --auto-correct 686 | Layout/SpaceAroundKeyword: 687 | Description: Use a space around keywords if appropriate. 688 | Enabled: true 689 | VersionAdded: '0.49' 690 | 691 | # Supports --auto-correct 692 | Layout/SpaceAroundMethodCallOperator: 693 | Description: Checks method call operators to not have spaces around them. 694 | Enabled: true 695 | VersionAdded: '0.82' 696 | 697 | # Supports --auto-correct 698 | Layout/SpaceAroundOperators: 699 | Description: Use a single space around operators. 700 | StyleGuide: "#spaces-operators" 701 | Enabled: true 702 | VersionAdded: '0.49' 703 | AllowForAlignment: true 704 | EnforcedStyleForExponentOperator: no_space 705 | SupportedStylesForExponentOperator: 706 | - space 707 | - no_space 708 | 709 | # Supports --auto-correct 710 | Layout/SpaceBeforeBlockBraces: 711 | Description: Checks that the left block brace has or doesn't have space before it. 712 | Enabled: true 713 | VersionAdded: '0.49' 714 | EnforcedStyle: space 715 | SupportedStyles: 716 | - space 717 | - no_space 718 | EnforcedStyleForEmptyBraces: space 719 | SupportedStylesForEmptyBraces: 720 | - space 721 | - no_space 722 | VersionChanged: 0.52.1 723 | 724 | # Supports --auto-correct 725 | Layout/SpaceBeforeComma: 726 | Description: No spaces before commas. 727 | Enabled: true 728 | VersionAdded: '0.49' 729 | 730 | # Supports --auto-correct 731 | Layout/SpaceBeforeComment: 732 | Description: Checks for missing space between code and a comment on the same line. 733 | Enabled: true 734 | VersionAdded: '0.49' 735 | 736 | # Supports --auto-correct 737 | Layout/SpaceBeforeFirstArg: 738 | Description: Checks that exactly one space is used between a method name and the first 739 | argument for method calls without parentheses. 740 | Enabled: true 741 | VersionAdded: '0.49' 742 | AllowForAlignment: true 743 | 744 | # Supports --auto-correct 745 | Layout/SpaceBeforeSemicolon: 746 | Description: No spaces before semicolons. 747 | Enabled: true 748 | VersionAdded: '0.49' 749 | 750 | # Supports --auto-correct 751 | Layout/SpaceInLambdaLiteral: 752 | Description: Checks for spaces in lambda literals. 753 | Enabled: true 754 | VersionAdded: '0.49' 755 | EnforcedStyle: require_no_space 756 | SupportedStyles: 757 | - require_no_space 758 | - require_space 759 | 760 | # Supports --auto-correct 761 | Layout/SpaceInsideArrayLiteralBrackets: 762 | Description: Checks the spacing inside array literal brackets. 763 | Enabled: true 764 | VersionAdded: '0.52' 765 | EnforcedStyle: no_space 766 | SupportedStyles: 767 | - space 768 | - no_space 769 | - compact 770 | EnforcedStyleForEmptyBrackets: no_space 771 | SupportedStylesForEmptyBrackets: 772 | - space 773 | - no_space 774 | 775 | # Supports --auto-correct 776 | Layout/SpaceInsideArrayPercentLiteral: 777 | Description: No unnecessary additional spaces between elements in %i/%w literals. 778 | Enabled: true 779 | VersionAdded: '0.49' 780 | 781 | # Supports --auto-correct 782 | Layout/SpaceInsideBlockBraces: 783 | Description: Checks that block braces have or don't have surrounding space. For blocks 784 | taking parameters, checks that the left brace has or doesn't have trailing space. 785 | Enabled: true 786 | VersionAdded: '0.49' 787 | EnforcedStyle: space 788 | SupportedStyles: 789 | - space 790 | - no_space 791 | EnforcedStyleForEmptyBraces: no_space 792 | SupportedStylesForEmptyBraces: 793 | - space 794 | - no_space 795 | SpaceBeforeBlockParameters: true 796 | 797 | # Supports --auto-correct 798 | Layout/SpaceInsideHashLiteralBraces: 799 | Description: Use spaces inside hash literal braces - or don't. 800 | StyleGuide: "#spaces-braces" 801 | Enabled: true 802 | VersionAdded: '0.49' 803 | EnforcedStyle: space 804 | SupportedStyles: 805 | - space 806 | - no_space 807 | - compact 808 | EnforcedStyleForEmptyBraces: no_space 809 | SupportedStylesForEmptyBraces: 810 | - space 811 | - no_space 812 | 813 | # Supports --auto-correct 814 | Layout/SpaceInsideParens: 815 | Description: No spaces after ( or before ). 816 | StyleGuide: "#spaces-braces" 817 | Enabled: true 818 | VersionAdded: '0.49' 819 | VersionChanged: '0.55' 820 | EnforcedStyle: no_space 821 | SupportedStyles: 822 | - space 823 | - no_space 824 | 825 | # Supports --auto-correct 826 | Layout/SpaceInsidePercentLiteralDelimiters: 827 | Description: No unnecessary spaces inside delimiters of %i/%w/%x literals. 828 | Enabled: true 829 | VersionAdded: '0.49' 830 | 831 | # Supports --auto-correct 832 | Layout/SpaceInsideRangeLiteral: 833 | Description: No spaces inside range literals. 834 | StyleGuide: "#no-space-inside-range-literals" 835 | Enabled: true 836 | VersionAdded: '0.49' 837 | 838 | # Supports --auto-correct 839 | Layout/SpaceInsideReferenceBrackets: 840 | Description: Checks the spacing inside referential brackets. 841 | Enabled: true 842 | VersionAdded: '0.52' 843 | VersionChanged: '0.53' 844 | EnforcedStyle: no_space 845 | SupportedStyles: 846 | - space 847 | - no_space 848 | EnforcedStyleForEmptyBrackets: no_space 849 | SupportedStylesForEmptyBrackets: 850 | - space 851 | - no_space 852 | 853 | # Supports --auto-correct 854 | Layout/SpaceInsideStringInterpolation: 855 | Description: Checks for padding/surrounding spaces inside string interpolation. 856 | StyleGuide: "#string-interpolation" 857 | Enabled: true 858 | VersionAdded: '0.49' 859 | EnforcedStyle: no_space 860 | SupportedStyles: 861 | - space 862 | - no_space 863 | 864 | # Supports --auto-correct 865 | Layout/TrailingEmptyLines: 866 | Description: Checks trailing blank lines and final newline. 867 | StyleGuide: "#newline-eof" 868 | Enabled: true 869 | VersionAdded: '0.49' 870 | VersionChanged: '0.77' 871 | EnforcedStyle: final_newline 872 | SupportedStyles: 873 | - final_newline 874 | - final_blank_line 875 | 876 | # Supports --auto-correct 877 | Layout/TrailingWhitespace: 878 | Description: Avoid trailing whitespace. 879 | StyleGuide: "#no-trailing-whitespace" 880 | Enabled: true 881 | VersionAdded: '0.49' 882 | VersionChanged: '0.83' 883 | AllowInHeredoc: true 884 | 885 | # Department 'Lint' (104): 886 | Lint/AmbiguousBlockAssociation: 887 | Description: Checks for ambiguous block association with method when param passed 888 | without parentheses. 889 | StyleGuide: "#syntax" 890 | Enabled: true 891 | VersionAdded: '0.48' 892 | 893 | # Supports --auto-correct 894 | Lint/AmbiguousOperator: 895 | Description: Checks for ambiguous operators in the first argument of a method invocation 896 | without parentheses. 897 | StyleGuide: "#method-invocation-parens" 898 | Enabled: true 899 | VersionAdded: '0.17' 900 | VersionChanged: '0.83' 901 | 902 | # Supports --auto-correct 903 | Lint/AmbiguousRegexpLiteral: 904 | Description: Checks for ambiguous regexp literals in the first argument of a method 905 | invocation without parentheses. 906 | Enabled: true 907 | VersionAdded: '0.17' 908 | VersionChanged: '0.83' 909 | 910 | Lint/AssignmentInCondition: 911 | Description: Don't use assignment in conditions. 912 | StyleGuide: "#safe-assignment-in-condition" 913 | Enabled: true 914 | VersionAdded: '0.9' 915 | AllowSafeAssignment: true 916 | 917 | # Supports --auto-correct 918 | Lint/BigDecimalNew: 919 | Description: "`BigDecimal.new()` is deprecated. Use `BigDecimal()` instead." 920 | Enabled: true 921 | VersionAdded: '0.53' 922 | 923 | Lint/BinaryOperatorWithIdenticalOperands: 924 | Description: This cop checks for places where binary operator has identical operands. 925 | Enabled: true 926 | Safe: false 927 | VersionAdded: '0.89' 928 | 929 | # Supports --auto-correct 930 | Lint/BooleanSymbol: 931 | Description: Check for `:true` and `:false` symbols. 932 | Enabled: true 933 | VersionAdded: '0.50' 934 | VersionChanged: '0.83' 935 | 936 | Lint/CircularArgumentReference: 937 | Description: Default values in optional keyword arguments and optional ordinal arguments 938 | should not refer back to the name of the argument. 939 | Enabled: true 940 | VersionAdded: '0.33' 941 | 942 | Lint/ConstantDefinitionInBlock: 943 | Description: Do not define constants within a block. 944 | StyleGuide: "#no-constant-definition-in-block" 945 | Enabled: true 946 | VersionAdded: '0.91' 947 | 948 | Lint/Debugger: 949 | Description: Check for debugger calls. 950 | Enabled: true 951 | VersionAdded: '0.14' 952 | VersionChanged: '0.49' 953 | Exclude: 954 | - test/examples/*.rb 955 | 956 | # Supports --auto-correct 957 | Lint/DeprecatedClassMethods: 958 | Description: Check for deprecated class method calls. 959 | Enabled: true 960 | VersionAdded: '0.19' 961 | 962 | # Supports --auto-correct 963 | Lint/DeprecatedOpenSSLConstant: 964 | Description: Don't use algorithm constants for `OpenSSL::Cipher` and `OpenSSL::Digest`. 965 | Enabled: true 966 | VersionAdded: '0.84' 967 | 968 | # Supports --auto-correct 969 | Lint/DisjunctiveAssignmentInConstructor: 970 | Description: In constructor, plain assignment is preferred over disjunctive. 971 | Enabled: true 972 | Safe: false 973 | VersionAdded: '0.62' 974 | VersionChanged: '0.88' 975 | 976 | Lint/DuplicateCaseCondition: 977 | Description: Do not repeat values in case conditionals. 978 | Enabled: true 979 | VersionAdded: '0.45' 980 | 981 | Lint/DuplicateElsifCondition: 982 | Description: Do not repeat conditions used in if `elsif`. 983 | Enabled: true 984 | VersionAdded: '0.88' 985 | 986 | Lint/DuplicateHashKey: 987 | Description: Check for duplicate keys in hash literals. 988 | Enabled: true 989 | VersionAdded: '0.34' 990 | VersionChanged: '0.77' 991 | 992 | Lint/DuplicateMethods: 993 | Description: Check for duplicate method definitions. 994 | Enabled: true 995 | VersionAdded: '0.29' 996 | 997 | Lint/DuplicateRequire: 998 | Description: Check for duplicate `require`s and `require_relative`s. 999 | Enabled: true 1000 | VersionAdded: '0.90' 1001 | 1002 | Lint/DuplicateRescueException: 1003 | Description: Checks that there are no repeated exceptions used in `rescue` expressions. 1004 | Enabled: true 1005 | VersionAdded: '0.89' 1006 | 1007 | Lint/EachWithObjectArgument: 1008 | Description: Check for immutable argument given to each_with_object. 1009 | Enabled: true 1010 | VersionAdded: '0.31' 1011 | 1012 | Lint/ElseLayout: 1013 | Description: Check for odd code arrangement in an else block. 1014 | Enabled: true 1015 | VersionAdded: '0.17' 1016 | 1017 | Lint/EmptyConditionalBody: 1018 | Description: This cop checks for the presence of `if`, `elsif` and `unless` branches 1019 | without a body. 1020 | Enabled: true 1021 | AllowComments: true 1022 | VersionAdded: '0.89' 1023 | 1024 | # Supports --auto-correct 1025 | Lint/EmptyEnsure: 1026 | Description: Checks for empty ensure block. 1027 | Enabled: true 1028 | VersionAdded: '0.10' 1029 | VersionChanged: '0.48' 1030 | 1031 | Lint/EmptyExpression: 1032 | Description: Checks for empty expressions. 1033 | Enabled: true 1034 | VersionAdded: '0.45' 1035 | 1036 | Lint/EmptyFile: 1037 | Description: Enforces that Ruby source files are not empty. 1038 | Enabled: true 1039 | AllowComments: true 1040 | VersionAdded: '0.90' 1041 | 1042 | # Supports --auto-correct 1043 | Lint/EmptyInterpolation: 1044 | Description: Checks for empty string interpolation. 1045 | Enabled: true 1046 | VersionAdded: '0.20' 1047 | VersionChanged: '0.45' 1048 | 1049 | Lint/EmptyWhen: 1050 | Description: Checks for `when` branches with empty bodies. 1051 | Enabled: true 1052 | AllowComments: true 1053 | VersionAdded: '0.45' 1054 | VersionChanged: '0.83' 1055 | 1056 | # Supports --auto-correct 1057 | Lint/EnsureReturn: 1058 | Description: Do not use return in an ensure block. 1059 | StyleGuide: "#no-return-ensure" 1060 | Enabled: true 1061 | VersionAdded: '0.9' 1062 | VersionChanged: '0.83' 1063 | 1064 | # Supports --auto-correct 1065 | Lint/ErbNewArguments: 1066 | Description: Use `:trim_mode` and `:eoutvar` keyword arguments to `ERB.new`. 1067 | Enabled: true 1068 | VersionAdded: '0.56' 1069 | 1070 | Lint/FlipFlop: 1071 | Description: Checks for flip-flops. 1072 | StyleGuide: "#no-flip-flops" 1073 | Enabled: true 1074 | VersionAdded: '0.16' 1075 | 1076 | Lint/FloatComparison: 1077 | Description: Checks for the presence of precise comparison of floating point numbers. 1078 | StyleGuide: "#float-comparison" 1079 | Enabled: true 1080 | VersionAdded: '0.89' 1081 | 1082 | Lint/FloatOutOfRange: 1083 | Description: Catches floating-point literals too large or small for Ruby to represent. 1084 | Enabled: true 1085 | VersionAdded: '0.36' 1086 | 1087 | Lint/FormatParameterMismatch: 1088 | Description: The number of parameters to format/sprint must match the fields. 1089 | Enabled: true 1090 | VersionAdded: '0.33' 1091 | 1092 | Lint/HashCompareByIdentity: 1093 | Description: Prefer using `Hash#compare_by_identity` than using `object_id` for keys. 1094 | StyleGuide: "#identity-comparison" 1095 | Enabled: true 1096 | Safe: false 1097 | VersionAdded: '0.93' 1098 | 1099 | # Supports --auto-correct 1100 | Lint/IdentityComparison: 1101 | Description: Prefer `equal?` over `==` when comparing `object_id`. 1102 | Enabled: true 1103 | StyleGuide: "#identity-comparison" 1104 | VersionAdded: '0.91' 1105 | 1106 | Lint/ImplicitStringConcatenation: 1107 | Description: Checks for adjacent string literals on the same line, which could better 1108 | be represented as a single string literal. 1109 | Enabled: true 1110 | VersionAdded: '0.36' 1111 | 1112 | Lint/IneffectiveAccessModifier: 1113 | Description: Checks for attempts to use `private` or `protected` to set the visibility 1114 | of a class method, which does not work. 1115 | Enabled: true 1116 | VersionAdded: '0.36' 1117 | 1118 | # Supports --auto-correct 1119 | Lint/InheritException: 1120 | Description: Avoid inheriting from the `Exception` class. 1121 | Enabled: true 1122 | VersionAdded: '0.41' 1123 | EnforcedStyle: runtime_error 1124 | SupportedStyles: 1125 | - runtime_error 1126 | - standard_error 1127 | 1128 | # Supports --auto-correct 1129 | Lint/InterpolationCheck: 1130 | Description: Raise warning for interpolation in single q strs. 1131 | Enabled: true 1132 | VersionAdded: '0.50' 1133 | VersionChanged: '0.87' 1134 | 1135 | Lint/LiteralAsCondition: 1136 | Description: Checks of literals used in conditions. 1137 | Enabled: true 1138 | VersionAdded: '0.51' 1139 | 1140 | # Supports --auto-correct 1141 | Lint/LiteralInInterpolation: 1142 | Description: Checks for literals used in interpolation. 1143 | Enabled: true 1144 | VersionAdded: '0.19' 1145 | VersionChanged: '0.32' 1146 | 1147 | # Supports --auto-correct 1148 | Lint/Loop: 1149 | Description: Use Kernel#loop with break rather than begin/end/until or begin/end/while 1150 | for post-loop tests. 1151 | StyleGuide: "#loop-with-break" 1152 | Enabled: true 1153 | VersionAdded: '0.9' 1154 | VersionChanged: '0.89' 1155 | 1156 | Lint/MissingCopEnableDirective: 1157 | Description: Checks for a `# rubocop:enable` after `# rubocop:disable`. 1158 | Enabled: true 1159 | VersionAdded: '0.52' 1160 | MaximumRangeSize: .inf 1161 | 1162 | Lint/MixedRegexpCaptureTypes: 1163 | Description: Do not mix named captures and numbered captures in a Regexp literal. 1164 | Enabled: true 1165 | VersionAdded: '0.85' 1166 | 1167 | # Supports --auto-correct 1168 | Lint/MultipleComparison: 1169 | Description: Use `&&` operator to compare multiple values. 1170 | Enabled: true 1171 | VersionAdded: '0.47' 1172 | VersionChanged: '0.77' 1173 | 1174 | Lint/NestedMethodDefinition: 1175 | Description: Do not use nested method definitions. 1176 | StyleGuide: "#no-nested-methods" 1177 | Enabled: true 1178 | VersionAdded: '0.32' 1179 | 1180 | Lint/NestedPercentLiteral: 1181 | Description: Checks for nested percent literals. 1182 | Enabled: true 1183 | VersionAdded: '0.52' 1184 | 1185 | Lint/NextWithoutAccumulator: 1186 | Description: Do not omit the accumulator when calling `next` in a `reduce`/`inject` 1187 | block. 1188 | Enabled: true 1189 | VersionAdded: '0.36' 1190 | 1191 | # Supports --auto-correct 1192 | Lint/NonDeterministicRequireOrder: 1193 | Description: Always sort arrays returned by Dir.glob when requiring files. 1194 | Enabled: true 1195 | VersionAdded: '0.78' 1196 | Safe: false 1197 | 1198 | Lint/NonLocalExitFromIterator: 1199 | Description: Do not use return in iterator to cause non-local exit. 1200 | Enabled: true 1201 | VersionAdded: '0.30' 1202 | 1203 | # Supports --auto-correct 1204 | Lint/OrderedMagicComments: 1205 | Description: Checks the proper ordering of magic comments and whether a magic comment 1206 | is not placed before a shebang. 1207 | Enabled: true 1208 | VersionAdded: '0.53' 1209 | 1210 | Lint/OutOfRangeRegexpRef: 1211 | Description: Checks for out of range reference for Regexp because it always returns 1212 | nil. 1213 | Enabled: true 1214 | Safe: false 1215 | VersionAdded: '0.89' 1216 | 1217 | # Supports --auto-correct 1218 | Lint/ParenthesesAsGroupedExpression: 1219 | Description: Checks for method calls with a space before the opening parenthesis. 1220 | StyleGuide: "#parens-no-spaces" 1221 | Enabled: true 1222 | VersionAdded: '0.12' 1223 | VersionChanged: '0.83' 1224 | 1225 | # Supports --auto-correct 1226 | Lint/PercentStringArray: 1227 | Description: Checks for unwanted commas and quotes in %w/%W literals. 1228 | Enabled: true 1229 | Safe: false 1230 | VersionAdded: '0.41' 1231 | 1232 | # Supports --auto-correct 1233 | Lint/PercentSymbolArray: 1234 | Description: Checks for unwanted commas and colons in %i/%I literals. 1235 | Enabled: true 1236 | VersionAdded: '0.41' 1237 | 1238 | # Supports --auto-correct 1239 | Lint/RaiseException: 1240 | Description: Checks for `raise` or `fail` statements which are raising `Exception` 1241 | class. 1242 | StyleGuide: "#raise-exception" 1243 | Enabled: true 1244 | Safe: false 1245 | VersionAdded: '0.81' 1246 | VersionChanged: '0.86' 1247 | AllowedImplicitNamespaces: 1248 | - Gem 1249 | 1250 | Lint/RandOne: 1251 | Description: Checks for `rand(1)` calls. Such calls always return `0` and most likely 1252 | a mistake. 1253 | Enabled: true 1254 | VersionAdded: '0.36' 1255 | 1256 | # Supports --auto-correct 1257 | Lint/RedundantCopDisableDirective: 1258 | Description: 'Checks for rubocop:disable comments that can be removed. Note: this 1259 | cop is not disabled when disabling all cops. It must be explicitly disabled.' 1260 | Enabled: true 1261 | VersionAdded: '0.76' 1262 | 1263 | # Supports --auto-correct 1264 | Lint/RedundantCopEnableDirective: 1265 | Description: Checks for rubocop:enable comments that can be removed. 1266 | Enabled: true 1267 | VersionAdded: '0.76' 1268 | 1269 | # Supports --auto-correct 1270 | Lint/RedundantRequireStatement: 1271 | Description: Checks for unnecessary `require` statement. 1272 | Enabled: true 1273 | VersionAdded: '0.76' 1274 | 1275 | # Supports --auto-correct 1276 | Lint/RedundantSafeNavigation: 1277 | Description: Checks for redundant safe navigation calls. 1278 | Enabled: true 1279 | VersionAdded: '0.93' 1280 | AllowedMethods: 1281 | - instance_of? 1282 | - kind_of? 1283 | - is_a? 1284 | - eql? 1285 | - respond_to? 1286 | - equal? 1287 | Safe: false 1288 | 1289 | # Supports --auto-correct 1290 | Lint/RedundantSplatExpansion: 1291 | Description: Checks for splat unnecessarily being called on literals. 1292 | Enabled: true 1293 | VersionAdded: '0.76' 1294 | 1295 | # Supports --auto-correct 1296 | Lint/RedundantStringCoercion: 1297 | Description: Checks for Object#to_s usage in string interpolation. 1298 | StyleGuide: "#no-to-s" 1299 | Enabled: true 1300 | VersionAdded: '0.19' 1301 | VersionChanged: '0.77' 1302 | 1303 | # Supports --auto-correct 1304 | Lint/RedundantWithIndex: 1305 | Description: Checks for redundant `with_index`. 1306 | Enabled: true 1307 | VersionAdded: '0.50' 1308 | 1309 | # Supports --auto-correct 1310 | Lint/RedundantWithObject: 1311 | Description: Checks for redundant `with_object`. 1312 | Enabled: true 1313 | VersionAdded: '0.51' 1314 | 1315 | # Supports --auto-correct 1316 | Lint/RegexpAsCondition: 1317 | Description: Do not use regexp literal as a condition. The regexp literal matches 1318 | `$_` implicitly. 1319 | Enabled: true 1320 | VersionAdded: '0.51' 1321 | VersionChanged: '0.86' 1322 | 1323 | Lint/RequireParentheses: 1324 | Description: Use parentheses in the method call to avoid confusion about precedence. 1325 | Enabled: true 1326 | VersionAdded: '0.18' 1327 | 1328 | Lint/RescueException: 1329 | Description: Avoid rescuing the Exception class. 1330 | StyleGuide: "#no-blind-rescues" 1331 | Enabled: true 1332 | VersionAdded: '0.9' 1333 | VersionChanged: 0.27.1 1334 | 1335 | # Supports --auto-correct 1336 | Lint/RescueType: 1337 | Description: Avoid rescuing from non constants that could result in a `TypeError`. 1338 | Enabled: true 1339 | VersionAdded: '0.49' 1340 | 1341 | Lint/ReturnInVoidContext: 1342 | Description: Checks for return in void context. 1343 | Enabled: true 1344 | VersionAdded: '0.50' 1345 | 1346 | Lint/SafeNavigationChain: 1347 | Description: Do not chain ordinary method call after safe navigation operator. 1348 | Enabled: true 1349 | VersionAdded: '0.47' 1350 | VersionChanged: '0.77' 1351 | AllowedMethods: 1352 | - present? 1353 | - blank? 1354 | - presence 1355 | - try 1356 | - try! 1357 | - in? 1358 | 1359 | # Supports --auto-correct 1360 | Lint/SafeNavigationConsistency: 1361 | Description: Check to make sure that if safe navigation is used for a method call 1362 | in an `&&` or `||` condition that safe navigation is used for all method calls on 1363 | that same object. 1364 | Enabled: true 1365 | VersionAdded: '0.55' 1366 | VersionChanged: '0.77' 1367 | AllowedMethods: 1368 | - present? 1369 | - blank? 1370 | - presence 1371 | - try 1372 | - try! 1373 | 1374 | # Supports --auto-correct 1375 | Lint/SafeNavigationWithEmpty: 1376 | Description: Avoid `foo&.empty?` in conditionals. 1377 | Enabled: true 1378 | VersionAdded: '0.62' 1379 | VersionChanged: '0.87' 1380 | 1381 | # Supports --auto-correct 1382 | Lint/ScriptPermission: 1383 | Description: Grant script file execute permission. 1384 | Enabled: true 1385 | VersionAdded: '0.49' 1386 | VersionChanged: '0.50' 1387 | 1388 | Lint/SelfAssignment: 1389 | Description: Checks for self-assignments. 1390 | Enabled: true 1391 | VersionAdded: '0.89' 1392 | 1393 | # Supports --auto-correct 1394 | Lint/SendWithMixinArgument: 1395 | Description: Checks for `send` method when using mixin. 1396 | Enabled: true 1397 | VersionAdded: '0.75' 1398 | 1399 | Lint/ShadowedArgument: 1400 | Description: Avoid reassigning arguments before they were used. 1401 | Enabled: true 1402 | VersionAdded: '0.52' 1403 | IgnoreImplicitReferences: false 1404 | 1405 | Lint/ShadowedException: 1406 | Description: Avoid rescuing a higher level exception before a lower level exception. 1407 | Enabled: true 1408 | VersionAdded: '0.41' 1409 | 1410 | Lint/ShadowingOuterLocalVariable: 1411 | Description: Do not use the same name as outer local variable for block arguments 1412 | or block local variables. 1413 | Enabled: true 1414 | VersionAdded: '0.9' 1415 | 1416 | Lint/StructNewOverride: 1417 | Description: Disallow overriding the `Struct` built-in methods via `Struct.new`. 1418 | Enabled: true 1419 | VersionAdded: '0.81' 1420 | 1421 | Lint/SuppressedException: 1422 | Description: Don't suppress exceptions. 1423 | StyleGuide: "#dont-hide-exceptions" 1424 | Enabled: true 1425 | AllowComments: true 1426 | VersionAdded: '0.9' 1427 | VersionChanged: '0.81' 1428 | 1429 | # Supports --auto-correct 1430 | Lint/ToJSON: 1431 | Description: 'Ensure #to_json includes an optional argument.' 1432 | Enabled: true 1433 | VersionAdded: '0.66' 1434 | 1435 | Lint/TopLevelReturnWithArgument: 1436 | Description: This cop detects top level return statements with argument. 1437 | Enabled: true 1438 | VersionAdded: '0.89' 1439 | 1440 | # Supports --auto-correct 1441 | Lint/TrailingCommaInAttributeDeclaration: 1442 | Description: This cop checks for trailing commas in attribute declarations. 1443 | Enabled: true 1444 | VersionAdded: '0.90' 1445 | 1446 | Lint/UnderscorePrefixedVariableName: 1447 | Description: Do not use prefix `_` for a variable that is used. 1448 | Enabled: true 1449 | VersionAdded: '0.21' 1450 | AllowKeywordBlockArguments: false 1451 | 1452 | # Supports --auto-correct 1453 | Lint/UnifiedInteger: 1454 | Description: Use Integer instead of Fixnum or Bignum. 1455 | Enabled: true 1456 | VersionAdded: '0.43' 1457 | 1458 | Lint/UnreachableCode: 1459 | Description: Unreachable code. 1460 | Enabled: true 1461 | VersionAdded: '0.9' 1462 | 1463 | Lint/UnreachableLoop: 1464 | Description: This cop checks for loops that will have at most one iteration. 1465 | Enabled: true 1466 | VersionAdded: '0.89' 1467 | 1468 | # Supports --auto-correct 1469 | Lint/UnusedBlockArgument: 1470 | Description: Checks for unused block arguments. 1471 | StyleGuide: "#underscore-unused-vars" 1472 | Enabled: true 1473 | VersionAdded: '0.21' 1474 | VersionChanged: '0.22' 1475 | IgnoreEmptyBlocks: true 1476 | AllowUnusedKeywordArguments: false 1477 | 1478 | # Supports --auto-correct 1479 | Lint/UnusedMethodArgument: 1480 | Description: Checks for unused method arguments. 1481 | StyleGuide: "#underscore-unused-vars" 1482 | Enabled: true 1483 | VersionAdded: '0.21' 1484 | VersionChanged: '0.81' 1485 | AllowUnusedKeywordArguments: false 1486 | IgnoreEmptyMethods: true 1487 | IgnoreNotImplementedMethods: true 1488 | 1489 | Lint/UriEscapeUnescape: 1490 | Description: "`URI.escape` method is obsolete and should not be used. Instead, use 1491 | `CGI.escape`, `URI.encode_www_form` or `URI.encode_www_form_component` de 1492 | on your specific use case. Also `URI.unescape` method is obsolete and should not 1493 | be used. Instead, use `CGI.unescape`, `URI.decode_www_form` or `URI.decode_www_form_component` 1494 | de on your specific use case." 1495 | Enabled: true 1496 | VersionAdded: '0.50' 1497 | 1498 | # Supports --auto-correct 1499 | Lint/UriRegexp: 1500 | Description: Use `URI::DEFAULT_PARSER.make_regexp` instead of `URI.regexp`. 1501 | Enabled: true 1502 | VersionAdded: '0.50' 1503 | 1504 | # Supports --auto-correct 1505 | Lint/UselessAccessModifier: 1506 | Description: Checks for useless access modifiers. 1507 | Enabled: true 1508 | VersionAdded: '0.20' 1509 | VersionChanged: '0.83' 1510 | ContextCreatingMethods: [] 1511 | MethodCreatingMethods: [] 1512 | 1513 | Lint/UselessAssignment: 1514 | Description: Checks for useless assignment to a local variable. 1515 | StyleGuide: "#underscore-unused-vars" 1516 | Enabled: true 1517 | VersionAdded: '0.11' 1518 | 1519 | Lint/UselessElseWithoutRescue: 1520 | Description: Checks for useless `else` in `begin..end` without `rescue`. 1521 | Enabled: true 1522 | VersionAdded: '0.17' 1523 | 1524 | # Supports --auto-correct 1525 | Lint/UselessMethodDefinition: 1526 | Description: Checks for useless method definitions. 1527 | Enabled: true 1528 | VersionAdded: '0.90' 1529 | Safe: false 1530 | 1531 | Lint/UselessSetterCall: 1532 | Description: Checks for useless setter call to a local variable. 1533 | Enabled: true 1534 | VersionAdded: '0.13' 1535 | VersionChanged: '0.80' 1536 | Safe: false 1537 | 1538 | # Supports --auto-correct 1539 | Lint/UselessTimes: 1540 | Description: Checks for useless `Integer#times` calls. 1541 | Enabled: true 1542 | VersionAdded: '0.91' 1543 | Safe: false 1544 | 1545 | Lint/Void: 1546 | Description: Possible use of operator/literal/variable in void context. 1547 | Enabled: true 1548 | VersionAdded: '0.9' 1549 | CheckForMethodsWithNoSideEffects: false 1550 | 1551 | # Department 'Migration' (1): 1552 | # Supports --auto-correct 1553 | Migration/DepartmentName: 1554 | Description: Check that cop names in rubocop:disable (etc) comments are given with 1555 | department name. 1556 | Enabled: true 1557 | VersionAdded: '0.75' 1558 | 1559 | # Department 'Naming' (16): 1560 | Naming/AccessorMethodName: 1561 | Description: Check the naming of accessor methods for get_/set_. 1562 | StyleGuide: "#accessor_mutator_method_names" 1563 | Enabled: true 1564 | VersionAdded: '0.50' 1565 | 1566 | Naming/AsciiIdentifiers: 1567 | Description: Use only ascii symbols in identifiers and constants. 1568 | StyleGuide: "#english-identifiers" 1569 | Enabled: true 1570 | VersionAdded: '0.50' 1571 | VersionChanged: '0.87' 1572 | AsciiConstants: true 1573 | 1574 | Naming/BinaryOperatorParameterName: 1575 | Description: When defining binary operators, name the argument other. 1576 | StyleGuide: "#other-arg" 1577 | Enabled: true 1578 | VersionAdded: '0.50' 1579 | 1580 | Naming/BlockParameterName: 1581 | Description: Checks for block parameter names that contain capital letters, end in 1582 | numbers, or do not meet a minimal length. 1583 | Enabled: true 1584 | VersionAdded: '0.53' 1585 | VersionChanged: '0.77' 1586 | MinNameLength: 1 1587 | AllowNamesEndingInNumbers: true 1588 | AllowedNames: [] 1589 | ForbiddenNames: [] 1590 | 1591 | Naming/ClassAndModuleCamelCase: 1592 | Description: Use CamelCase for classes and modules. 1593 | StyleGuide: "#camelcase-classes" 1594 | Enabled: true 1595 | VersionAdded: '0.50' 1596 | VersionChanged: '0.85' 1597 | AllowedNames: 1598 | - module_parent 1599 | 1600 | Naming/ConstantName: 1601 | Description: Constants should use SCREAMING_SNAKE_CASE. 1602 | StyleGuide: "#screaming-snake-case" 1603 | Enabled: true 1604 | VersionAdded: '0.50' 1605 | 1606 | Naming/FileName: 1607 | Description: Use snake_case for source file names. 1608 | StyleGuide: "#snake-case-files" 1609 | Enabled: true 1610 | VersionAdded: '0.50' 1611 | Exclude: 1612 | - lib/pry-byebug.rb 1613 | - pry-byebug.gemspec 1614 | ExpectMatchingDefinition: false 1615 | CheckDefinitionPathHierarchy: true 1616 | Regex: 1617 | IgnoreExecutableScripts: true 1618 | AllowedAcronyms: 1619 | - CLI 1620 | - DSL 1621 | - ACL 1622 | - API 1623 | - ASCII 1624 | - CPU 1625 | - CSS 1626 | - DNS 1627 | - EOF 1628 | - GUID 1629 | - HTML 1630 | - HTTP 1631 | - HTTPS 1632 | - ID 1633 | - IP 1634 | - JSON 1635 | - LHS 1636 | - QPS 1637 | - RAM 1638 | - RHS 1639 | - RPC 1640 | - SLA 1641 | - SMTP 1642 | - SQL 1643 | - SSH 1644 | - TCP 1645 | - TLS 1646 | - TTL 1647 | - UDP 1648 | - UI 1649 | - UID 1650 | - UUID 1651 | - URI 1652 | - URL 1653 | - UTF8 1654 | - VM 1655 | - XML 1656 | - XMPP 1657 | - XSRF 1658 | - XSS 1659 | 1660 | Naming/HeredocDelimiterCase: 1661 | Description: Use configured case for heredoc delimiters. 1662 | StyleGuide: "#heredoc-delimiters" 1663 | Enabled: true 1664 | VersionAdded: '0.50' 1665 | EnforcedStyle: uppercase 1666 | SupportedStyles: 1667 | - lowercase 1668 | - uppercase 1669 | 1670 | Naming/HeredocDelimiterNaming: 1671 | Description: Use descriptive heredoc delimiters. 1672 | StyleGuide: "#heredoc-delimiters" 1673 | Enabled: true 1674 | VersionAdded: '0.50' 1675 | ForbiddenDelimiters: 1676 | - !ruby/regexp /(^|\s)(EO[A-Z]{1}|END)(\s|$)/ 1677 | 1678 | Naming/MemoizedInstanceVariableName: 1679 | Description: Memoized method name should match memo instance variable name. 1680 | Enabled: true 1681 | VersionAdded: '0.53' 1682 | VersionChanged: '0.58' 1683 | EnforcedStyleForLeadingUnderscores: disallowed 1684 | SupportedStylesForLeadingUnderscores: 1685 | - disallowed 1686 | - required 1687 | - optional 1688 | 1689 | Naming/MethodName: 1690 | Description: Use the configured style when naming methods. 1691 | StyleGuide: "#snake-case-symbols-methods-vars" 1692 | Enabled: true 1693 | VersionAdded: '0.50' 1694 | EnforcedStyle: snake_case 1695 | SupportedStyles: 1696 | - snake_case 1697 | - camelCase 1698 | AllowedPatterns: [] 1699 | 1700 | Naming/MethodParameterName: 1701 | Description: Checks for method parameter names that contain capital letters, end in 1702 | numbers, or do not meet a minimal length. 1703 | Enabled: true 1704 | VersionAdded: '0.53' 1705 | VersionChanged: '0.77' 1706 | MinNameLength: 3 1707 | AllowNamesEndingInNumbers: true 1708 | AllowedNames: 1709 | - at 1710 | - by 1711 | - db 1712 | - id 1713 | - in 1714 | - io 1715 | - ip 1716 | - of 1717 | - 'on' 1718 | - os 1719 | - pp 1720 | - to 1721 | ForbiddenNames: [] 1722 | 1723 | Naming/PredicateName: 1724 | Description: Check the names of predicate methods. 1725 | StyleGuide: "#bool-methods-qmark" 1726 | Enabled: true 1727 | VersionAdded: '0.50' 1728 | VersionChanged: '0.77' 1729 | NamePrefix: 1730 | - is_ 1731 | - has_ 1732 | - have_ 1733 | ForbiddenPrefixes: 1734 | - is_ 1735 | - has_ 1736 | - have_ 1737 | AllowedMethods: 1738 | - is_a? 1739 | MethodDefinitionMacros: 1740 | - define_method 1741 | - define_singleton_method 1742 | Exclude: 1743 | - "spec/**/*" 1744 | 1745 | # Supports --auto-correct 1746 | Naming/RescuedExceptionsVariableName: 1747 | Description: Use consistent rescued exceptions variables naming. 1748 | Enabled: true 1749 | VersionAdded: '0.67' 1750 | VersionChanged: '0.68' 1751 | PreferredName: e 1752 | 1753 | Naming/VariableName: 1754 | Description: Use the configured style when naming variables. 1755 | StyleGuide: "#snake-case-symbols-methods-vars" 1756 | Enabled: true 1757 | VersionAdded: '0.50' 1758 | EnforcedStyle: snake_case 1759 | SupportedStyles: 1760 | - snake_case 1761 | - camelCase 1762 | 1763 | Naming/VariableNumber: 1764 | Description: Use the configured style when numbering variables. 1765 | Enabled: true 1766 | VersionAdded: '0.50' 1767 | EnforcedStyle: normalcase 1768 | SupportedStyles: 1769 | - snake_case 1770 | - normalcase 1771 | - non_integer 1772 | 1773 | # Department 'Security' (5): 1774 | Security/Eval: 1775 | Description: The use of eval represents a serious security risk. 1776 | Enabled: true 1777 | VersionAdded: '0.47' 1778 | 1779 | # Supports --auto-correct 1780 | Security/JSONLoad: 1781 | Description: Prefer usage of `JSON.parse` over `JSON.load` due to potential security 1782 | issues. See reference for more information. 1783 | Reference: https://ruby-doc.org/stdlib-2.7.0/libdoc/json/rdoc/JSON.html#method-i-load 1784 | Enabled: true 1785 | VersionAdded: '0.43' 1786 | VersionChanged: '0.44' 1787 | AutoCorrect: false 1788 | SafeAutoCorrect: false 1789 | 1790 | Security/MarshalLoad: 1791 | Description: Avoid using of `Marshal.load` or `Marshal.restore` due to potential security 1792 | issues. See reference for more information. 1793 | Reference: https://ruby-doc.org/core-2.7.0/Marshal.html#module-Marshal-label-Security+considerations 1794 | Enabled: true 1795 | VersionAdded: '0.47' 1796 | 1797 | Security/Open: 1798 | Description: The use of Kernel#open represents a serious security risk. 1799 | Enabled: true 1800 | VersionAdded: '0.53' 1801 | Safe: false 1802 | 1803 | # Supports --auto-correct 1804 | Security/YAMLLoad: 1805 | Description: Prefer usage of `YAML.safe_load` over `YAML.load` due to potential security 1806 | issues. See reference for more information. 1807 | Reference: https://ruby-doc.org/stdlib-2.7.0/libdoc/yaml/rdoc/YAML.html#module-YAML-label-Security 1808 | Enabled: true 1809 | VersionAdded: '0.47' 1810 | SafeAutoCorrect: false 1811 | 1812 | # Department 'Style' (197): 1813 | Style/AccessModifierDeclarations: 1814 | Description: Checks style of how access modifiers are used. 1815 | Enabled: true 1816 | VersionAdded: '0.57' 1817 | VersionChanged: '0.81' 1818 | EnforcedStyle: group 1819 | SupportedStyles: 1820 | - inline 1821 | - group 1822 | AllowModifiersOnSymbols: true 1823 | 1824 | # Supports --auto-correct 1825 | Style/AccessorGrouping: 1826 | Description: Checks for grouping of accessors in `class` and `module` bodies. 1827 | Enabled: true 1828 | VersionAdded: '0.87' 1829 | EnforcedStyle: grouped 1830 | SupportedStyles: 1831 | - separated 1832 | - grouped 1833 | 1834 | # Supports --auto-correct 1835 | Style/Alias: 1836 | Description: Use alias instead of alias_method. 1837 | StyleGuide: "#alias-method-lexically" 1838 | Enabled: true 1839 | VersionAdded: '0.9' 1840 | VersionChanged: '0.36' 1841 | EnforcedStyle: prefer_alias 1842 | SupportedStyles: 1843 | - prefer_alias 1844 | - prefer_alias_method 1845 | 1846 | # Supports --auto-correct 1847 | Style/AndOr: 1848 | Description: Use &&/|| instead of and/or. 1849 | StyleGuide: "#no-and-or-or" 1850 | Enabled: true 1851 | VersionAdded: '0.9' 1852 | VersionChanged: '0.25' 1853 | EnforcedStyle: conditionals 1854 | SupportedStyles: 1855 | - always 1856 | - conditionals 1857 | 1858 | # Supports --auto-correct 1859 | Style/ArrayJoin: 1860 | Description: Use Array#join instead of Array#*. 1861 | StyleGuide: "#array-join" 1862 | Enabled: true 1863 | VersionAdded: '0.20' 1864 | VersionChanged: '0.31' 1865 | 1866 | Style/AsciiComments: 1867 | Description: Use only ascii symbols in comments. 1868 | StyleGuide: "#english-comments" 1869 | Enabled: true 1870 | VersionAdded: '0.9' 1871 | VersionChanged: '0.52' 1872 | AllowedChars: [] 1873 | 1874 | # Supports --auto-correct 1875 | Style/Attr: 1876 | Description: Checks for uses of Module#attr. 1877 | StyleGuide: "#attr" 1878 | Enabled: true 1879 | VersionAdded: '0.9' 1880 | VersionChanged: '0.12' 1881 | 1882 | # Supports --auto-correct 1883 | Style/BarePercentLiterals: 1884 | Description: Checks if usage of %() or %Q() matches configuration. 1885 | StyleGuide: "#percent-q-shorthand" 1886 | Enabled: true 1887 | VersionAdded: '0.25' 1888 | EnforcedStyle: bare_percent 1889 | SupportedStyles: 1890 | - percent_q 1891 | - bare_percent 1892 | 1893 | Style/BeginBlock: 1894 | Description: Avoid the use of BEGIN blocks. 1895 | StyleGuide: "#no-BEGIN-blocks" 1896 | Enabled: true 1897 | VersionAdded: '0.9' 1898 | 1899 | # Supports --auto-correct 1900 | Style/BisectedAttrAccessor: 1901 | Description: Checks for places where `attr_reader` and `attr_writer` for the same 1902 | method can be combined into single `attr_accessor`. 1903 | Enabled: true 1904 | VersionAdded: '0.87' 1905 | 1906 | # Supports --auto-correct 1907 | Style/BlockComments: 1908 | Description: Do not use block comments. 1909 | StyleGuide: "#no-block-comments" 1910 | Enabled: true 1911 | VersionAdded: '0.9' 1912 | VersionChanged: '0.23' 1913 | 1914 | # Supports --auto-correct 1915 | Style/BlockDelimiters: 1916 | Description: Avoid using {...} for multi-line blocks (multiline chaining is always 1917 | ugly). Prefer {...} over do...end for single-line blocks. 1918 | StyleGuide: "#single-line-blocks" 1919 | Enabled: true 1920 | VersionAdded: '0.30' 1921 | VersionChanged: '0.35' 1922 | EnforcedStyle: line_count_based 1923 | SupportedStyles: 1924 | - line_count_based 1925 | - semantic 1926 | - braces_for_chaining 1927 | - always_braces 1928 | ProceduralMethods: 1929 | - benchmark 1930 | - bm 1931 | - bmbm 1932 | - create 1933 | - each_with_object 1934 | - measure 1935 | - new 1936 | - realtime 1937 | - tap 1938 | - with_object 1939 | FunctionalMethods: 1940 | - let 1941 | - let! 1942 | - subject 1943 | - watch 1944 | AllowedMethods: 1945 | - lambda 1946 | - proc 1947 | - it 1948 | AllowBracesOnProceduralOneLiners: false 1949 | BracesRequiredMethods: [] 1950 | 1951 | # Supports --auto-correct 1952 | Style/CaseEquality: 1953 | Description: Avoid explicit use of the case equality operator(===). 1954 | StyleGuide: "#no-case-equality" 1955 | Enabled: true 1956 | VersionAdded: '0.9' 1957 | VersionChanged: '0.89' 1958 | AllowOnConstant: false 1959 | 1960 | # Supports --auto-correct 1961 | Style/CaseLikeIf: 1962 | Description: This cop identifies places where `if-elsif` constructions can be replaced 1963 | with `case-when`. 1964 | StyleGuide: "#case-vs-if-else" 1965 | Enabled: true 1966 | Safe: false 1967 | VersionAdded: '0.88' 1968 | 1969 | # Supports --auto-correct 1970 | Style/CharacterLiteral: 1971 | Description: Checks for uses of character literals. 1972 | StyleGuide: "#no-character-literals" 1973 | Enabled: true 1974 | VersionAdded: '0.9' 1975 | 1976 | # Supports --auto-correct 1977 | Style/ClassAndModuleChildren: 1978 | Description: Checks style of children classes and modules. 1979 | StyleGuide: "#namespace-definition" 1980 | SafeAutoCorrect: false 1981 | Enabled: true 1982 | VersionAdded: '0.19' 1983 | EnforcedStyle: nested 1984 | SupportedStyles: 1985 | - nested 1986 | - compact 1987 | 1988 | # Supports --auto-correct 1989 | Style/ClassCheck: 1990 | Description: Enforces consistent use of `Object#is_a?` or `Object#kind_of?`. 1991 | StyleGuide: "#is-a-vs-kind-of" 1992 | Enabled: true 1993 | VersionAdded: '0.24' 1994 | EnforcedStyle: is_a? 1995 | SupportedStyles: 1996 | - is_a? 1997 | - kind_of? 1998 | 1999 | # Supports --auto-correct 2000 | Style/ClassEqualityComparison: 2001 | Description: Enforces the use of `Object#instance_of?` instead of class comparison 2002 | for equality. 2003 | StyleGuide: "#instance-of-vs-class-comparison" 2004 | Enabled: true 2005 | VersionAdded: '0.93' 2006 | AllowedMethods: 2007 | - "==" 2008 | - equal? 2009 | - eql? 2010 | 2011 | # Supports --auto-correct 2012 | Style/ClassMethods: 2013 | Description: Use self when defining module/class methods. 2014 | StyleGuide: "#def-self-class-methods" 2015 | Enabled: true 2016 | VersionAdded: '0.9' 2017 | VersionChanged: '0.20' 2018 | 2019 | Style/ClassVars: 2020 | Description: Avoid the use of class variables. 2021 | StyleGuide: "#no-class-vars" 2022 | Enabled: true 2023 | VersionAdded: '0.13' 2024 | 2025 | # Supports --auto-correct 2026 | Style/ColonMethodCall: 2027 | Description: 'Do not use :: for method call.' 2028 | StyleGuide: "#double-colons" 2029 | Enabled: true 2030 | VersionAdded: '0.9' 2031 | 2032 | # Supports --auto-correct 2033 | Style/ColonMethodDefinition: 2034 | Description: 'Do not use :: for defining class methods.' 2035 | StyleGuide: "#colon-method-definition" 2036 | Enabled: true 2037 | VersionAdded: '0.52' 2038 | 2039 | Style/CombinableLoops: 2040 | Description: Checks for places where multiple consecutive loops over the same data 2041 | can be combined into a single loop. 2042 | Enabled: true 2043 | Safe: false 2044 | VersionAdded: '0.90' 2045 | 2046 | # Supports --auto-correct 2047 | Style/CommandLiteral: 2048 | Description: Use `` or %x around command literals. 2049 | StyleGuide: "#percent-x" 2050 | Enabled: true 2051 | VersionAdded: '0.30' 2052 | EnforcedStyle: backticks 2053 | SupportedStyles: 2054 | - backticks 2055 | - percent_x 2056 | - mixed 2057 | AllowInnerBackticks: false 2058 | 2059 | # Supports --auto-correct 2060 | Style/CommentAnnotation: 2061 | Description: Checks formatting of special comments (TODO, FIXME, OPTIMIZE, HACK, REVIEW). 2062 | StyleGuide: "#annotate-keywords" 2063 | Enabled: true 2064 | VersionAdded: '0.10' 2065 | VersionChanged: '0.31' 2066 | Keywords: 2067 | - TODO 2068 | - FIXME 2069 | - OPTIMIZE 2070 | - HACK 2071 | - REVIEW 2072 | 2073 | Style/CommentedKeyword: 2074 | Description: Do not place comments on the same line as certain keywords. 2075 | Enabled: true 2076 | VersionAdded: '0.51' 2077 | 2078 | # Supports --auto-correct 2079 | Style/ConditionalAssignment: 2080 | Description: Use the return value of `if` and `case` statements for assignment to 2081 | a variable and variable comparison instead of assigning that variable inside of 2082 | each branch. 2083 | Enabled: true 2084 | VersionAdded: '0.36' 2085 | VersionChanged: '0.47' 2086 | EnforcedStyle: assign_to_condition 2087 | SupportedStyles: 2088 | - assign_to_condition 2089 | - assign_inside_condition 2090 | SingleLineConditionsOnly: true 2091 | IncludeTernaryExpressions: true 2092 | 2093 | # Supports --auto-correct 2094 | Style/DefWithParentheses: 2095 | Description: Use def with parentheses when there are arguments. 2096 | StyleGuide: "#method-parens" 2097 | Enabled: true 2098 | VersionAdded: '0.9' 2099 | VersionChanged: '0.12' 2100 | 2101 | # Supports --auto-correct 2102 | Style/Dir: 2103 | Description: Use the `__dir__` method to retrieve the canonicalized absolute path 2104 | to the current file. 2105 | Enabled: true 2106 | VersionAdded: '0.50' 2107 | 2108 | Style/Documentation: 2109 | Description: Document classes and non-namespace modules. 2110 | Enabled: true 2111 | VersionAdded: '0.9' 2112 | Exclude: 2113 | - "spec/**/*" 2114 | - "test/**/*" 2115 | 2116 | # Supports --auto-correct 2117 | Style/DoubleCopDisableDirective: 2118 | Description: Checks for double rubocop:disable comments on a single line. 2119 | Enabled: true 2120 | VersionAdded: '0.73' 2121 | 2122 | Style/DoubleNegation: 2123 | Description: Checks for uses of double negation (!!). 2124 | StyleGuide: "#no-bang-bang" 2125 | Enabled: true 2126 | VersionAdded: '0.19' 2127 | VersionChanged: '0.84' 2128 | EnforcedStyle: allowed_in_returns 2129 | SafeAutoCorrect: false 2130 | SupportedStyles: 2131 | - allowed_in_returns 2132 | - forbidden 2133 | 2134 | # Supports --auto-correct 2135 | Style/EachForSimpleLoop: 2136 | Description: Use `Integer#times` for a simple loop which iterates a fixed number of 2137 | times. 2138 | Enabled: true 2139 | VersionAdded: '0.41' 2140 | 2141 | # Supports --auto-correct 2142 | Style/EachWithObject: 2143 | Description: Prefer `each_with_object` over `inject` or `reduce`. 2144 | Enabled: true 2145 | VersionAdded: '0.22' 2146 | VersionChanged: '0.42' 2147 | 2148 | # Supports --auto-correct 2149 | Style/EmptyBlockParameter: 2150 | Description: Omit pipes for empty block parameters. 2151 | Enabled: true 2152 | VersionAdded: '0.52' 2153 | 2154 | # Supports --auto-correct 2155 | Style/EmptyCaseCondition: 2156 | Description: Avoid empty condition in case statements. 2157 | Enabled: true 2158 | VersionAdded: '0.40' 2159 | 2160 | # Supports --auto-correct 2161 | Style/EmptyElse: 2162 | Description: Avoid empty else-clauses. 2163 | Enabled: true 2164 | VersionAdded: '0.28' 2165 | VersionChanged: '0.32' 2166 | EnforcedStyle: both 2167 | SupportedStyles: 2168 | - empty 2169 | - nil 2170 | - both 2171 | 2172 | # Supports --auto-correct 2173 | Style/EmptyLambdaParameter: 2174 | Description: Omit parens for empty lambda parameters. 2175 | Enabled: true 2176 | VersionAdded: '0.52' 2177 | 2178 | # Supports --auto-correct 2179 | Style/EmptyLiteral: 2180 | Description: Prefer literals to Array.new/Hash.new/String.new. 2181 | StyleGuide: "#literal-array-hash" 2182 | Enabled: true 2183 | VersionAdded: '0.9' 2184 | VersionChanged: '0.12' 2185 | 2186 | # Supports --auto-correct 2187 | Style/EmptyMethod: 2188 | Description: Checks the formatting of empty method definitions. 2189 | StyleGuide: "#no-single-line-methods" 2190 | Enabled: true 2191 | VersionAdded: '0.46' 2192 | EnforcedStyle: compact 2193 | SupportedStyles: 2194 | - compact 2195 | - expanded 2196 | 2197 | # Supports --auto-correct 2198 | Style/Encoding: 2199 | Description: Use UTF-8 as the source file encoding. 2200 | StyleGuide: "#utf-8" 2201 | Enabled: true 2202 | VersionAdded: '0.9' 2203 | VersionChanged: '0.50' 2204 | 2205 | # Supports --auto-correct 2206 | Style/EndBlock: 2207 | Description: Avoid the use of END blocks. 2208 | StyleGuide: "#no-END-blocks" 2209 | Enabled: true 2210 | VersionAdded: '0.9' 2211 | VersionChanged: '0.81' 2212 | 2213 | Style/EvalWithLocation: 2214 | Description: Pass `__FILE__` and `__LINE__` to `eval` method, as they are used by 2215 | backtraces. 2216 | Enabled: true 2217 | VersionAdded: '0.52' 2218 | 2219 | # Supports --auto-correct 2220 | Style/EvenOdd: 2221 | Description: Favor the use of `Integer#even?` && `Integer#odd?`. 2222 | StyleGuide: "#predicate-methods" 2223 | Enabled: true 2224 | VersionAdded: '0.12' 2225 | VersionChanged: '0.29' 2226 | 2227 | # Supports --auto-correct 2228 | Style/ExpandPathArguments: 2229 | Description: Use `expand_path(__dir__)` instead of `expand_path('..', __FILE__)`. 2230 | Enabled: true 2231 | VersionAdded: '0.53' 2232 | 2233 | Style/ExponentialNotation: 2234 | Description: When using exponential notation, favor a mantissa between 1 (inclusive) 2235 | and 10 (exclusive). 2236 | StyleGuide: "#exponential-notation" 2237 | Enabled: true 2238 | VersionAdded: '0.82' 2239 | EnforcedStyle: scientific 2240 | SupportedStyles: 2241 | - scientific 2242 | - engineering 2243 | - integral 2244 | 2245 | Style/FloatDivision: 2246 | Description: For performing float division, coerce one side only. 2247 | StyleGuide: "#float-division" 2248 | Reference: https://github.com/rubocop-hq/ruby-style-guide/issues/628 2249 | Enabled: true 2250 | VersionAdded: '0.72' 2251 | EnforcedStyle: single_coerce 2252 | SupportedStyles: 2253 | - left_coerce 2254 | - right_coerce 2255 | - single_coerce 2256 | - fdiv 2257 | 2258 | # Supports --auto-correct 2259 | Style/For: 2260 | Description: Checks use of for or each in multiline loops. 2261 | StyleGuide: "#no-for-loops" 2262 | Enabled: true 2263 | VersionAdded: '0.13' 2264 | VersionChanged: '0.59' 2265 | EnforcedStyle: each 2266 | SupportedStyles: 2267 | - each 2268 | - for 2269 | 2270 | # Supports --auto-correct 2271 | Style/FormatString: 2272 | Description: Enforce the use of Kernel#sprintf, Kernel#format or String#%. 2273 | StyleGuide: "#sprintf" 2274 | Enabled: true 2275 | VersionAdded: '0.19' 2276 | VersionChanged: '0.49' 2277 | EnforcedStyle: format 2278 | SupportedStyles: 2279 | - format 2280 | - sprintf 2281 | - percent 2282 | 2283 | Style/FormatStringToken: 2284 | Description: Use a consistent style for format string tokens. 2285 | Enabled: true 2286 | EnforcedStyle: unannotated 2287 | SupportedStyles: 2288 | - annotated 2289 | - template 2290 | - unannotated 2291 | VersionAdded: '0.49' 2292 | VersionChanged: '0.75' 2293 | 2294 | # Supports --auto-correct 2295 | Style/FrozenStringLiteralComment: 2296 | Description: Add the frozen_string_literal comment to the top of files to help transition 2297 | to frozen string literals by default. 2298 | Enabled: true 2299 | VersionAdded: '0.36' 2300 | VersionChanged: '0.79' 2301 | EnforcedStyle: always 2302 | SupportedStyles: 2303 | - always 2304 | - always_true 2305 | - never 2306 | SafeAutoCorrect: false 2307 | 2308 | # Supports --auto-correct 2309 | Style/GlobalStdStream: 2310 | Description: Enforces the use of `$stdout/$stderr/$stdin` instead of `STDOUT/STDERR/STDIN`. 2311 | StyleGuide: "#global-stdout" 2312 | Enabled: true 2313 | VersionAdded: '0.89' 2314 | SafeAutoCorrect: false 2315 | 2316 | Style/GlobalVars: 2317 | Description: Do not introduce global variables. 2318 | StyleGuide: "#instance-vars" 2319 | Reference: https://www.zenspider.com/ruby/quickref.html 2320 | Enabled: true 2321 | VersionAdded: '0.13' 2322 | AllowedVariables: [] 2323 | 2324 | Style/GuardClause: 2325 | Description: Check for conditionals that can be replaced with guard clauses. 2326 | StyleGuide: "#no-nested-conditionals" 2327 | Enabled: true 2328 | VersionAdded: '0.20' 2329 | VersionChanged: '0.22' 2330 | MinBodyLength: 1 2331 | 2332 | # Supports --auto-correct 2333 | Style/HashAsLastArrayItem: 2334 | Description: Checks for presence or absence of braces around hash literal as a last 2335 | array item de on configuration. 2336 | StyleGuide: "#hash-literal-as-last-array-item" 2337 | Enabled: true 2338 | VersionAdded: '0.88' 2339 | EnforcedStyle: braces 2340 | SupportedStyles: 2341 | - braces 2342 | - no_braces 2343 | 2344 | # Supports --auto-correct 2345 | Style/HashEachMethods: 2346 | Description: Use Hash#each_key and Hash#each_value. 2347 | StyleGuide: "#hash-each" 2348 | Enabled: true 2349 | VersionAdded: '0.80' 2350 | Safe: false 2351 | 2352 | Style/HashLikeCase: 2353 | Description: Checks for places where `case-when` represents a simple 1:1 mapping and 2354 | can be replaced with a hash lookup. 2355 | Enabled: true 2356 | VersionAdded: '0.88' 2357 | MinBranchesCount: 3 2358 | 2359 | # Supports --auto-correct 2360 | Style/HashSyntax: 2361 | Description: 'Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, 2362 | :b => 2 }.' 2363 | StyleGuide: "#hash-literals" 2364 | Enabled: true 2365 | VersionAdded: '0.9' 2366 | VersionChanged: '0.43' 2367 | EnforcedStyle: ruby19 2368 | SupportedStyles: 2369 | - ruby19 2370 | - hash_rockets 2371 | - no_mixed_keys 2372 | - ruby19_no_mixed_keys 2373 | UseHashRocketsWithSymbolValues: false 2374 | PreferHashRocketsForNonAlnumEndingSymbols: false 2375 | 2376 | # Supports --auto-correct 2377 | Style/HashTransformKeys: 2378 | Description: Prefer `transform_keys` over `each_with_object`, `map`, or `to_h`. 2379 | Enabled: true 2380 | VersionAdded: '0.80' 2381 | VersionChanged: '0.90' 2382 | Safe: false 2383 | 2384 | # Supports --auto-correct 2385 | Style/HashTransformValues: 2386 | Description: Prefer `transform_values` over `each_with_object`, `map`, or `to_h`. 2387 | Enabled: true 2388 | VersionAdded: '0.80' 2389 | VersionChanged: '0.90' 2390 | Safe: false 2391 | 2392 | Style/IdenticalConditionalBranches: 2393 | Description: Checks that conditional statements do not have an identical line at the 2394 | end of each branch, which can validly be moved out of the conditional. 2395 | Enabled: true 2396 | VersionAdded: '0.36' 2397 | 2398 | Style/IfInsideElse: 2399 | Description: Finds if nodes inside else, which can be converted to elsif. 2400 | Enabled: true 2401 | AllowIfModifier: false 2402 | VersionAdded: '0.36' 2403 | 2404 | # Supports --auto-correct 2405 | Style/IfUnlessModifier: 2406 | Description: Favor modifier if/unless usage when you have a single-line body. 2407 | StyleGuide: "#if-as-a-modifier" 2408 | Enabled: true 2409 | VersionAdded: '0.9' 2410 | VersionChanged: '0.30' 2411 | 2412 | # Supports --auto-correct 2413 | Style/IfUnlessModifierOfIfUnless: 2414 | Description: Avoid modifier if/unless usage on conditionals. 2415 | Enabled: true 2416 | VersionAdded: '0.39' 2417 | VersionChanged: '0.87' 2418 | 2419 | # Supports --auto-correct 2420 | Style/IfWithSemicolon: 2421 | Description: Do not use if x; .... Use the ternary operator instead. 2422 | StyleGuide: "#no-semicolon-ifs" 2423 | Enabled: true 2424 | VersionAdded: '0.9' 2425 | VersionChanged: '0.83' 2426 | 2427 | # Supports --auto-correct 2428 | Style/InfiniteLoop: 2429 | Description: Use Kernel#loop for infinite loops. 2430 | StyleGuide: "#infinite-loop" 2431 | Enabled: true 2432 | VersionAdded: '0.26' 2433 | VersionChanged: '0.61' 2434 | 2435 | # Supports --auto-correct 2436 | Style/InverseMethods: 2437 | Description: Use the inverse method instead of `!.method` if an inverse method is 2438 | defined. 2439 | Enabled: true 2440 | Safe: false 2441 | VersionAdded: '0.48' 2442 | InverseMethods: 2443 | :any?: :none? 2444 | :even?: :odd? 2445 | :==: :!= 2446 | :=~: :!~ 2447 | :<: :>= 2448 | :>: :<= 2449 | InverseBlocks: 2450 | :select: :reject 2451 | :select!: :reject! 2452 | 2453 | # Supports --auto-correct 2454 | Style/KeywordParametersOrder: 2455 | Description: Enforces that optional keyword parameters are placed at the end of the 2456 | parameters list. 2457 | StyleGuide: "#keyword-parameters-order" 2458 | Enabled: true 2459 | VersionAdded: '0.90' 2460 | 2461 | # Supports --auto-correct 2462 | Style/Lambda: 2463 | Description: Use the new lambda literal syntax for single-line blocks. 2464 | StyleGuide: "#lambda-multi-line" 2465 | Enabled: true 2466 | VersionAdded: '0.9' 2467 | VersionChanged: '0.40' 2468 | EnforcedStyle: line_count_dependent 2469 | SupportedStyles: 2470 | - line_count_dependent 2471 | - lambda 2472 | - literal 2473 | 2474 | # Supports --auto-correct 2475 | Style/LambdaCall: 2476 | Description: Use lambda.call(...) instead of lambda.(...). 2477 | StyleGuide: "#proc-call" 2478 | Enabled: true 2479 | VersionAdded: '0.13' 2480 | VersionChanged: '0.14' 2481 | EnforcedStyle: call 2482 | SupportedStyles: 2483 | - call 2484 | - braces 2485 | 2486 | # Supports --auto-correct 2487 | Style/LineEndConcatenation: 2488 | Description: Use \ instead of + or << to concatenate two string literals at line end. 2489 | Enabled: true 2490 | SafeAutoCorrect: false 2491 | VersionAdded: '0.18' 2492 | VersionChanged: '0.64' 2493 | 2494 | # Supports --auto-correct 2495 | Style/MethodCallWithoutArgsParentheses: 2496 | Description: Do not use parentheses for method calls with no arguments. 2497 | StyleGuide: "#method-invocation-parens" 2498 | Enabled: true 2499 | AllowedMethods: [] 2500 | VersionAdded: '0.47' 2501 | VersionChanged: '0.55' 2502 | 2503 | # Supports --auto-correct 2504 | Style/MethodDefParentheses: 2505 | Description: Checks if the method definitions have or don't have parentheses. 2506 | StyleGuide: "#method-parens" 2507 | Enabled: true 2508 | VersionAdded: '0.16' 2509 | VersionChanged: '0.35' 2510 | EnforcedStyle: require_parentheses 2511 | SupportedStyles: 2512 | - require_parentheses 2513 | - require_no_parentheses 2514 | - require_no_parentheses_except_multiline 2515 | 2516 | # Supports --auto-correct 2517 | Style/MinMax: 2518 | Description: Use `Enumerable#minmax` instead of `Enumerable#min` and `Enumerable#max` 2519 | in conjunction. 2520 | Enabled: true 2521 | VersionAdded: '0.50' 2522 | 2523 | Style/MissingRespondToMissing: 2524 | Description: Checks if `method_missing` is implemented without implementing `respond_to_missing`. 2525 | StyleGuide: "#no-method-missing" 2526 | Enabled: true 2527 | VersionAdded: '0.56' 2528 | 2529 | # Supports --auto-correct 2530 | Style/MixinGrouping: 2531 | Description: Checks for grouping of mixins in `class` and `module` bodies. 2532 | StyleGuide: "#mixin-grouping" 2533 | Enabled: true 2534 | VersionAdded: '0.48' 2535 | VersionChanged: '0.49' 2536 | EnforcedStyle: separated 2537 | SupportedStyles: 2538 | - separated 2539 | - grouped 2540 | 2541 | Style/MixinUsage: 2542 | Description: Checks that `include`, `extend` and `prepend` exists at the top level. 2543 | Enabled: true 2544 | VersionAdded: '0.51' 2545 | 2546 | Style/MultilineBlockChain: 2547 | Description: Avoid multi-line chains of blocks. 2548 | StyleGuide: "#single-line-blocks" 2549 | Enabled: true 2550 | VersionAdded: '0.13' 2551 | 2552 | # Supports --auto-correct 2553 | Style/MultilineIfModifier: 2554 | Description: Only use if/unless modifiers on single line statements. 2555 | StyleGuide: "#no-multiline-if-modifiers" 2556 | Enabled: true 2557 | VersionAdded: '0.45' 2558 | 2559 | # Supports --auto-correct 2560 | Style/MultilineIfThen: 2561 | Description: Do not use then for multi-line if/unless. 2562 | StyleGuide: "#no-then" 2563 | Enabled: true 2564 | VersionAdded: '0.9' 2565 | VersionChanged: '0.26' 2566 | 2567 | # Supports --auto-correct 2568 | Style/MultilineMemoization: 2569 | Description: Wrap multiline memoizations in a `begin` and `end` block. 2570 | Enabled: true 2571 | VersionAdded: '0.44' 2572 | VersionChanged: '0.48' 2573 | EnforcedStyle: keyword 2574 | SupportedStyles: 2575 | - keyword 2576 | - braces 2577 | 2578 | # Supports --auto-correct 2579 | Style/MultilineTernaryOperator: 2580 | Description: 'Avoid multi-line ?: (the ternary operator); use if/unless instead.' 2581 | StyleGuide: "#no-multiline-ternary" 2582 | Enabled: true 2583 | VersionAdded: '0.9' 2584 | VersionChanged: '0.86' 2585 | 2586 | # Supports --auto-correct 2587 | Style/MultilineWhenThen: 2588 | Description: Do not use then for multi-line when statement. 2589 | StyleGuide: "#no-then" 2590 | Enabled: true 2591 | VersionAdded: '0.73' 2592 | 2593 | Style/MultipleComparison: 2594 | Description: Avoid comparing a variable with multiple items in a conditional, use 2595 | Array#include? instead. 2596 | Enabled: true 2597 | VersionAdded: '0.49' 2598 | 2599 | # Supports --auto-correct 2600 | Style/MutableConstant: 2601 | Description: Do not assign mutable objects to constants. 2602 | Enabled: true 2603 | VersionAdded: '0.34' 2604 | VersionChanged: '0.65' 2605 | EnforcedStyle: literals 2606 | SupportedStyles: 2607 | - literals 2608 | - strict 2609 | 2610 | # Supports --auto-correct 2611 | Style/NegatedIf: 2612 | Description: Favor unless over if for negative conditions (or control flow or). 2613 | StyleGuide: "#unless-for-negatives" 2614 | Enabled: true 2615 | VersionAdded: '0.20' 2616 | VersionChanged: '0.48' 2617 | EnforcedStyle: both 2618 | SupportedStyles: 2619 | - both 2620 | - prefix 2621 | - postfix 2622 | 2623 | # Supports --auto-correct 2624 | Style/NegatedUnless: 2625 | Description: Favor if over unless for negative conditions. 2626 | StyleGuide: "#if-for-negatives" 2627 | Enabled: true 2628 | VersionAdded: '0.69' 2629 | EnforcedStyle: both 2630 | SupportedStyles: 2631 | - both 2632 | - prefix 2633 | - postfix 2634 | 2635 | # Supports --auto-correct 2636 | Style/NegatedWhile: 2637 | Description: Favor until over while for negative conditions. 2638 | StyleGuide: "#until-for-negatives" 2639 | Enabled: true 2640 | VersionAdded: '0.20' 2641 | 2642 | # Supports --auto-correct 2643 | Style/NestedModifier: 2644 | Description: Avoid using nested modifiers. 2645 | StyleGuide: "#no-nested-modifiers" 2646 | Enabled: true 2647 | VersionAdded: '0.35' 2648 | 2649 | # Supports --auto-correct 2650 | Style/NestedParenthesizedCalls: 2651 | Description: Parenthesize method calls which are nested inside the argument list of 2652 | another parenthesized method call. 2653 | Enabled: true 2654 | VersionAdded: '0.36' 2655 | VersionChanged: '0.77' 2656 | AllowedMethods: 2657 | - be 2658 | - be_a 2659 | - be_an 2660 | - be_between 2661 | - be_falsey 2662 | - be_kind_of 2663 | - be_instance_of 2664 | - be_truthy 2665 | - be_within 2666 | - eq 2667 | - eql 2668 | - end_with 2669 | - include 2670 | - match 2671 | - raise_error 2672 | - respond_to 2673 | - start_with 2674 | 2675 | # Supports --auto-correct 2676 | Style/NestedTernaryOperator: 2677 | Description: Use one expression per branch in a ternary operator. 2678 | StyleGuide: "#no-nested-ternary" 2679 | Enabled: true 2680 | VersionAdded: '0.9' 2681 | VersionChanged: '0.86' 2682 | 2683 | # Supports --auto-correct 2684 | Style/Next: 2685 | Description: Use `next` to skip iteration instead of a condition at the end. 2686 | StyleGuide: "#no-nested-conditionals" 2687 | Enabled: true 2688 | VersionAdded: '0.22' 2689 | VersionChanged: '0.35' 2690 | EnforcedStyle: skip_modifier_ifs 2691 | MinBodyLength: 3 2692 | SupportedStyles: 2693 | - skip_modifier_ifs 2694 | - always 2695 | 2696 | # Supports --auto-correct 2697 | Style/NilComparison: 2698 | Description: Prefer x.nil? to x == nil. 2699 | StyleGuide: "#predicate-methods" 2700 | Enabled: true 2701 | VersionAdded: '0.12' 2702 | VersionChanged: '0.59' 2703 | EnforcedStyle: predicate 2704 | SupportedStyles: 2705 | - predicate 2706 | - comparison 2707 | 2708 | # Supports --auto-correct 2709 | Style/NonNilCheck: 2710 | Description: Checks for redundant nil checks. 2711 | StyleGuide: "#no-non-nil-checks" 2712 | Enabled: true 2713 | VersionAdded: '0.20' 2714 | VersionChanged: '0.22' 2715 | IncludeSemanticChanges: false 2716 | 2717 | # Supports --auto-correct 2718 | Style/Not: 2719 | Description: Use ! instead of not. 2720 | StyleGuide: "#bang-not-not" 2721 | Enabled: true 2722 | VersionAdded: '0.9' 2723 | VersionChanged: '0.20' 2724 | 2725 | # Supports --auto-correct 2726 | Style/NumericLiteralPrefix: 2727 | Description: Use smallcase prefixes for numeric literals. 2728 | StyleGuide: "#numeric-literal-prefixes" 2729 | Enabled: true 2730 | VersionAdded: '0.41' 2731 | EnforcedOctalStyle: zero_with_o 2732 | SupportedOctalStyles: 2733 | - zero_with_o 2734 | - zero_only 2735 | 2736 | # Supports --auto-correct 2737 | Style/NumericLiterals: 2738 | Description: Add underscores to large numeric literals to improve their readability. 2739 | StyleGuide: "#underscores-in-numerics" 2740 | Enabled: true 2741 | VersionAdded: '0.9' 2742 | VersionChanged: '0.48' 2743 | MinDigits: 5 2744 | Strict: false 2745 | 2746 | # Supports --auto-correct 2747 | Style/NumericPredicate: 2748 | Description: Checks for the use of predicate- or comparison methods for numeric comparisons. 2749 | StyleGuide: "#predicate-methods" 2750 | Safe: false 2751 | Enabled: true 2752 | VersionAdded: '0.42' 2753 | VersionChanged: '0.59' 2754 | EnforcedStyle: predicate 2755 | SupportedStyles: 2756 | - predicate 2757 | - comparison 2758 | AllowedMethods: [] 2759 | Exclude: 2760 | - "spec/**/*" 2761 | 2762 | # Supports --auto-correct 2763 | Style/OneLineConditional: 2764 | Description: Favor the ternary operator (?:) or multi-line constructs over single-line 2765 | if/then/else/end constructs. 2766 | StyleGuide: "#ternary-operator" 2767 | Enabled: true 2768 | AlwaysCorrectToMultiline: false 2769 | VersionAdded: '0.9' 2770 | VersionChanged: '0.90' 2771 | 2772 | Style/OptionalArguments: 2773 | Description: Checks for optional arguments that do not appear at the end of the argument 2774 | list. 2775 | StyleGuide: "#optional-arguments" 2776 | Enabled: true 2777 | Safe: false 2778 | VersionAdded: '0.33' 2779 | VersionChanged: '0.83' 2780 | 2781 | # Supports --auto-correct 2782 | Style/OrAssignment: 2783 | Description: Recommend usage of double pipe equals (||=) where applicable. 2784 | StyleGuide: "#double-pipe-for-uninit" 2785 | Enabled: true 2786 | VersionAdded: '0.50' 2787 | 2788 | # Supports --auto-correct 2789 | Style/ParallelAssignment: 2790 | Description: Check for simple usages of parallel assignment. It will only warn when 2791 | the number of variables matches on both sides of the assignment. 2792 | StyleGuide: "#parallel-assignment" 2793 | Enabled: true 2794 | VersionAdded: '0.32' 2795 | 2796 | # Supports --auto-correct 2797 | Style/ParenthesesAroundCondition: 2798 | Description: Don't use parentheses around the condition of an if/unless/while. 2799 | StyleGuide: "#no-parens-around-condition" 2800 | Enabled: true 2801 | VersionAdded: '0.9' 2802 | VersionChanged: '0.56' 2803 | AllowSafeAssignment: true 2804 | AllowInMultilineConditions: false 2805 | 2806 | # Supports --auto-correct 2807 | Style/PercentLiteralDelimiters: 2808 | Description: Use `%`-literal delimiters consistently. 2809 | StyleGuide: "#percent-literal-braces" 2810 | Enabled: true 2811 | VersionAdded: '0.19' 2812 | PreferredDelimiters: 2813 | default: "()" 2814 | "%i": "[]" 2815 | "%I": "[]" 2816 | "%r": "{}" 2817 | "%w": "[]" 2818 | "%W": "[]" 2819 | VersionChanged: 0.48.1 2820 | 2821 | # Supports --auto-correct 2822 | Style/PercentQLiterals: 2823 | Description: Checks if uses of %Q/%q match the configured preference. 2824 | Enabled: true 2825 | VersionAdded: '0.25' 2826 | EnforcedStyle: lower_case_q 2827 | SupportedStyles: 2828 | - lower_case_q 2829 | - upper_case_q 2830 | 2831 | # Supports --auto-correct 2832 | Style/PerlBackrefs: 2833 | Description: Avoid Perl-style regex back references. 2834 | StyleGuide: "#no-perl-regexp-last-matchers" 2835 | Enabled: true 2836 | VersionAdded: '0.13' 2837 | 2838 | # Supports --auto-correct 2839 | Style/PreferredHashMethods: 2840 | Description: Checks use of `has_key?` and `has_value?` Hash methods. 2841 | StyleGuide: "#hash-key" 2842 | Enabled: true 2843 | Safe: false 2844 | VersionAdded: '0.41' 2845 | VersionChanged: '0.70' 2846 | EnforcedStyle: short 2847 | SupportedStyles: 2848 | - short 2849 | - verbose 2850 | 2851 | # Supports --auto-correct 2852 | Style/Proc: 2853 | Description: Use proc instead of Proc.new. 2854 | StyleGuide: "#proc" 2855 | Enabled: true 2856 | VersionAdded: '0.9' 2857 | VersionChanged: '0.18' 2858 | 2859 | # Supports --auto-correct 2860 | Style/RaiseArgs: 2861 | Description: Checks the arguments passed to raise/fail. 2862 | StyleGuide: "#exception-class-messages" 2863 | Enabled: true 2864 | VersionAdded: '0.14' 2865 | VersionChanged: '0.40' 2866 | EnforcedStyle: exploded 2867 | SupportedStyles: 2868 | - compact 2869 | - exploded 2870 | 2871 | # Supports --auto-correct 2872 | Style/RandomWithOffset: 2873 | Description: Prefer to use ranges when generating random numbers instead of integers 2874 | with offsets. 2875 | StyleGuide: "#random-numbers" 2876 | Enabled: true 2877 | VersionAdded: '0.52' 2878 | 2879 | # Supports --auto-correct 2880 | Style/RedundantBegin: 2881 | Description: Don't use begin blocks when they are not needed. 2882 | StyleGuide: "#begin-implicit" 2883 | Enabled: true 2884 | VersionAdded: '0.10' 2885 | VersionChanged: '0.21' 2886 | 2887 | # Supports --auto-correct 2888 | Style/RedundantCapitalW: 2889 | Description: Checks for %W when interpolation is not needed. 2890 | Enabled: true 2891 | VersionAdded: '0.76' 2892 | 2893 | # Supports --auto-correct 2894 | Style/RedundantCondition: 2895 | Description: Checks for unnecessary conditional expressions. 2896 | Enabled: true 2897 | VersionAdded: '0.76' 2898 | 2899 | # Supports --auto-correct 2900 | Style/RedundantConditional: 2901 | Description: Don't return true/false from a conditional. 2902 | Enabled: true 2903 | VersionAdded: '0.50' 2904 | 2905 | # Supports --auto-correct 2906 | Style/RedundantException: 2907 | Description: Checks for an obsolete RuntimeException argument in raise/fail. 2908 | StyleGuide: "#no-explicit-runtimeerror" 2909 | Enabled: true 2910 | VersionAdded: '0.14' 2911 | VersionChanged: '0.29' 2912 | 2913 | # Supports --auto-correct 2914 | Style/RedundantFetchBlock: 2915 | Description: Use `fetch(key, value)` instead of `fetch(key) { value }` when value 2916 | has Numeric, Rational, Complex, Symbol or String type, `false`, `true`, `nil` or 2917 | is a constant. 2918 | Reference: https://github.com/JuanitoFatas/fast-ruby#hashfetch-with-argument-vs-hashfetch--block-code 2919 | Enabled: true 2920 | Safe: false 2921 | SafeForConstants: false 2922 | VersionAdded: '0.86' 2923 | 2924 | # Supports --auto-correct 2925 | Style/RedundantFileExtensionInRequire: 2926 | Description: Checks for the presence of superfluous `.rb` extension in the filename 2927 | provided to `require` and `require_relative`. 2928 | StyleGuide: "#no-explicit-rb-to-require" 2929 | Enabled: true 2930 | VersionAdded: '0.88' 2931 | 2932 | # Supports --auto-correct 2933 | Style/RedundantFreeze: 2934 | Description: Checks usages of Object#freeze on immutable objects. 2935 | Enabled: true 2936 | VersionAdded: '0.34' 2937 | VersionChanged: '0.66' 2938 | 2939 | # Supports --auto-correct 2940 | Style/RedundantInterpolation: 2941 | Description: Checks for strings that are just an interpolated expression. 2942 | Enabled: true 2943 | VersionAdded: '0.76' 2944 | 2945 | # Supports --auto-correct 2946 | Style/RedundantParentheses: 2947 | Description: Checks for parentheses that seem not to serve any purpose. 2948 | Enabled: true 2949 | VersionAdded: '0.36' 2950 | 2951 | # Supports --auto-correct 2952 | Style/RedundantPercentQ: 2953 | Description: Checks for %q/%Q when single quotes or double quotes would do. 2954 | StyleGuide: "#percent-q" 2955 | Enabled: true 2956 | VersionAdded: '0.76' 2957 | 2958 | # Supports --auto-correct 2959 | Style/RedundantRegexpCharacterClass: 2960 | Description: Checks for unnecessary single-element Regexp character classes. 2961 | Enabled: true 2962 | VersionAdded: '0.85' 2963 | 2964 | # Supports --auto-correct 2965 | Style/RedundantReturn: 2966 | Description: Don't use return where it's not required. 2967 | StyleGuide: "#no-explicit-return" 2968 | Enabled: true 2969 | VersionAdded: '0.10' 2970 | VersionChanged: '0.14' 2971 | AllowMultipleReturnValues: false 2972 | 2973 | # Supports --auto-correct 2974 | Style/RedundantSelf: 2975 | Description: Don't use self where it's not needed. 2976 | StyleGuide: "#no-self-unless-required" 2977 | Enabled: true 2978 | VersionAdded: '0.10' 2979 | VersionChanged: '0.13' 2980 | 2981 | # Supports --auto-correct 2982 | Style/RedundantSelfAssignment: 2983 | Description: Checks for places where redundant assignments are made for in place modification 2984 | methods. 2985 | Enabled: true 2986 | Safe: false 2987 | VersionAdded: '0.90' 2988 | 2989 | # Supports --auto-correct 2990 | Style/RedundantSort: 2991 | Description: Use `min` instead of `sort.first`, `max_by` instead of `sort_by...last`, 2992 | etc. 2993 | Enabled: true 2994 | VersionAdded: '0.76' 2995 | 2996 | # Supports --auto-correct 2997 | Style/RedundantSortBy: 2998 | Description: Use `sort` instead of `sort_by { |x| x }`. 2999 | Enabled: true 3000 | VersionAdded: '0.36' 3001 | 3002 | # Supports --auto-correct 3003 | Style/RegexpLiteral: 3004 | Description: Use / or %r around regular expressions. 3005 | StyleGuide: "#percent-r" 3006 | Enabled: true 3007 | VersionAdded: '0.9' 3008 | VersionChanged: '0.30' 3009 | EnforcedStyle: slashes 3010 | SupportedStyles: 3011 | - slashes 3012 | - percent_r 3013 | - mixed 3014 | AllowInnerSlashes: false 3015 | 3016 | # Supports --auto-correct 3017 | Style/RescueModifier: 3018 | Description: Avoid using rescue in its modifier form. 3019 | StyleGuide: "#no-rescue-modifiers" 3020 | Enabled: true 3021 | VersionAdded: '0.9' 3022 | VersionChanged: '0.34' 3023 | 3024 | # Supports --auto-correct 3025 | Style/RescueStandardError: 3026 | Description: Avoid rescuing without specifying an error class. 3027 | Enabled: true 3028 | VersionAdded: '0.52' 3029 | EnforcedStyle: explicit 3030 | SupportedStyles: 3031 | - implicit 3032 | - explicit 3033 | 3034 | # Supports --auto-correct 3035 | Style/SafeNavigation: 3036 | Description: This cop transforms usages of a method call safeguarded by a check for 3037 | the existence of the object to safe navigation (`&.`). Auto-correction is unsafe 3038 | as it assumes the object will be `nil` or truthy, but never `false`. 3039 | Enabled: true 3040 | VersionAdded: '0.43' 3041 | VersionChanged: '0.77' 3042 | ConvertCodeThatCanStartToReturnNil: false 3043 | AllowedMethods: 3044 | - present? 3045 | - blank? 3046 | - presence 3047 | - try 3048 | - try! 3049 | SafeAutoCorrect: false 3050 | 3051 | # Supports --auto-correct 3052 | Style/Sample: 3053 | Description: Use `sample` instead of `shuffle.first`, `shuffle.last`, and `shuffle[Integer]`. 3054 | Reference: https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code 3055 | Enabled: true 3056 | VersionAdded: '0.30' 3057 | 3058 | # Supports --auto-correct 3059 | Style/SelfAssignment: 3060 | Description: Checks for places where self-assignment shorthand should have been used. 3061 | StyleGuide: "#self-assignment" 3062 | Enabled: true 3063 | VersionAdded: '0.19' 3064 | VersionChanged: '0.29' 3065 | 3066 | # Supports --auto-correct 3067 | Style/Semicolon: 3068 | Description: Don't use semicolons to terminate expressions. 3069 | StyleGuide: "#no-semicolon" 3070 | Enabled: true 3071 | VersionAdded: '0.9' 3072 | VersionChanged: '0.19' 3073 | AllowAsExpressionSeparator: false 3074 | 3075 | # Supports --auto-correct 3076 | Style/SignalException: 3077 | Description: Checks for proper usage of fail and raise. 3078 | StyleGuide: "#prefer-raise-over-fail" 3079 | Enabled: true 3080 | VersionAdded: '0.11' 3081 | VersionChanged: '0.37' 3082 | EnforcedStyle: only_raise 3083 | SupportedStyles: 3084 | - only_raise 3085 | - only_fail 3086 | - semantic 3087 | 3088 | # Supports --auto-correct 3089 | Style/SingleArgumentDig: 3090 | Description: Avoid using single argument dig method. 3091 | Enabled: true 3092 | VersionAdded: '0.89' 3093 | Safe: false 3094 | 3095 | # Supports --auto-correct 3096 | Style/SingleLineMethods: 3097 | Description: Avoid single-line methods. 3098 | StyleGuide: "#no-single-line-methods" 3099 | Enabled: true 3100 | VersionAdded: '0.9' 3101 | VersionChanged: '0.19' 3102 | AllowIfMethodIsEmpty: true 3103 | 3104 | # Supports --auto-correct 3105 | Style/SlicingWithRange: 3106 | Description: Checks array slicing is done with endless ranges when suitable. 3107 | Enabled: true 3108 | VersionAdded: '0.83' 3109 | Safe: false 3110 | 3111 | Style/SoleNestedConditional: 3112 | Description: Finds sole nested conditional nodes which can be merged into outer conditional 3113 | node. 3114 | Enabled: true 3115 | VersionAdded: '0.89' 3116 | AllowModifier: false 3117 | 3118 | # Supports --auto-correct 3119 | Style/SpecialGlobalVars: 3120 | Description: Avoid Perl-style global variables. 3121 | StyleGuide: "#no-cryptic-perlisms" 3122 | Enabled: true 3123 | VersionAdded: '0.13' 3124 | VersionChanged: '0.36' 3125 | SafeAutoCorrect: false 3126 | EnforcedStyle: use_english_names 3127 | SupportedStyles: 3128 | - use_perl_names 3129 | - use_english_names 3130 | 3131 | # Supports --auto-correct 3132 | Style/StabbyLambdaParentheses: 3133 | Description: Check for the usage of parentheses around stabby lambda arguments. 3134 | StyleGuide: "#stabby-lambda-with-args" 3135 | Enabled: true 3136 | VersionAdded: '0.35' 3137 | EnforcedStyle: require_parentheses 3138 | SupportedStyles: 3139 | - require_parentheses 3140 | - require_no_parentheses 3141 | 3142 | # Supports --auto-correct 3143 | Style/StderrPuts: 3144 | Description: Use `warn` instead of `$stderr.puts`. 3145 | StyleGuide: "#warn" 3146 | Enabled: true 3147 | VersionAdded: '0.51' 3148 | 3149 | # Supports --auto-correct 3150 | Style/StringLiterals: 3151 | Description: Checks if uses of quotes match the configured preference. 3152 | StyleGuide: "#consistent-string-literals" 3153 | Enabled: true 3154 | VersionAdded: '0.9' 3155 | VersionChanged: '0.36' 3156 | EnforcedStyle: double_quotes 3157 | SupportedStyles: 3158 | - single_quotes 3159 | - double_quotes 3160 | ConsistentQuotesInMultiline: false 3161 | 3162 | # Supports --auto-correct 3163 | Style/StringLiteralsInInterpolation: 3164 | Description: Checks if uses of quotes inside expressions in interpolated strings match 3165 | the configured preference. 3166 | Enabled: true 3167 | VersionAdded: '0.27' 3168 | EnforcedStyle: single_quotes 3169 | SupportedStyles: 3170 | - single_quotes 3171 | - double_quotes 3172 | 3173 | # Supports --auto-correct 3174 | Style/Strip: 3175 | Description: Use `strip` instead of `lstrip.rstrip`. 3176 | Enabled: true 3177 | VersionAdded: '0.36' 3178 | 3179 | # Supports --auto-correct 3180 | Style/StructInheritance: 3181 | Description: Checks for inheritance from Struct.new. 3182 | StyleGuide: "#no-extend-struct-new" 3183 | Enabled: true 3184 | VersionAdded: '0.29' 3185 | VersionChanged: '0.86' 3186 | 3187 | # Supports --auto-correct 3188 | Style/SymbolArray: 3189 | Description: Use %i or %I for arrays of symbols. 3190 | StyleGuide: "#percent-i" 3191 | Enabled: true 3192 | VersionAdded: '0.9' 3193 | VersionChanged: '0.49' 3194 | EnforcedStyle: percent 3195 | MinSize: 2 3196 | SupportedStyles: 3197 | - percent 3198 | - brackets 3199 | 3200 | # Supports --auto-correct 3201 | Style/SymbolLiteral: 3202 | Description: Use plain symbols instead of string symbols when possible. 3203 | Enabled: true 3204 | VersionAdded: '0.30' 3205 | 3206 | # Supports --auto-correct 3207 | Style/SymbolProc: 3208 | Description: Use symbols as procs instead of blocks when possible. 3209 | Enabled: true 3210 | Safe: false 3211 | VersionAdded: '0.26' 3212 | VersionChanged: '0.64' 3213 | AllowedMethods: 3214 | - respond_to 3215 | - define_method 3216 | 3217 | # Supports --auto-correct 3218 | Style/TernaryParentheses: 3219 | Description: Checks for use of parentheses around ternary conditions. 3220 | Enabled: true 3221 | VersionAdded: '0.42' 3222 | VersionChanged: '0.46' 3223 | EnforcedStyle: require_no_parentheses 3224 | SupportedStyles: 3225 | - require_parentheses 3226 | - require_no_parentheses 3227 | - require_parentheses_when_complex 3228 | AllowSafeAssignment: true 3229 | 3230 | # Supports --auto-correct 3231 | Style/TrailingBodyOnClass: 3232 | Description: Class body goes below class statement. 3233 | Enabled: true 3234 | VersionAdded: '0.53' 3235 | 3236 | # Supports --auto-correct 3237 | Style/TrailingBodyOnMethodDefinition: 3238 | Description: Method body goes below definition. 3239 | Enabled: true 3240 | VersionAdded: '0.52' 3241 | 3242 | # Supports --auto-correct 3243 | Style/TrailingBodyOnModule: 3244 | Description: Module body goes below module statement. 3245 | Enabled: true 3246 | VersionAdded: '0.53' 3247 | 3248 | # Supports --auto-correct 3249 | Style/TrailingCommaInArguments: 3250 | Description: Checks for trailing comma in argument lists. 3251 | StyleGuide: "#no-trailing-params-comma" 3252 | Enabled: true 3253 | VersionAdded: '0.36' 3254 | EnforcedStyleForMultiline: no_comma 3255 | SupportedStylesForMultiline: 3256 | - comma 3257 | - consistent_comma 3258 | - no_comma 3259 | 3260 | # Supports --auto-correct 3261 | Style/TrailingCommaInArrayLiteral: 3262 | Description: Checks for trailing comma in array literals. 3263 | StyleGuide: "#no-trailing-array-commas" 3264 | Enabled: true 3265 | VersionAdded: '0.53' 3266 | EnforcedStyleForMultiline: no_comma 3267 | SupportedStylesForMultiline: 3268 | - comma 3269 | - consistent_comma 3270 | - no_comma 3271 | 3272 | # Supports --auto-correct 3273 | Style/TrailingCommaInHashLiteral: 3274 | Description: Checks for trailing comma in hash literals. 3275 | Enabled: true 3276 | EnforcedStyleForMultiline: no_comma 3277 | SupportedStylesForMultiline: 3278 | - comma 3279 | - consistent_comma 3280 | - no_comma 3281 | VersionAdded: '0.53' 3282 | 3283 | # Supports --auto-correct 3284 | Style/TrailingMethodEndStatement: 3285 | Description: Checks for trailing end statement on line of method body. 3286 | Enabled: true 3287 | VersionAdded: '0.52' 3288 | 3289 | # Supports --auto-correct 3290 | Style/TrailingUnderscoreVariable: 3291 | Description: Checks for the usage of unneeded trailing underscores at the end of parallel 3292 | variable assignment. 3293 | AllowNamedUnderscoreVariables: true 3294 | Enabled: true 3295 | VersionAdded: '0.31' 3296 | VersionChanged: '0.35' 3297 | 3298 | # Supports --auto-correct 3299 | Style/TrivialAccessors: 3300 | Description: Prefer attr_* methods to trivial readers/writers. 3301 | StyleGuide: "#attr_family" 3302 | Enabled: true 3303 | VersionAdded: '0.9' 3304 | VersionChanged: '0.77' 3305 | ExactNameMatch: true 3306 | AllowPredicates: true 3307 | AllowDSLWriters: false 3308 | IgnoreClassMethods: false 3309 | AllowedMethods: 3310 | - to_ary 3311 | - to_a 3312 | - to_c 3313 | - to_enum 3314 | - to_h 3315 | - to_hash 3316 | - to_i 3317 | - to_int 3318 | - to_io 3319 | - to_open 3320 | - to_path 3321 | - to_proc 3322 | - to_r 3323 | - to_regexp 3324 | - to_str 3325 | - to_s 3326 | - to_sym 3327 | 3328 | # Supports --auto-correct 3329 | Style/UnlessElse: 3330 | Description: Do not use unless with else. Rewrite these with the positive case first. 3331 | StyleGuide: "#no-else-with-unless" 3332 | Enabled: true 3333 | VersionAdded: '0.9' 3334 | 3335 | # Supports --auto-correct 3336 | Style/UnpackFirst: 3337 | Description: Checks for accessing the first element of `String#unpack` instead of 3338 | using `unpack1`. 3339 | Enabled: true 3340 | VersionAdded: '0.54' 3341 | 3342 | # Supports --auto-correct 3343 | Style/VariableInterpolation: 3344 | Description: Don't interpolate global, instance and class variables directly in strings. 3345 | StyleGuide: "#curlies-interpolate" 3346 | Enabled: true 3347 | VersionAdded: '0.9' 3348 | VersionChanged: '0.20' 3349 | 3350 | # Supports --auto-correct 3351 | Style/WhenThen: 3352 | Description: Use when x then ... for one-line cases. 3353 | StyleGuide: "#one-line-cases" 3354 | Enabled: true 3355 | VersionAdded: '0.9' 3356 | 3357 | # Supports --auto-correct 3358 | Style/WhileUntilDo: 3359 | Description: Checks for redundant do after while or until. 3360 | StyleGuide: "#no-multiline-while-do" 3361 | Enabled: true 3362 | VersionAdded: '0.9' 3363 | 3364 | # Supports --auto-correct 3365 | Style/WhileUntilModifier: 3366 | Description: Favor modifier while/until usage when you have a single-line body. 3367 | StyleGuide: "#while-as-a-modifier" 3368 | Enabled: true 3369 | VersionAdded: '0.9' 3370 | VersionChanged: '0.30' 3371 | 3372 | # Supports --auto-correct 3373 | Style/WordArray: 3374 | Description: Use %w or %W for arrays of words. 3375 | StyleGuide: "#percent-w" 3376 | Enabled: true 3377 | VersionAdded: '0.9' 3378 | VersionChanged: '0.36' 3379 | EnforcedStyle: percent 3380 | SupportedStyles: 3381 | - percent 3382 | - brackets 3383 | MinSize: 2 3384 | WordRegex: !ruby/regexp /\A(?:\p{Word}|\p{Word}-\p{Word}|\n|\t)+\z/ 3385 | 3386 | # Supports --auto-correct 3387 | Style/YodaCondition: 3388 | Description: Forbid or enforce yoda conditions. 3389 | Reference: https://en.wikipedia.org/wiki/Yoda_conditions 3390 | Enabled: true 3391 | EnforcedStyle: forbid_for_all_comparison_operators 3392 | SupportedStyles: 3393 | - forbid_for_all_comparison_operators 3394 | - forbid_for_equality_operators_only 3395 | - require_for_all_comparison_operators 3396 | - require_for_equality_operators_only 3397 | Safe: false 3398 | VersionAdded: '0.49' 3399 | VersionChanged: '0.75' 3400 | 3401 | # Supports --auto-correct 3402 | Style/ZeroLengthPredicate: 3403 | Description: 'Use #empty? when testing for objects of length 0.' 3404 | Enabled: true 3405 | Safe: false 3406 | VersionAdded: '0.37' 3407 | VersionChanged: '0.39' 3408 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # CHANGELOG 2 | 3 | ## Master (Unreleased) 4 | 5 | ## 3.11.0 (2025-03-28) 6 | 7 | ### Added 8 | 9 | * Byebug 12 compatibility, with Ruby 3.1, 3.2, and 3.3 support (#434). 10 | * Support for pry 0.15 (#428). 11 | 12 | ### Removed 13 | 14 | * Support for Ruby 2.7, and 3.0. Pry-byebug no longer installs on these platforms (#433). 15 | 16 | ## 3.10.1 (2022-08-16) 17 | 18 | ### Fixed 19 | 20 | * Rails console loading a debugger REPL instead of the standard Pry REPL (#392) 21 | 22 | ## 3.10.0 (2022-08-15) 23 | 24 | ### Added 25 | 26 | * Support for pry 0.14 (#346, #386). NOTE: pry-byebug now needs to be explicitly required from `~/.pryrc` since plugin autoloading has been removed from Pry. 27 | 28 | ### Removed 29 | 30 | * Support for Ruby 2.4, 2.5, and 2.6. Pry-byebug no longer installs on these platforms (#380). 31 | 32 | ## 3.9.0 (2020-03-21) 33 | 34 | ### Fixed 35 | 36 | * Dependency on pry being too loose. Now breaking minor releases of pry won't affect pry-byebug users (#289). 37 | 38 | ### Added 39 | 40 | * Support for pry 0.13.0 (#266). 41 | 42 | ### Removed 43 | 44 | * Support for pry older than 0.13.0 (#289). 45 | 46 | ## 3.8.0 (2020-01-22) 47 | 48 | ### Fixed 49 | 50 | * Use `Binding#source_location` instead of evaluating `__FILE__` to avoid 51 | warnings on Ruby 2.7 and on Ruby 2.6 in verbose mode (#221). 52 | 53 | ### Removed 54 | 55 | * Support for Ruby 2.3. Pry-byebug no longer installs on this platform. 56 | 57 | ## 3.7.0 (2019-02-21) 58 | 59 | * Byebug 11 compatibility, with ruby 2.6 support. 60 | 61 | ## 3.6.0 (2018-02-07) 62 | 63 | ### Added 64 | 65 | * Byebug 10 compatibility, with ruby 2.5 support. 66 | 67 | ## 3.5.1 (2017-11-27) 68 | 69 | ### Fixed 70 | 71 | * Allow other threads like Pry (#142). 72 | 73 | ## 3.5.0 (2017-08-23) 74 | 75 | ### Added 76 | 77 | * Byebug 9.1 support. As a result, Ruby 2.0 & Ruby 2.1 support has been dropped. 78 | Pry-byebug no longer installs on these platforms. 79 | 80 | ## 3.4.3 (2017-08-22) 81 | 82 | ### Fixed 83 | 84 | * Installation on old rubies after byebug dropping support for them. 85 | 86 | ## 3.4.2 (2016-12-06) 87 | 88 | ### Fixed 89 | 90 | * Byebug doesn't start after `disable-pry` command. 91 | 92 | ## 3.4.1 (2016-11-22) 93 | 94 | ### Fixed 95 | 96 | * control_d handler not being required properly when `pry-byebug` loaded 97 | as a `pry` plugin and not through explicit require. 98 | 99 | ## 3.4.0 (2016-05-15) 100 | 101 | ### Fixed 102 | 103 | * Byebug 9 compatibility. 104 | 105 | ### Added 106 | 107 | * A new `backtrace` command. 108 | 109 | ## 3.3.0 (2015-11-05) 110 | 111 | ### Fixed 112 | 113 | * Byebug 8 compatibility. 114 | * Fix encoding error in gemspec file (#70). 115 | * Debugger being too slow (#80, thanks @k0kubun). 116 | 117 | ## 3.2.0 (2015-07-18) 118 | 119 | ### Added 120 | 121 | * `continue` can now receive a line number argument (#56). 122 | 123 | ### Fixed 124 | 125 | * Conflicts with `break` and `next` Ruby keywords inside multiline statements 126 | (#44). 127 | 128 | ### Removed 129 | 130 | * `breaks` command. It was broken anyways (#47). 131 | 132 | ## 3.1.0 (2015-04-14) 133 | 134 | ### Added 135 | 136 | * Frame navigation commands `up`, `down` and `frame`. 137 | 138 | ## 3.0.1 (2015-04-02) 139 | 140 | ### Fixed 141 | 142 | * Several formatting and alignment issues. 143 | 144 | ## 3.0.0 (2015-02-02) 145 | 146 | ### Fixed 147 | 148 | * `binding.pry` would not stop at the correct place when called at the last 149 | line of a method/block. 150 | 151 | ### Removed 152 | 153 | * Stepping aliases for `next` (`n`), `step` (`s`), `finish` (`f`) and `continue` 154 | (`c`). See #34. 155 | 156 | ## 2.0.0 (2014-01-09) 157 | 158 | ### Fixed 159 | 160 | * Byebug 3 compatibility. 161 | * Pry not starting at the first line after `binding.pry` but at `binding.pry`. 162 | * `continue` not finishing pry instance (#13). 163 | 164 | ## 1.3.3 (2014-25-06) 165 | 166 | ### Fixed 167 | 168 | * Pry 0.10 series and further minor version level releases compatibility. 169 | 170 | ## 1.3.2 (2014-24-02) 171 | 172 | ### Fixed 173 | 174 | * Bug inherited from `byebug`. 175 | 176 | ## 1.3.1 (2014-08-02) 177 | 178 | ### Fixed 179 | 180 | * Bug #22 (thanks @andreychernih). 181 | 182 | ## 1.3.0 (2014-05-02) 183 | 184 | ### Added 185 | 186 | * Breakpoints on method names (thanks @andreychernih & @palkan). 187 | 188 | ### Fixed 189 | 190 | * "Undefined method `interface`" error (huge thanks to @andreychernih). 191 | 192 | ## 1.2.1 (2013-30-12) 193 | 194 | ### Fixed 195 | 196 | * "Uncaught throw :breakout_nav" error (thanks @lukebergen). 197 | 198 | ## 1.2.0 (2013-24-09) 199 | 200 | ### Fixed 201 | 202 | * Compatibility with byebug's 2.x series 203 | 204 | ## 1.1.2 (2013-11-07) 205 | 206 | ### Fixed 207 | 208 | * Compatibility with backwards compatible byebug versions. 209 | 210 | ## 1.1.1 (2013-02-07) 211 | 212 | ### Fixed 213 | 214 | * Bug when doing `step n` or `next n` where n > 1 right after `binding.pry`. 215 | 216 | ## 1.1.0 (2013-06-06) 217 | 218 | ### Added 219 | 220 | * `s`, `n`, `f` and `c` aliases (thanks @jgakos!). 221 | 222 | ## 1.0.1 (2013-05-07) 223 | 224 | ### Fixed 225 | 226 | * Unwanted debugging printf. 227 | 228 | ## 1.0.0 (2013-05-07) 229 | 230 | ### Added 231 | 232 | * Initial release forked from 233 | [pry-debugger](https://github.com/nixme/pry-debugger) to support byebug. 234 | 235 | ### Removed 236 | 237 | * pry-remote support. 238 | 239 | ## Older releases 240 | 241 | * Check [pry-debugger](https://github.com/nixme/pry-debugger)'s CHANGELOG. 242 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING 2 | 3 | Please note that this project is released with a [Contributor Code of 4 | Conduct](code_of_conduct.md). By participating in this project you agree to 5 | abide by its terms. 6 | 7 | ## Bug Reports 8 | 9 | * Try to reproduce the issue against the latest revision. There might be 10 | unrealeased work that fixes your problem! 11 | * Ensure that your issue has not already been reported. 12 | * Include the steps you carried out to produce the problem. If we can't 13 | reproduce it, we can't fix it. 14 | * Include the behavior you observed along with the behavior you expected, 15 | and why you expected it. 16 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | gemspec 6 | 7 | group :development do 8 | gem "rake", "~> 13.0" 9 | 10 | gem "chandler", "0.9.0" 11 | 12 | # To workaround octokit warning. Can be removed once 13 | # https://github.com/octokit/octokit.rb/pull/1706 is released 14 | gem "faraday-retry" 15 | 16 | gem "mdl", "0.13.0" 17 | gem "minitest", "~> 5.14" 18 | gem "minitest-bisect", "~> 1.5" 19 | gem "rubocop", "~> 1.0" 20 | end 21 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | pry-byebug (3.11.0) 5 | byebug (~> 12.0) 6 | pry (>= 0.13, < 0.16) 7 | 8 | GEM 9 | remote: https://rubygems.org/ 10 | specs: 11 | addressable (2.8.7) 12 | public_suffix (>= 2.0.2, < 7.0) 13 | ast (2.4.3) 14 | byebug (12.0.0) 15 | chandler (0.9.0) 16 | netrc 17 | octokit (>= 2.2.0) 18 | chef-utils (18.6.2) 19 | concurrent-ruby 20 | coderay (1.1.3) 21 | concurrent-ruby (1.3.5) 22 | drb (2.2.1) 23 | faraday (2.12.2) 24 | faraday-net_http (>= 2.0, < 3.5) 25 | json 26 | logger 27 | faraday-net_http (3.4.0) 28 | net-http (>= 0.5.0) 29 | faraday-retry (2.3.0) 30 | faraday (~> 2.0) 31 | json (2.10.2) 32 | kramdown (2.5.1) 33 | rexml (>= 3.3.9) 34 | kramdown-parser-gfm (1.1.0) 35 | kramdown (~> 2.0) 36 | language_server-protocol (3.17.0.4) 37 | lint_roller (1.1.0) 38 | logger (1.7.0) 39 | mdl (0.13.0) 40 | kramdown (~> 2.3) 41 | kramdown-parser-gfm (~> 1.1) 42 | mixlib-cli (~> 2.1, >= 2.1.1) 43 | mixlib-config (>= 2.2.1, < 4) 44 | mixlib-shellout 45 | method_source (1.1.0) 46 | minitest (5.25.5) 47 | minitest-bisect (1.7.0) 48 | minitest-server (~> 1.0) 49 | path_expander (~> 1.1) 50 | minitest-server (1.0.8) 51 | drb (~> 2.0) 52 | minitest (~> 5.16) 53 | mixlib-cli (2.1.8) 54 | mixlib-config (3.0.27) 55 | tomlrb 56 | mixlib-shellout (3.3.8) 57 | chef-utils 58 | net-http (0.6.0) 59 | uri 60 | netrc (0.11.0) 61 | octokit (9.2.0) 62 | faraday (>= 1, < 3) 63 | sawyer (~> 0.9) 64 | parallel (1.26.3) 65 | parser (3.3.7.3) 66 | ast (~> 2.4.1) 67 | racc 68 | path_expander (1.1.3) 69 | prism (1.4.0) 70 | pry (0.15.2) 71 | coderay (~> 1.1) 72 | method_source (~> 1.0) 73 | public_suffix (6.0.1) 74 | racc (1.8.1) 75 | rainbow (3.1.1) 76 | rake (13.2.1) 77 | regexp_parser (2.10.0) 78 | rexml (3.4.1) 79 | rubocop (1.75.1) 80 | json (~> 2.3) 81 | language_server-protocol (~> 3.17.0.2) 82 | lint_roller (~> 1.1.0) 83 | parallel (~> 1.10) 84 | parser (>= 3.3.0.2) 85 | rainbow (>= 2.2.2, < 4.0) 86 | regexp_parser (>= 2.9.3, < 3.0) 87 | rubocop-ast (>= 1.43.0, < 2.0) 88 | ruby-progressbar (~> 1.7) 89 | unicode-display_width (>= 2.4.0, < 4.0) 90 | rubocop-ast (1.43.0) 91 | parser (>= 3.3.7.2) 92 | prism (~> 1.4) 93 | ruby-progressbar (1.13.0) 94 | sawyer (0.9.2) 95 | addressable (>= 2.3.5) 96 | faraday (>= 0.17.3, < 3) 97 | tomlrb (2.0.3) 98 | unicode-display_width (3.1.4) 99 | unicode-emoji (~> 4.0, >= 4.0.4) 100 | unicode-emoji (4.0.4) 101 | uri (1.0.3) 102 | 103 | PLATFORMS 104 | ruby 105 | 106 | DEPENDENCIES 107 | chandler (= 0.9.0) 108 | faraday-retry 109 | mdl (= 0.13.0) 110 | minitest (~> 5.14) 111 | minitest-bisect (~> 1.5) 112 | pry-byebug! 113 | rake (~> 13.0) 114 | rubocop (~> 1.0) 115 | 116 | BUNDLED WITH 117 | 2.6.6 118 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 David Rodríguez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pry-byebug 2 | 3 | [![Version][VersionBadge]][VersionURL] 4 | [![Build][CIBadge]][CIURL] 5 | [![Inline docs][InchCIBadge]][InchCIURL] 6 | 7 | Adds step-by-step debugging and stack navigation capabilities to [pry] using 8 | [byebug]. 9 | 10 | To use, invoke pry normally. No need to start your script or app differently. 11 | Execution will stop in the first statement after your `binding.pry`. 12 | 13 | ```ruby 14 | def some_method 15 | puts 'Hello World' # Run 'step' in the console to move here 16 | end 17 | 18 | binding.pry 19 | some_method # Execution will stop here. 20 | puts 'Goodbye World' # Run 'next' in the console to move here. 21 | ``` 22 | 23 | ## Requirements 24 | 25 | MRI 2.4.0 or higher. 26 | 27 | ## Installation 28 | 29 | Add 30 | 31 | ```ruby 32 | gem 'pry-byebug' 33 | ``` 34 | 35 | to your Gemfile and run 36 | 37 | ```console 38 | bundle install 39 | ``` 40 | 41 | Make sure you include the gem globally or inside the `:test` group if you plan 42 | to use it to debug your tests! 43 | 44 | ## Commands 45 | 46 | ### Step-by-step debugging 47 | 48 | **break:** Manage breakpoints. 49 | 50 | **step:** Step execution into the next line or method. Takes an optional numeric 51 | argument to step multiple times. 52 | 53 | **next:** Step over to the next line within the same frame. Also takes an 54 | optional numeric argument to step multiple lines. 55 | 56 | **finish:** Execute until current stack frame returns. 57 | 58 | **continue:** Continue program execution and end the Pry session. 59 | 60 | ### Callstack navigation 61 | 62 | **backtrace:** Shows the current stack. You can use the numbers on the left 63 | side with the `frame` command to navigate the stack. 64 | 65 | **up:** Moves the stack frame up. Takes an optional numeric argument to move 66 | multiple frames. 67 | 68 | **down:** Moves the stack frame down. Takes an optional numeric argument to move 69 | multiple frames. 70 | 71 | **frame:** Moves to a specific frame. Called without arguments will show the 72 | current frame. 73 | 74 | ## Matching Byebug Behaviour 75 | 76 | If you're coming from Byebug or from Pry-Byebug versions previous to 3.0, you 77 | may be lacking the 'n', 's', 'c' and 'f' aliases for the stepping commands. 78 | These aliases were removed by default because they usually conflict with 79 | scratch variable names. But it's very easy to reenable them if you still want 80 | them, just add the following shortcuts to your `~/.pryrc` file: 81 | 82 | ```ruby 83 | if defined?(PryByebug) 84 | Pry.commands.alias_command 'c', 'continue' 85 | Pry.commands.alias_command 's', 'step' 86 | Pry.commands.alias_command 'n', 'next' 87 | Pry.commands.alias_command 'f', 'finish' 88 | end 89 | ``` 90 | 91 | Also, you might find useful as well the repeat the last command by just hitting 92 | the `Enter` key (e.g., with `step` or `next`). To achieve that, add this to 93 | your `~/.pryrc` file: 94 | 95 | ```ruby 96 | # Hit Enter to repeat last command 97 | Pry::Commands.command /^$/, "repeat last command" do 98 | pry_instance.run_command Pry.history.to_a.last 99 | end 100 | ``` 101 | 102 | ## Breakpoints 103 | 104 | You can set and adjust breakpoints directly from a Pry session using the 105 | `break` command: 106 | 107 | **break:** Set a new breakpoint from a line number in the current file, a file 108 | and line number, or a method. Pass an optional expression to create a 109 | conditional breakpoint. Edit existing breakpoints via various flags. 110 | 111 | Examples: 112 | 113 | ```ruby 114 | break SomeClass#run # Break at the start of `SomeClass#run`. 115 | break Foo#bar if baz? # Break at `Foo#bar` only if `baz?`. 116 | break app/models/user.rb:15 # Break at line 15 in user.rb. 117 | break 14 # Break at line 14 in the current file. 118 | 119 | break --condition 4 x > 2 # Change condition on breakpoint #4 to 'x > 2'. 120 | break --condition 3 # Remove the condition on breakpoint #3. 121 | 122 | break --delete 5 # Delete breakpoint #5. 123 | break --disable-all # Disable all breakpoints. 124 | 125 | break # List all breakpoints. 126 | break --show 2 # Show details about breakpoint #2. 127 | ``` 128 | 129 | Type `break --help` from a Pry session to see all available options. 130 | 131 | ## Alternatives 132 | 133 | Note that all of the alternatives here are incompatible with pry-byebug. If 134 | your platform is supported by pry-byebug, you should remove any of the gems 135 | mentioned here if they are present in your Gemfile. 136 | 137 | * [pry-debugger]: Provides step-by-step debugging for MRI 1.9.3 or older 138 | rubies. If you're still using those and need a step-by-step debugger to help 139 | with the upgrade, pry-debugger can be handy. 140 | 141 | * [pry-stack_explorer]: Provides stack navigation capabilities for MRI 1.9.3 or 142 | older rubies. If you're still using those and need to navigate your stack to 143 | help with the upgrade, pry-stack_explorer can be handy. 144 | 145 | * [pry-nav]: Provides step-by-step debugging for JRuby. 146 | 147 | ## Contribute 148 | 149 | See [Getting Started with Development](CONTRIBUTING.md). 150 | 151 | ## Funding 152 | 153 | Subscribe to [Tidelift] to ensure pry-byebug stays actively maintained, and at 154 | the same time get licensing assurances and timely security notifications for 155 | your open source dependencies. 156 | 157 | You can also help `pry-byebug` by leaving a small (or big) tip through [Liberapay]. 158 | 159 | [Tidelift]: https://tidelift.com/subscription/pkg/rubygems-pry-byebug?utm_source=rubygems-pry-byebug&utm_medium=referral&utm_campaign=readme 160 | [Liberapay]: https://liberapay.com/pry-byebug/donate 161 | 162 | ## Security contact information 163 | 164 | Please use the Tidelift security contact to [report a security vulnerability]. 165 | Tidelift will coordinate the fix and disclosure. 166 | 167 | [report a security vulnerability]: https://tidelift.com/security 168 | 169 | ## Credits 170 | 171 | * Gopal Patel (@nixme), creator of [pry-debugger], and everybody who contributed 172 | to it. pry-byebug is a fork of pry-debugger so it wouldn't exist as it is 173 | without those contributions. 174 | * John Mair (@banister), creator of [pry]. 175 | 176 | Patches and bug reports are welcome. 177 | 178 | [pry]: https://pry.github.io 179 | [byebug]: https://github.com/deivid-rodriguez/byebug 180 | [pry-debugger]: https://github.com/nixme/pry-debugger 181 | [pry-nav]: https://github.com/nixme/pry-nav 182 | [pry-stack_explorer]: https://github.com/pry/pry-stack_explorer 183 | 184 | [VersionBadge]: https://badge.fury.io/rb/pry-byebug.svg 185 | [VersionURL]: http://badge.fury.io/rb/pry-byebug 186 | [CIBadge]: https://github.com/deivid-rodriguez/pry-byebug/workflows/ubuntu/badge.svg?branch=master 187 | [CIURL]: https://github.com/deivid-rodriguez/pry-byebug/actions?query=workflow%3Aubuntu 188 | [InchCIBadge]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug.svg?branch=master 189 | [InchCIURL]: http://inch-ci.org/github/deivid-rodriguez/pry-byebug 190 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "bundler/gem_tasks" 4 | require "chandler/tasks" 5 | require "rake/testtask" 6 | require "rubocop/rake_task" 7 | 8 | # 9 | # Add chandler as a prerequisite for `rake release` 10 | # 11 | task "release:rubygem_push" => "chandler:push" 12 | 13 | desc "Run tests" 14 | Rake::TestTask.new(:test) do |t| 15 | t.libs << "test" 16 | t.warning = false 17 | t.verbose = true 18 | t.pattern = "test/**/*_test.rb" 19 | end 20 | 21 | RuboCop::RakeTask.new 22 | 23 | desc "Checks markdown code style with Markdownlint" 24 | task :mdl do 25 | puts "Running mdl..." 26 | 27 | abort unless system("mdl", *Dir.glob("*.md")) 28 | end 29 | 30 | task default: %i[test rubocop mdl] 31 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | require "rubygems" 5 | 6 | m = Module.new do 7 | extend self 8 | 9 | def invoked_as_script? 10 | File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__) 11 | end 12 | 13 | def cli_arg_version 14 | return unless invoked_as_script? # don't want to hijack other binstubs 15 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 16 | 17 | bundler_version = nil 18 | update_index = nil 19 | ARGV.each_with_index do |a, i| 20 | bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 21 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 22 | 23 | bundler_version = Regexp.last_match(1) || ">= 0.a" 24 | update_index = i 25 | end 26 | bundler_version 27 | end 28 | 29 | def gemfile 30 | File.expand_path("../Gemfile", __dir__) 31 | end 32 | 33 | def lockfile 34 | "#{gemfile}.lock" 35 | end 36 | 37 | def lockfile_version 38 | lockfile_contents = File.read(lockfile) 39 | 40 | regexp = /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 41 | 42 | regexp.match(lockfile_contents)[1] 43 | end 44 | 45 | def bundler_version 46 | @bundler_version ||= cli_arg_version || lockfile_version 47 | end 48 | 49 | def load_bundler! 50 | ENV["BUNDLE_GEMFILE"] ||= gemfile 51 | 52 | activate_bundler(bundler_version) 53 | end 54 | 55 | def activate_bundler(bundler_version) 56 | gem "bundler", bundler_version 57 | end 58 | end 59 | 60 | m.load_bundler! 61 | 62 | load Gem.bin_path("bundler", "bundle") if m.invoked_as_script? 63 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 5 | 6 | load File.expand_path("bundle", __dir__) 7 | 8 | require "bundler/setup" 9 | 10 | load Gem.bin_path("rake", "rake") 11 | -------------------------------------------------------------------------------- /bin/rubocop: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 5 | 6 | load File.expand_path("bundle", __dir__) 7 | 8 | require "bundler/setup" 9 | 10 | load Gem.bin_path("rubocop", "rubocop") 11 | -------------------------------------------------------------------------------- /code_of_conduct.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at deivid.rodriguez@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 71 | version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /lib/byebug/processors/pry_processor.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "byebug/core" 4 | 5 | module Byebug 6 | # 7 | # Extends raw byebug's processor. 8 | # 9 | class PryProcessor < CommandProcessor 10 | attr_accessor :pry 11 | 12 | extend Forwardable 13 | def_delegators :@pry, :output 14 | def_delegators Pry::Helpers::Text, :bold 15 | 16 | def self.start 17 | Byebug.start 18 | Setting[:autolist] = false 19 | Context.processor = self 20 | Byebug.current_context.step_out(5, true) 21 | end 22 | 23 | # 24 | # Wrap a Pry REPL to catch navigational commands and act on them. 25 | # 26 | def run(&_block) 27 | return_value = nil 28 | 29 | command = catch(:breakout_nav) do # Throws from PryByebug::Commands 30 | return_value = allowing_other_threads { yield } 31 | {} # Nothing thrown == no navigational command 32 | end 33 | 34 | # Pry instance to resume after stepping 35 | @pry = command[:pry] 36 | 37 | perform(command[:action], command[:options]) 38 | 39 | return_value 40 | end 41 | 42 | # 43 | # Set up a number of navigational commands to be performed by Byebug. 44 | # 45 | def perform(action, options = {}) 46 | return unless %i[ 47 | backtrace 48 | down 49 | finish 50 | frame 51 | next 52 | step 53 | up 54 | ].include?(action) 55 | 56 | send("perform_#{action}", options) 57 | end 58 | 59 | # --- Callbacks from byebug C extension --- 60 | 61 | # 62 | # Called when the debugger wants to stop at a regular line 63 | # 64 | def at_line 65 | resume_pry 66 | end 67 | 68 | # 69 | # Called when the debugger wants to stop right before a method return 70 | # 71 | def at_return(_return_value) 72 | resume_pry 73 | end 74 | 75 | # 76 | # Called when a breakpoint is hit. Note that `at_line`` is called 77 | # inmediately after with the context's `stop_reason == :breakpoint`, so we 78 | # must not resume the pry instance here 79 | # 80 | def at_breakpoint(breakpoint) 81 | @pry ||= Pry.new 82 | 83 | output.puts bold("\n Breakpoint #{breakpoint.id}. ") + n_hits(breakpoint) 84 | 85 | expr = breakpoint.expr 86 | return unless expr 87 | 88 | output.puts bold("Condition: ") + expr 89 | end 90 | 91 | private 92 | 93 | def n_hits(breakpoint) 94 | n_hits = breakpoint.hit_count 95 | 96 | n_hits == 1 ? "First hit" : "Hit #{n_hits} times." 97 | end 98 | 99 | # 100 | # Resume an existing Pry REPL at the paused point. 101 | # 102 | def resume_pry 103 | new_binding = frame._binding 104 | 105 | run do 106 | if defined?(@pry) && @pry 107 | @pry.repl(new_binding) 108 | else 109 | @pry = Pry::REPL.start_without_pry_byebug(target: new_binding) 110 | end 111 | end 112 | end 113 | 114 | def perform_backtrace(_options) 115 | Byebug::WhereCommand.new(self, "backtrace").execute 116 | 117 | resume_pry 118 | end 119 | 120 | def perform_next(options) 121 | lines = (options[:lines] || 1).to_i 122 | context.step_over(lines, frame.pos) 123 | end 124 | 125 | def perform_step(options) 126 | times = (options[:times] || 1).to_i 127 | context.step_into(times, frame.pos) 128 | end 129 | 130 | def perform_finish(*) 131 | context.step_out(1) 132 | end 133 | 134 | def perform_up(options) 135 | times = (options[:times] || 1).to_i 136 | 137 | Byebug::UpCommand.new(self, "up #{times}").execute 138 | 139 | resume_pry 140 | end 141 | 142 | def perform_down(options) 143 | times = (options[:times] || 1).to_i 144 | 145 | Byebug::DownCommand.new(self, "down #{times}").execute 146 | 147 | resume_pry 148 | end 149 | 150 | def perform_frame(options) 151 | index = options[:index] ? options[:index].to_i : "" 152 | 153 | Byebug::FrameCommand.new(self, "frame #{index}").execute 154 | 155 | resume_pry 156 | end 157 | end 158 | end 159 | -------------------------------------------------------------------------------- /lib/pry-byebug.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry" 4 | require "pry-byebug/cli" 5 | -------------------------------------------------------------------------------- /lib/pry-byebug/base.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/location" 4 | 5 | # 6 | # Main container module for Pry-Byebug functionality 7 | # 8 | module PryByebug 9 | # Reference to currently running pry-remote server. Used by the processor. 10 | attr_accessor :current_remote_server 11 | 12 | module_function 13 | 14 | # 15 | # Checks that a target binding is in a local file context. 16 | # 17 | def file_context?(target) 18 | file = Helpers::Location.current_file(target) 19 | file == Pry.eval_path || !Pry::Helpers::BaseHelpers.not_a_real_file?(file) 20 | end 21 | 22 | # 23 | # Ensures that a command is executed in a local file context. 24 | # 25 | def check_file_context(target, msg = nil) 26 | msg ||= "Cannot find local context. Did you use `binding.pry`?" 27 | raise(Pry::CommandError, msg) unless file_context?(target) 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/pry-byebug/cli.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/base" 4 | require "pry-byebug/pry_ext" 5 | require "pry-byebug/commands" 6 | require "pry-byebug/control_d_handler" 7 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/commands/backtrace" 4 | require "pry-byebug/commands/next" 5 | require "pry-byebug/commands/step" 6 | require "pry-byebug/commands/continue" 7 | require "pry-byebug/commands/finish" 8 | require "pry-byebug/commands/up" 9 | require "pry-byebug/commands/down" 10 | require "pry-byebug/commands/frame" 11 | require "pry-byebug/commands/breakpoint" 12 | require "pry-byebug/commands/exit_all" 13 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/backtrace.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | 5 | module PryByebug 6 | # 7 | # Display the current stack 8 | # 9 | class BacktraceCommand < Pry::ClassCommand 10 | include Helpers::Navigation 11 | 12 | match "backtrace" 13 | group "Byebug" 14 | 15 | description "Display the current stack." 16 | 17 | banner <<-BANNER 18 | Usage: backtrace 19 | 20 | Display the current stack. 21 | BANNER 22 | 23 | def process 24 | PryByebug.check_file_context(target) 25 | 26 | breakout_navigation :backtrace 27 | end 28 | end 29 | end 30 | 31 | Pry::Commands.add_command(PryByebug::BacktraceCommand) 32 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/breakpoint.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry/byebug/breakpoints" 4 | require "pry-byebug/helpers/breakpoints" 5 | require "pry-byebug/helpers/location" 6 | require "pry-byebug/helpers/multiline" 7 | 8 | module PryByebug 9 | # 10 | # Add, show and remove breakpoints 11 | # 12 | class BreakCommand < Pry::ClassCommand 13 | include Helpers::Breakpoints 14 | include Helpers::Location 15 | include Helpers::Multiline 16 | 17 | match "break" 18 | group "Byebug" 19 | description "Set or edit a breakpoint." 20 | 21 | banner <<-BANNER 22 | Usage: break [if CONDITION] 23 | break --condition N [CONDITION] 24 | break [--show | --delete | --enable | --disable] N 25 | break [--delete-all | --disable-all] 26 | break 27 | 28 | Set a breakpoint. Accepts a line number in the current file, a file and 29 | line number, or a method, and an optional condition. 30 | 31 | Pass appropriate flags to manipulate existing breakpoints. 32 | 33 | Examples: 34 | 35 | break SomeClass#run Break at the start of `SomeClass#run`. 36 | break Foo#bar if baz? Break at `Foo#bar` only if `baz?`. 37 | break app/models/user.rb:15 Break at line 15 in user.rb. 38 | break 14 Break at line 14 in the current file. 39 | 40 | break --condition 4 x > 2 Add/change condition on breakpoint #4. 41 | break --condition 3 Remove the condition on breakpoint #3. 42 | 43 | break --delete 5 Delete breakpoint #5. 44 | break --disable-all Disable all breakpoints. 45 | 46 | break --show 2 Show details about breakpoint #2. 47 | break List all breakpoints. 48 | BANNER 49 | 50 | def options(opt) 51 | defaults = { argument: true, as: Integer } 52 | 53 | opt.on :c, :condition, "Change condition of a breakpoint.", defaults 54 | opt.on :s, :show, "Show breakpoint details and source.", defaults 55 | opt.on :D, :delete, "Delete a breakpoint.", defaults 56 | opt.on :d, :disable, "Disable a breakpoint.", defaults 57 | opt.on :e, :enable, "Enable a disabled breakpoint.", defaults 58 | opt.on :'disable-all', "Disable all breakpoints." 59 | opt.on :'delete-all', "Delete all breakpoints." 60 | end 61 | 62 | def process 63 | return if check_multiline_context 64 | 65 | PryByebug.check_file_context(target) 66 | 67 | option, = opts.to_hash.find { |key, _value| opts.present?(key) } 68 | return send(option_to_method(option)) if option 69 | 70 | return new_breakpoint unless args.empty? 71 | 72 | print_all 73 | end 74 | 75 | private 76 | 77 | %w[delete disable enable disable_all delete_all].each do |command| 78 | define_method(:"process_#{command}") do 79 | breakpoints.send(*[command, opts[command]].compact) 80 | print_all 81 | end 82 | end 83 | 84 | def process_show 85 | print_full_breakpoint(breakpoints.find_by_id(opts[:show])) 86 | end 87 | 88 | def process_condition 89 | expr = args.empty? ? nil : args.join(" ") 90 | breakpoints.change(opts[:condition], expr) 91 | end 92 | 93 | def new_breakpoint 94 | place = args.shift 95 | condition = args.join(" ") if args.shift == "if" 96 | 97 | bp = add_breakpoint(place, condition) 98 | 99 | print_full_breakpoint(bp) 100 | end 101 | 102 | def option_to_method(option) 103 | "process_#{option.to_s.tr('-', '_')}" 104 | end 105 | 106 | def print_all 107 | print_breakpoints_header 108 | breakpoints.each { |b| print_short_breakpoint(b) } 109 | end 110 | 111 | def add_breakpoint(place, condition) 112 | case place 113 | when /^(\d+)$/ 114 | errmsg = "Line number declaration valid only in a file context." 115 | PryByebug.check_file_context(target, errmsg) 116 | 117 | lineno = Regexp.last_match[1].to_i 118 | breakpoints.add_file(current_file, lineno, condition) 119 | when /^(.+):(\d+)$/ 120 | file = Regexp.last_match[1] 121 | lineno = Regexp.last_match[2].to_i 122 | breakpoints.add_file(file, lineno, condition) 123 | when /^(.*)[.#].+$/ # Method or class name 124 | if Regexp.last_match[1].strip.empty? 125 | errmsg = "Method name declaration valid only in a file context." 126 | PryByebug.check_file_context(target, errmsg) 127 | place = target.eval("self.class.to_s") + place 128 | end 129 | breakpoints.add_method(place, condition) 130 | else 131 | raise(ArgumentError, "Cannot identify arguments as breakpoint") 132 | end 133 | end 134 | end 135 | end 136 | 137 | Pry::Commands.add_command(PryByebug::BreakCommand) 138 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/continue.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | require "pry-byebug/helpers/breakpoints" 5 | require "pry-byebug/helpers/location" 6 | 7 | module PryByebug 8 | # 9 | # Continue program execution until the next breakpoint 10 | # 11 | class ContinueCommand < Pry::ClassCommand 12 | include Helpers::Navigation 13 | include Helpers::Breakpoints 14 | include Helpers::Location 15 | 16 | match "continue" 17 | group "Byebug" 18 | description "Continue program execution and end the Pry session." 19 | 20 | banner <<-BANNER 21 | Usage: continue [LINE] 22 | 23 | Continue program execution until the next breakpoint, or the program 24 | ends. Optionally continue to the specified line number. 25 | 26 | Examples: 27 | continue #=> Continue until the next breakpoint. 28 | continue 4 #=> Continue to line number 4. 29 | BANNER 30 | 31 | def process 32 | PryByebug.check_file_context(target) 33 | 34 | breakpoints.add_file(current_file, args.first.to_i) if args.first 35 | 36 | breakout_navigation :continue 37 | ensure 38 | Byebug.stop if Byebug.stoppable? 39 | end 40 | end 41 | end 42 | 43 | Pry::Commands.add_command(PryByebug::ContinueCommand) 44 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/down.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | 5 | module PryByebug 6 | # 7 | # Travel down the frame stack 8 | # 9 | class DownCommand < Pry::ClassCommand 10 | include Helpers::Navigation 11 | 12 | match "down" 13 | group "Byebug" 14 | 15 | description "Move current frame down." 16 | 17 | banner <<-BANNER 18 | Usage: down [TIMES] 19 | 20 | Move current frame down. By default, moves by 1 frame. 21 | 22 | Examples: 23 | down #=> Move down 1 frame. 24 | down 5 #=> Move down 5 frames. 25 | BANNER 26 | 27 | def process 28 | PryByebug.check_file_context(target) 29 | 30 | breakout_navigation :down, times: args.first 31 | end 32 | end 33 | end 34 | 35 | Pry::Commands.add_command(PryByebug::DownCommand) 36 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/exit_all.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry/commands/exit_all" 4 | 5 | module PryByebug 6 | # 7 | # Exit pry REPL with Byebug.stop 8 | # 9 | class ExitAllCommand < Pry::Command::ExitAll 10 | def process 11 | super 12 | ensure 13 | Byebug.stop if Byebug.stoppable? 14 | end 15 | end 16 | end 17 | 18 | Pry::Commands.add_command(PryByebug::ExitAllCommand) 19 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/finish.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | 5 | module PryByebug 6 | # 7 | # Run until the end of current frame 8 | # 9 | class FinishCommand < Pry::ClassCommand 10 | include PryByebug::Helpers::Navigation 11 | 12 | match "finish" 13 | group "Byebug" 14 | description "Execute until current stack frame returns." 15 | 16 | banner <<-BANNER 17 | Usage: finish 18 | BANNER 19 | 20 | def process 21 | PryByebug.check_file_context(target) 22 | 23 | breakout_navigation :finish 24 | end 25 | end 26 | end 27 | 28 | Pry::Commands.add_command(PryByebug::FinishCommand) 29 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/frame.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | 5 | module PryByebug 6 | # 7 | # Move to a specific frame in the callstack 8 | # 9 | class FrameCommand < Pry::ClassCommand 10 | include Helpers::Navigation 11 | 12 | match "frame" 13 | group "Byebug" 14 | 15 | description "Move to specified frame #." 16 | 17 | banner <<-BANNER 18 | Usage: frame [TIMES] 19 | 20 | Move to specified frame #. 21 | 22 | Examples: 23 | frame #=> Show current frame #. 24 | frame 5 #=> Move to frame 5. 25 | BANNER 26 | 27 | def process 28 | PryByebug.check_file_context(target) 29 | 30 | breakout_navigation :frame, index: args.first 31 | end 32 | end 33 | end 34 | 35 | Pry::Commands.add_command(PryByebug::FrameCommand) 36 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/next.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | require "pry-byebug/helpers/multiline" 5 | 6 | module PryByebug 7 | # 8 | # Run a number of lines and then stop again 9 | # 10 | class NextCommand < Pry::ClassCommand 11 | include Helpers::Navigation 12 | include Helpers::Multiline 13 | 14 | match "next" 15 | group "Byebug" 16 | description "Execute the next line within the current stack frame." 17 | 18 | banner <<-BANNER 19 | Usage: next [LINES] 20 | 21 | Step over within the same frame. By default, moves forward a single 22 | line. 23 | 24 | Examples: 25 | next #=> Move a single line forward. 26 | next 4 #=> Execute the next 4 lines. 27 | BANNER 28 | 29 | def process 30 | return if check_multiline_context 31 | 32 | PryByebug.check_file_context(target) 33 | 34 | breakout_navigation :next, lines: args.first 35 | end 36 | end 37 | end 38 | 39 | Pry::Commands.add_command(PryByebug::NextCommand) 40 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/step.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | 5 | module PryByebug 6 | # 7 | # Run a number of Ruby statements and then stop again 8 | # 9 | class StepCommand < Pry::ClassCommand 10 | include Helpers::Navigation 11 | 12 | match "step" 13 | group "Byebug" 14 | description "Step execution into the next line or method." 15 | 16 | banner <<-BANNER 17 | Usage: step [TIMES] 18 | 19 | Step execution forward. By default, moves a single step. 20 | 21 | Examples: 22 | step #=> Move a single step forward. 23 | step 5 #=> Execute the next 5 steps. 24 | BANNER 25 | 26 | def process 27 | PryByebug.check_file_context(target) 28 | 29 | breakout_navigation :step, times: args.first 30 | end 31 | end 32 | end 33 | 34 | Pry::Commands.add_command(PryByebug::StepCommand) 35 | -------------------------------------------------------------------------------- /lib/pry-byebug/commands/up.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-byebug/helpers/navigation" 4 | 5 | module PryByebug 6 | # 7 | # Travel up the frame stack 8 | # 9 | class UpCommand < Pry::ClassCommand 10 | include Helpers::Navigation 11 | 12 | match "up" 13 | group "Byebug" 14 | 15 | description "Move current frame up." 16 | 17 | banner <<-BANNER 18 | Usage: up [TIMES] 19 | 20 | Move current frame up. By default, moves by 1 frame. 21 | 22 | Examples: 23 | up #=> Move up 1 frame. 24 | up 5 #=> Move up 5 frames. 25 | BANNER 26 | 27 | def process 28 | PryByebug.check_file_context(target) 29 | 30 | breakout_navigation :up, times: args.first 31 | end 32 | end 33 | end 34 | 35 | Pry::Commands.add_command(PryByebug::UpCommand) 36 | -------------------------------------------------------------------------------- /lib/pry-byebug/control_d_handler.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | original_handler = Pry.config.control_d_handler 4 | 5 | Pry.config.control_d_handler = proc do |pry_instance| 6 | Byebug.stop if Byebug.stoppable? 7 | 8 | original_handler.call(pry_instance) 9 | end 10 | -------------------------------------------------------------------------------- /lib/pry-byebug/helpers/breakpoints.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "byebug" 4 | 5 | module PryByebug 6 | module Helpers 7 | # 8 | # Common helpers for breakpoint related commands 9 | # 10 | module Breakpoints 11 | # 12 | # Byebug's array of breakpoints. 13 | # 14 | def breakpoints 15 | Pry::Byebug::Breakpoints 16 | end 17 | 18 | # 19 | # Prints a message with bold font. 20 | # 21 | def bold_puts(msg) 22 | output.puts(bold(msg)) 23 | end 24 | 25 | # 26 | # Print out full information about a breakpoint. 27 | # 28 | # Includes surrounding code at that point. 29 | # 30 | def print_full_breakpoint(breakpoint) 31 | header = "Breakpoint #{breakpoint.id}:" 32 | status = breakpoint.enabled? ? "Enabled" : "Disabled" 33 | code = breakpoint.source_code.with_line_numbers.to_s 34 | condition = if breakpoint.expr 35 | "#{bold('Condition:')} #{breakpoint.expr}\n" 36 | else 37 | "" 38 | end 39 | 40 | output.puts <<-BREAKPOINT.gsub(/ {8}/, "") 41 | 42 | #{bold(header)} #{breakpoint} (#{status}) #{condition} 43 | 44 | #{code} 45 | 46 | BREAKPOINT 47 | end 48 | 49 | # 50 | # Print out concise information about a breakpoint. 51 | # 52 | def print_short_breakpoint(breakpoint) 53 | id = format("%*d", max_width, breakpoint.id) 54 | status = breakpoint.enabled? ? "Yes" : "No " 55 | expr = breakpoint.expr ? " #{breakpoint.expr} " : "" 56 | 57 | output.puts(" #{id} #{status} #{breakpoint}#{expr}") 58 | end 59 | 60 | # 61 | # Prints a header for the breakpoint list. 62 | # 63 | def print_breakpoints_header 64 | header = "#{' ' * (max_width - 1)}# Enabled At " 65 | 66 | output.puts <<-BREAKPOINTS.gsub(/ {8}/, "") 67 | 68 | #{bold(header)} 69 | #{bold('-' * header.size)} 70 | 71 | BREAKPOINTS 72 | end 73 | 74 | # 75 | # Max width of breakpoints id column 76 | # 77 | def max_width 78 | breakpoints.last ? breakpoints.last.id.to_s.length : 1 79 | end 80 | end 81 | end 82 | end 83 | -------------------------------------------------------------------------------- /lib/pry-byebug/helpers/location.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module PryByebug 4 | module Helpers 5 | # 6 | # Compatibility helper to handle source location 7 | # 8 | module Location 9 | module_function 10 | 11 | # 12 | # Current file in the target binding. Used as the default breakpoint 13 | # location. 14 | # 15 | def current_file(source = target) 16 | # Guard clause for Ruby >= 2.6 providing now Binding#source_location ... 17 | return source.source_location[0] if source.respond_to?(:source_location) 18 | 19 | # ... to avoid warning: 'eval may not return location in binding' 20 | source.eval("__FILE__") 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/pry-byebug/helpers/multiline.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module PryByebug 4 | module Helpers 5 | # 6 | # Helpers to help handling multiline inputs 7 | # 8 | module Multiline 9 | # 10 | # Returns true if we are in a multiline context and, as a side effect, 11 | # updates the partial evaluation string with the current input. 12 | # 13 | # Returns false otherwise 14 | # 15 | def check_multiline_context 16 | return false if eval_string.empty? 17 | 18 | eval_string.replace("#{eval_string}#{match} #{arg_string}\n") 19 | true 20 | end 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /lib/pry-byebug/helpers/navigation.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module PryByebug 4 | module Helpers 5 | # 6 | # Helpers to aid breaking out of the REPL loop 7 | # 8 | module Navigation 9 | # 10 | # Breaks out of the REPL loop and signals tracer 11 | # 12 | def breakout_navigation(action, options = {}) 13 | pry_instance.binding_stack.clear 14 | 15 | throw :breakout_nav, action: action, options: options, pry: pry_instance 16 | end 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/pry-byebug/pry_ext.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "byebug/processors/pry_processor" 4 | 5 | class << Pry::REPL 6 | alias start_without_pry_byebug start 7 | 8 | def start_with_pry_byebug(options = {}) 9 | target = options[:target] 10 | 11 | if target.is_a?(Binding) && PryByebug.file_context?(target) 12 | Byebug::PryProcessor.start unless ENV["DISABLE_PRY"] 13 | else 14 | # No need for the tracer unless we have a file context to step through 15 | start_without_pry_byebug(options) 16 | end 17 | end 18 | 19 | alias start start_with_pry_byebug 20 | end 21 | -------------------------------------------------------------------------------- /lib/pry-byebug/pry_remote_ext.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "pry-remote" 4 | 5 | module PryRemote 6 | # 7 | # Overrides PryRemote::Server 8 | # 9 | class Server 10 | # 11 | # Override the call to Pry.start to save off current Server, and not 12 | # teardown the server right after Pry.start finishes. 13 | # 14 | def run 15 | raise("Already running a pry-remote session!") if 16 | PryByebug.current_remote_server 17 | 18 | PryByebug.current_remote_server = self 19 | 20 | setup 21 | Pry.start @object, input: client.input_proxy, output: client.output 22 | end 23 | 24 | # 25 | # Override to reset our saved global current server session. 26 | # 27 | alias teardown_without_pry_byebug teardown 28 | def teardown_with_pry_byebug 29 | return if @torn 30 | 31 | teardown_without_pry_byebug 32 | PryByebug.current_remote_server = nil 33 | @torn = true 34 | end 35 | alias teardown teardown_with_pry_byebug 36 | end 37 | end 38 | 39 | # Ensure cleanup when a program finishes without another break. For example, 40 | # 'next' on the last line of a program won't hit Byebug::PryProcessor#run, 41 | # which normally handles cleanup. 42 | at_exit do 43 | PryByebug.current_remote_server&.teardown 44 | end 45 | -------------------------------------------------------------------------------- /lib/pry-byebug/version.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Main container module for Pry-Byebug functionality 5 | # 6 | module PryByebug 7 | VERSION = "3.11.0" 8 | end 9 | -------------------------------------------------------------------------------- /lib/pry/byebug/breakpoints.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Pry 4 | module Byebug 5 | # 6 | # Wrapper for Byebug.breakpoints that respects our Processor and has better 7 | # failure behavior. Acts as an Enumerable. 8 | # 9 | module Breakpoints 10 | extend Enumerable 11 | extend self 12 | 13 | # 14 | # Breakpoint in a file:line location 15 | # 16 | class FileBreakpoint < SimpleDelegator 17 | def source_code 18 | Pry::Code.from_file(source).around(pos, 3).with_marker(pos) 19 | end 20 | 21 | def to_s 22 | "#{source} @ #{pos}" 23 | end 24 | end 25 | 26 | # 27 | # Breakpoint in a Class#method location 28 | # 29 | class MethodBreakpoint < SimpleDelegator 30 | def initialize(byebug_bp, method) 31 | __setobj__ byebug_bp 32 | @method = method 33 | end 34 | 35 | def source_code 36 | Pry::Code.from_method(Pry::Method.from_str(@method)) 37 | end 38 | 39 | def to_s 40 | @method 41 | end 42 | end 43 | 44 | def breakpoints 45 | @breakpoints ||= [] 46 | end 47 | 48 | # 49 | # Adds a method breakpoint. 50 | # 51 | def add_method(method, expression = nil) 52 | validate_expression expression 53 | owner, name = method.split(/[\.#]/) 54 | byebug_bp = ::Byebug::Breakpoint.add(owner, name.to_sym, expression) 55 | bp = MethodBreakpoint.new byebug_bp, method 56 | breakpoints << bp 57 | bp 58 | end 59 | 60 | # 61 | # Adds a file breakpoint. 62 | # 63 | def add_file(file, line, expression = nil) 64 | real_file = (file != Pry.eval_path) 65 | raise(ArgumentError, "Invalid file!") if real_file && !File.exist?(file) 66 | 67 | validate_expression expression 68 | 69 | path = (real_file ? File.expand_path(file) : file) 70 | bp = FileBreakpoint.new ::Byebug::Breakpoint.add(path, line, expression) 71 | breakpoints << bp 72 | bp 73 | end 74 | 75 | # 76 | # Changes the conditional expression for a breakpoint. 77 | # 78 | def change(id, expression = nil) 79 | validate_expression expression 80 | 81 | breakpoint = find_by_id(id) 82 | breakpoint.expr = expression 83 | breakpoint 84 | end 85 | 86 | # 87 | # Deletes an existing breakpoint with the given ID. 88 | # 89 | def delete(id) 90 | deleted = 91 | ::Byebug::Breakpoint.remove(id) && 92 | breakpoints.delete(find_by_id(id)) 93 | 94 | raise(ArgumentError, "No breakpoint ##{id}") unless deleted 95 | end 96 | 97 | # 98 | # Deletes all breakpoints. 99 | # 100 | def delete_all 101 | @breakpoints = [] 102 | ::Byebug.breakpoints.clear 103 | end 104 | 105 | # 106 | # Enables a disabled breakpoint with the given ID. 107 | # 108 | def enable(id) 109 | change_status id, true 110 | end 111 | 112 | # 113 | # Disables a breakpoint with the given ID. 114 | # 115 | def disable(id) 116 | change_status id, false 117 | end 118 | 119 | # 120 | # Disables all breakpoints. 121 | # 122 | def disable_all 123 | each do |breakpoint| 124 | breakpoint.enabled = false 125 | end 126 | end 127 | 128 | def to_a 129 | breakpoints 130 | end 131 | 132 | def size 133 | to_a.size 134 | end 135 | 136 | def each(&block) 137 | to_a.each(&block) 138 | end 139 | 140 | def last 141 | to_a.last 142 | end 143 | 144 | def find_by_id(id) 145 | breakpoint = find { |b| b.id == id } 146 | raise(ArgumentError, "No breakpoint ##{id}!") unless breakpoint 147 | 148 | breakpoint 149 | end 150 | 151 | private 152 | 153 | def change_status(id, enabled = true) 154 | breakpoint = find_by_id(id) 155 | breakpoint.enabled = enabled 156 | breakpoint 157 | end 158 | 159 | def validate_expression(exp) 160 | valid = exp && (exp.empty? || !Pry::Code.complete_expression?(exp)) 161 | return unless valid 162 | 163 | raise("Invalid breakpoint conditional: #{expression}") 164 | end 165 | end 166 | end 167 | end 168 | -------------------------------------------------------------------------------- /pry-byebug.gemspec: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require File.dirname(__FILE__) + "/lib/pry-byebug/version" 4 | 5 | Gem::Specification.new do |gem| 6 | gem.name = "pry-byebug" 7 | gem.version = PryByebug::VERSION 8 | gem.authors = ["David Rodríguez", "Gopal Patel"] 9 | gem.email = "deivid.rodriguez@gmail.com" 10 | gem.license = "MIT" 11 | gem.homepage = "https://github.com/deivid-rodriguez/pry-byebug" 12 | gem.summary = "Fast debugging with Pry." 13 | gem.description = "Combine 'pry' with 'byebug'. Adds 'step', 'next', 'finish', 14 | 'continue' and 'break' commands to control execution." 15 | 16 | gem.files = Dir["lib/**/*.rb", "LICENSE"] 17 | gem.extra_rdoc_files = %w[CHANGELOG.md README.md] 18 | gem.require_path = "lib" 19 | gem.executables = [] 20 | 21 | gem.metadata = { 22 | "bug_tracker_uri" => "https://github.com/deivid-rodriguez/pry-byebug/issues", 23 | "changelog_uri" => "https://github.com/deivid-rodriguez/pry-byebug/blob/HEAD/CHANGELOG.md", 24 | "source_code_uri" => "https://github.com/deivid-rodriguez/pry-byebug", 25 | "funding_uri" => "https://liberapay.com/pry-byebug" 26 | } 27 | 28 | # Dependencies 29 | gem.required_ruby_version = ">= 3.1.0" 30 | 31 | gem.add_runtime_dependency "byebug", "~> 12.0" 32 | gem.add_runtime_dependency "pry", ">= 0.13", "< 0.16" 33 | end 34 | -------------------------------------------------------------------------------- /test/base_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | # 6 | # Checks current pry-byebug's context. 7 | # 8 | class BaseTest < Minitest::Spec 9 | def test_main_file_context 10 | Pry.stub :eval_path, "
" do 11 | assert PryByebug.file_context?(TOPLEVEL_BINDING) 12 | end 13 | end 14 | 15 | def test_other_file_context 16 | Pry.stub :eval_path, "something" do 17 | refute PryByebug.file_context?(TOPLEVEL_BINDING) 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /test/breakpoints_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | # 6 | # Tests for pry-byebug breakpoints. 7 | # 8 | class BreakpointsTestGeneral < Minitest::Spec 9 | # 10 | # Minimal dummy example class. 11 | # 12 | class Tester 13 | def self.class_method; end 14 | 15 | def instance_method; end 16 | end 17 | 18 | def breakpoints_class 19 | Pry::Byebug::Breakpoints 20 | end 21 | 22 | def test_add_file_raises_argument_error 23 | Pry.stub :eval_path, "something" do 24 | assert_raises(ArgumentError) { breakpoints_class.add_file("file", 1) } 25 | end 26 | end 27 | 28 | def test_add_method_adds_instance_method_breakpoint 29 | breakpoints_class.add_method "BreakpointsTest::Tester#instance_method" 30 | bp = Byebug.breakpoints.last 31 | 32 | assert_equal "BreakpointsTest::Tester", bp.source 33 | assert_equal "instance_method", bp.pos 34 | 35 | breakpoints_class.delete_all 36 | end 37 | 38 | def test_add_method_adds_class_method_breakpoint 39 | breakpoints_class.add_method "BreakpointsTest::Tester.class_method" 40 | bp = Byebug.breakpoints.last 41 | 42 | assert_equal "BreakpointsTest::Tester", bp.source 43 | assert_equal "class_method", bp.pos 44 | 45 | breakpoints_class.delete_all 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /test/commands/breakpoints_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | # 6 | # Some common specs for breakpoints 7 | # 8 | module BreakpointSpecs 9 | def test_shows_breakpoint_enabled 10 | assert_match @regexp, @output.string 11 | end 12 | 13 | def test_shows_breakpoint_hit 14 | assert_match @regexp, @output.string 15 | 16 | match = @output.string.match(@regexp) 17 | assert_match(/^ Breakpoint #{match[:id]}\. First hit/, @output.string) 18 | end 19 | 20 | def test_shows_breakpoint_line 21 | assert_match(/\=> \s*#{@line}:/, @output.string) 22 | end 23 | end 24 | 25 | # 26 | # Tests for breakpoint commands 27 | # 28 | class BreakpointsTest < Minitest::Test 29 | def setup 30 | super 31 | 32 | @input = InputTester.new "break --delete-all" 33 | @output = StringIO.new 34 | end 35 | 36 | def teardown 37 | super 38 | 39 | clean_remove_const(:Break1Example) 40 | clean_remove_const(:Break2Example) 41 | end 42 | 43 | def width 44 | Byebug.breakpoints.last.id.to_s.length 45 | end 46 | end 47 | 48 | # 49 | # Tests setting a breakpoint by line number 50 | # 51 | class SettingBreakpointsTestByLineNumber < BreakpointsTest 52 | def setup 53 | super 54 | 55 | @input.add("break 8") 56 | redirect_pry_io(@input, @output) { load test_file("break1") } 57 | @line = 8 58 | @regexp = / Breakpoint (?\d+): #{test_file('break1')} @ 8 \(Enabled\)/ 59 | end 60 | 61 | include BreakpointSpecs 62 | end 63 | 64 | # 65 | # Tests setting a breakpoint in a method 66 | # 67 | class SettingBreakpointsTestByMethodId < BreakpointsTest 68 | def setup 69 | super 70 | 71 | @input.add("break Break1Example#a") 72 | redirect_pry_io(@input, @output) { load test_file("break1") } 73 | @line = 8 74 | @regexp = / Breakpoint (?\d+): Break1Example#a \(Enabled\)/ 75 | end 76 | 77 | include BreakpointSpecs 78 | end 79 | 80 | # 81 | # Tests setting a breakpoint in a bang method 82 | # 83 | class SettingBreakpointsTestByMethodIdForBangMethods < BreakpointsTest 84 | def setup 85 | super 86 | 87 | @input.add("break Break1Example#c!") 88 | redirect_pry_io(@input, @output) { load test_file("break1") } 89 | @line = 18 90 | @regexp = / Breakpoint (?\d+): Break1Example#c! \(Enabled\)/ 91 | end 92 | 93 | include BreakpointSpecs 94 | end 95 | 96 | # 97 | # Tests setting a breakpoint in a (non fully qualified) method 98 | # 99 | class SettingBreakpointsTestByMethodIdWithinContext < BreakpointsTest 100 | def setup 101 | super 102 | 103 | @input.add("break #b") 104 | redirect_pry_io(@input, @output) { load test_file("break2") } 105 | @line = 9 106 | @regexp = / Breakpoint (?\d+): Break2Example#b \(Enabled\)/ 107 | end 108 | 109 | include BreakpointSpecs 110 | end 111 | 112 | # 113 | # Tests listing breakpoints 114 | # 115 | class ListingBreakpoints < BreakpointsTest 116 | def setup 117 | super 118 | 119 | @input.add("break #b", "break") 120 | redirect_pry_io(@input, @output) { load test_file("break2") } 121 | end 122 | 123 | def test_shows_all_breakpoints 124 | assert_match(/Yes \s*Break2Example#b/, @output.string) 125 | end 126 | 127 | def test_properly_displays_breakpoint_list 128 | assert_match(/ {#{width - 1}}# Enabled At/, @output.string) 129 | assert_match(/ \d{#{width}} Yes Break2Example#b/, @output.string) 130 | end 131 | end 132 | 133 | # 134 | # Tests disabling breakpoints 135 | # 136 | class DisablingBreakpoints < BreakpointsTest 137 | def setup 138 | super 139 | 140 | @input.add("break #b", "break --disable-all") 141 | redirect_pry_io(@input, @output) { load test_file("break2") } 142 | end 143 | 144 | def test_shows_breakpoints_as_disabled 145 | assert_match(/ {#{width - 1}}# Enabled At/, @output.string) 146 | assert_match(/ \d{#{width}} No Break2Example#b/, @output.string) 147 | end 148 | end 149 | 150 | # 151 | # Tests that the break Ruby keyword does not conflict with the break command 152 | # 153 | class BreakInsideMultilineInput < BreakpointsTest 154 | def setup 155 | super 156 | 157 | @input.add("2.times do |i|", "break 18 if i > 0", "end") 158 | 159 | redirect_pry_io(@input, @output) { load test_file("break1") } 160 | end 161 | 162 | def test_it_is_ignored 163 | assert_equal 0, Pry::Byebug::Breakpoints.size 164 | end 165 | 166 | def test_lets_input_be_properly_evaluated 167 | assert_match(/=> 18/, @output.string) 168 | end 169 | end 170 | -------------------------------------------------------------------------------- /test/commands/frames_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | require "stringio" 5 | 6 | # 7 | # Tests for pry-byebug frame commands. 8 | # 9 | class FramesTest < Minitest::Spec 10 | let(:output) { StringIO.new } 11 | 12 | after { clean_remove_const(:FramesExample) } 13 | 14 | describe "Up command" do 15 | let(:input) { InputTester.new("up", "down") } 16 | 17 | before do 18 | redirect_pry_io(input, output) { load test_file("frames") } 19 | end 20 | 21 | it "shows current line" do 22 | _(output.string).must_match(/=> \s*8: \s*method_b/) 23 | end 24 | end 25 | 26 | describe "Down command" do 27 | let(:input) { InputTester.new("up", "down") } 28 | 29 | before do 30 | redirect_pry_io(input, output) { load test_file("frames") } 31 | end 32 | 33 | it "shows current line" do 34 | _(output.string).must_match(/=> \s*13: \s*end/) 35 | end 36 | end 37 | 38 | describe "Frame command" do 39 | before do 40 | redirect_pry_io(input, output) { load test_file("frames") } 41 | end 42 | 43 | describe "jump to frame 1" do 44 | let(:input) { InputTester.new("frame 1", "frame 0") } 45 | 46 | it "shows current line" do 47 | _(output.string).must_match(/=> \s*8: \s*method_b/) 48 | end 49 | end 50 | 51 | describe "jump to current frame" do 52 | let(:input) { InputTester.new("frame 0") } 53 | 54 | it "shows current line" do 55 | _(output.string).must_match(/=> \s*13: \s*end/) 56 | end 57 | end 58 | end 59 | 60 | describe "Backtrace command" do 61 | let(:input) { InputTester.new("backtrace") } 62 | 63 | before do 64 | @stdout, @stderr = capture_subprocess_io do 65 | redirect_pry_io(input) { load test_file("frames") } 66 | end 67 | end 68 | 69 | it "shows a backtrace" do 70 | frames = @stdout.split("\n") 71 | 72 | assert_match(/\A--> #0 FramesExample\.method_b at/, frames[0]) 73 | assert_match(/\A #1 FramesExample\.method_a at/, frames[1]) 74 | assert_match(/\A #2 at/, frames[2]) 75 | end 76 | end 77 | end 78 | -------------------------------------------------------------------------------- /test/commands/stepping_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | # 6 | # Tests for pry-byebug stepping commands 7 | # 8 | class SteppingTest < Minitest::Test 9 | def setup 10 | super 11 | 12 | @output = StringIO.new 13 | @input = InputTester.new("break --delete-all") 14 | end 15 | 16 | def teardown 17 | clean_remove_const(:SteppingExample) 18 | 19 | super 20 | end 21 | end 22 | 23 | # 24 | # Tests the step command without arguments 25 | # 26 | class StepCommandSingleStepTest < SteppingTest 27 | def setup 28 | super 29 | 30 | @input.add("step") 31 | redirect_pry_io(@input, @output) { load test_file("stepping") } 32 | end 33 | 34 | def test_stops_at_the_next_statement 35 | assert_match(/\=> \s*9:/, @output.string) 36 | end 37 | end 38 | 39 | # 40 | # Tests the step command with a step argument 41 | # 42 | class StepCommandMultipleStepTest < SteppingTest 43 | def setup 44 | super 45 | 46 | @input.add("step 2") 47 | redirect_pry_io(@input, @output) { load test_file("stepping") } 48 | end 49 | 50 | def test_stops_a_correct_number_of_steps_after 51 | assert_match(/\=> \s*14:/, @output.string) 52 | end 53 | end 54 | 55 | # 56 | # Tests the next command without arguments 57 | # 58 | class NextCommandSingleStepTest < SteppingTest 59 | def setup 60 | super 61 | 62 | @input.add("next") 63 | redirect_pry_io(@input, @output) { load test_file("stepping") } 64 | end 65 | 66 | def test_stops_at_the_next_line_in_the_current_frame 67 | assert_match(/\=> \s*26:/, @output.string) 68 | end 69 | end 70 | 71 | # 72 | # Tests the next command with an argument 73 | # 74 | class NextCommandMultipleStepTest < SteppingTest 75 | def setup 76 | super 77 | 78 | @input.add("next 2") 79 | redirect_pry_io(@input, @output) { load test_file("stepping") } 80 | end 81 | 82 | def test_advances_the_correct_number_of_lines 83 | assert_match(/\=> \s*27:/, @output.string) 84 | end 85 | end 86 | 87 | # 88 | # Tests that the next Ruby keyword does not conflict with the next command 89 | # 90 | class NextInsideMultilineInput < SteppingTest 91 | def setup 92 | super 93 | 94 | @input.add( 95 | "2.times do |i|", 96 | "if i == 0", 97 | "next", 98 | "end", 99 | "break 1001 + i", 100 | "end" 101 | ) 102 | 103 | redirect_pry_io(@input, @output) { load test_file("stepping") } 104 | end 105 | 106 | def test_it_is_ignored 107 | assert_match(/\=> \s*8:/, @output.string) 108 | refute_match(/\=> \s*26:/, @output.string) 109 | end 110 | 111 | def test_lets_input_be_properly_evaluated 112 | assert_match(/=> 1002/, @output.string) 113 | end 114 | end 115 | 116 | # 117 | # Tests the finish command 118 | # 119 | class FinishCommand < SteppingTest 120 | def setup 121 | super 122 | 123 | @input.add("break 21", "continue", "finish") 124 | redirect_pry_io(@input, @output) { load test_file("stepping") } 125 | end 126 | 127 | def test_advances_until_the_end_of_the_current_frame 128 | assert_match(/\=> \s*17:/, @output.string) 129 | end 130 | end 131 | 132 | # 133 | # Tests the continue command without arguments 134 | # 135 | class ContinueCommandWithoutArguments < SteppingTest 136 | def setup 137 | super 138 | 139 | @input.add("break 16", "continue") 140 | redirect_pry_io(@input, @output) { load test_file("stepping") } 141 | end 142 | 143 | def test_advances_until_the_next_breakpoint 144 | assert_match(/\=> \s*16:/, @output.string) 145 | end 146 | end 147 | 148 | # 149 | # Tests the continue command with a line argument 150 | # 151 | class ContinueCommandWithALineArgument < SteppingTest 152 | def setup 153 | super 154 | 155 | @input.add("continue 16") 156 | redirect_pry_io(@input, @output) { load test_file("stepping") } 157 | end 158 | 159 | def test_advances_until_the_specified_line 160 | assert_match(/\=> \s*16:/, @output.string) 161 | end 162 | end 163 | -------------------------------------------------------------------------------- /test/examples/break1.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # A toy example for testing break commands. 5 | # 6 | class Break1Example 7 | def a 8 | z = 2 9 | z + b 10 | end 11 | 12 | def b 13 | z = 5 14 | z + c! 15 | end 16 | 17 | def c! 18 | z = 4 19 | z 20 | end 21 | end 22 | 23 | binding.pry 24 | 25 | Break1Example.new.a 26 | -------------------------------------------------------------------------------- /test/examples/break2.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Another toy example for testing break commands. 5 | # 6 | class Break2Example 7 | def a 8 | binding.pry 9 | z = 2 10 | z + b 11 | end 12 | 13 | def b 14 | c 15 | end 16 | 17 | def c 18 | z = 4 19 | z + 5 20 | end 21 | end 22 | 23 | Break2Example.new.a 24 | -------------------------------------------------------------------------------- /test/examples/deep_stepping.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Toy program for testing binding.pry initialization 5 | # 6 | 7 | new_str = "string".gsub(/str/) do |_| 8 | binding.pry 9 | end 10 | 11 | _foo = new_str 12 | -------------------------------------------------------------------------------- /test/examples/echo_thread.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "socket" 4 | 5 | client, server = Socket.pair(Socket::AF_UNIX, Socket::SOCK_STREAM) 6 | 7 | Thread.new do 8 | while (line = server.readline) 9 | server.write(line) 10 | end 11 | end 12 | 13 | binding.pry 14 | client 15 | -------------------------------------------------------------------------------- /test/examples/frames.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # 4 | # Toy class for testing frame commands 5 | # 6 | class FramesExample 7 | def method_a 8 | method_b 9 | end 10 | 11 | def method_b 12 | binding.pry 13 | end 14 | end 15 | 16 | FramesExample.new.method_a 17 | -------------------------------------------------------------------------------- /test/examples/multiple.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | 5.times do 4 | binding.pry 5 | end 6 | -------------------------------------------------------------------------------- /test/examples/stepping.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | binding.pry 4 | 5 | # 6 | # Toy class for testing steps 7 | # 8 | class SteppingExample 9 | def method_a 10 | z = 2 11 | z + method_b 12 | end 13 | 14 | def method_b 15 | c = Math::PI / 2 16 | c += method_c 17 | c + 1 18 | end 19 | 20 | def method_c 21 | z = 4 22 | z 23 | end 24 | end 25 | 26 | ex = SteppingExample.new.method_a 27 | 2.times do 28 | ex += 1 29 | end 30 | 31 | _foo = ex 32 | -------------------------------------------------------------------------------- /test/processor_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | # 6 | # Tests for pry-byebug's processor. 7 | # 8 | class ProcessorTest < Minitest::Spec 9 | let(:output) { StringIO.new } 10 | 11 | describe "Initialization" do 12 | let(:input) { InputTester.new } 13 | 14 | describe "normally" do 15 | let(:source_file) { test_file("stepping") } 16 | 17 | before do 18 | redirect_pry_io(input, output) { load source_file } 19 | end 20 | 21 | after { clean_remove_const(:SteppingExample) } 22 | 23 | it "stops execution at the first line after binding.pry" do 24 | _(output.string).must_match(/\=> 8:/) 25 | end 26 | end 27 | 28 | describe "at the end of block/method call" do 29 | let(:source_file) { test_file("deep_stepping") } 30 | 31 | before do 32 | redirect_pry_io(input, output) { load source_file } 33 | end 34 | 35 | it "stops execution at the first line after binding.pry" do 36 | _(output.string).must_match(/\=> 9:/) 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /test/pry_ext_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | class PryExtTest < Minitest::Spec 6 | let(:output) { StringIO.new } 7 | let(:input) { InputTester.new } 8 | 9 | describe "when disable-pry called" do 10 | subject { redirect_pry_io(input, output) { load test_file("multiple") } } 11 | before { input.add "disable-pry" } 12 | after { ENV.delete("DISABLE_PRY") } 13 | 14 | it "keeps pry's default behaviour" do 15 | subject 16 | assert_equal 1, output.string.scan(/binding\.pry/).size 17 | end 18 | 19 | it "does not start byebug" do 20 | Byebug.stop 21 | subject 22 | assert !Byebug.started? 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /test/pry_remote_ext_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | 5 | class PryRemoteExtTest < Minitest::Spec 6 | end 7 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "minitest/autorun" 4 | require "pry-byebug" 5 | 6 | Pry.config.color = false 7 | Pry.config.pager = false 8 | Pry.config.correct_indent = false 9 | 10 | # 11 | # Set I/O streams. Out defaults to an anonymous StringIO. 12 | # 13 | def redirect_pry_io(new_in, new_out = StringIO.new) 14 | old_in = Pry.input 15 | old_out = Pry.output 16 | Pry.input = new_in 17 | Pry.output = new_out 18 | begin 19 | yield 20 | ensure 21 | Pry.input = old_in 22 | Pry.output = old_out 23 | end 24 | end 25 | 26 | def test_file(name) 27 | (Pathname.new(__FILE__) + "../examples/#{name}.rb").cleanpath.to_s 28 | end 29 | 30 | def clean_remove_const(const) 31 | Object.send(:remove_const, const.to_s) if Object.send(:const_defined?, const) 32 | end 33 | 34 | # 35 | # Simulate pry-byebug's input for testing 36 | # 37 | class InputTester 38 | def initialize(*actions) 39 | @actions = actions 40 | end 41 | 42 | def add(*actions) 43 | @actions += actions 44 | end 45 | 46 | def readline(*) 47 | @actions.shift 48 | end 49 | end 50 | -------------------------------------------------------------------------------- /test/thread_lock_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require "test_helper" 4 | require "timeout" 5 | 6 | class ThreadLockTest < Minitest::Spec 7 | let(:output) { StringIO.new } 8 | let(:input) { InputTester.new } 9 | 10 | describe "when there's another thread" do 11 | before do 12 | input.add 'client.puts("Hello")' 13 | input.add "IO.select([client], [], [], 1) && client.readline" 14 | 15 | redirect_pry_io(input, output) { load test_file("echo_thread") } 16 | end 17 | 18 | it "another thread isn't locked" do 19 | assert_equal "=> \"Hello\\n\"\n", output.string.lines.last 20 | end 21 | end 22 | end 23 | --------------------------------------------------------------------------------