Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby debugger highlighting false-positives #16357

Closed
bostonaholic opened this issue Apr 4, 2024 · 0 comments 路 Fixed by #16358
Closed

Ruby debugger highlighting false-positives #16357

bostonaholic opened this issue Apr 4, 2024 · 0 comments 路 Fixed by #16358

Comments

@bostonaholic
Copy link
Sponsor Contributor

Description :octocat:

Ruby debugger highlighting false-positives

Reproduction guide 馃

  • Start Emacs
  • Open a ruby file
  • Add the line # byebug

Observed behaviour: 馃憖 馃挃
The line is highlighted as a warning.

Screenshot 2024-04-04 at 9 08 15鈥疉M

Expected behaviour: 鉂わ笍 馃槃
The line is not highlighted.

Screenshot 2024-04-04 at 9 12 23鈥疉M

System Info 馃捇

  • OS: darwin
  • Emacs: 29.3
  • Spacemacs: 0.999.0
  • Spacemacs branch: develop (rev. 6bd273b)
  • Graphic display: t
  • Running in daemon: nil
  • Distribution: spacemacs
  • Editing style: emacs
  • Completion: helm
  • Layers:
((auto-completion :variables auto-completion-enable-help-tooltip t auto-completion-enable-snippets-in-popup t auto-completion-enable-sort-by-usage t)
 better-defaults
 (clojure :variables clojure-enable-linters 'clj-kondo)
 csv dash docker emacs-lisp
 (erc :variables erc-server-list
      '(("irc.freenode.net" :port "6697" :ssl t :nick my/irc-nick)))
 (git :variables git-magit-status-fullscreen t magit-repository-directories
      '(("~/code/")))
 github graphviz helm html ibuffer javascript
 (markdown :variables markdown-live-preview-engine 'vmd markdown-fontify-code-blocks-natively t)
 multiple-cursors nginx org plantuml python react
 (ruby :variables ruby-enable-enh-ruby-mode t ruby-prettier-on-save t ruby-test-runner 'rspec ruby-version-manager 'rbenv)
 ruby-on-rails shell-scripts spell-checking sql syntax-checking templates
 (typescript :variables typescript-fmt-tool 'prettier typescript-fmt-on-save t)
 vimscript yaml)
  • System configuration features: ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB

Backtrace 馃惥

bostonaholic added a commit to bostonaholic/spacemacs that referenced this issue Apr 4, 2024
Fixes syl20bnr#16357

The change expands the matching regex to only highlight lines where the debugger
is the first word on a line.

The intended behavior is to highlight lines that are calling a ruby debugger.
The purpose is to warn developers that might push code to production
with a debugger enabled. The change expands the matching regex to only highlight
lines where the debugger is the first word on a line.

However, there are cases in which the regex is highlighting lines as a
false-positive. I first noticed this in my `Gemfile` when it was highlighting the
line below:

```ruby
gem 'pry-byebug'
```

Other cases include: commented lines and defined function names that match a known
debugger.

See below for cases in which the line should and should not be highlighted.

```ruby

class Test
  # This line below should not be highlighted
  def byebug
    byebug # this line should be highlighted
    # byebug This comment shouldn't be highlighted

    binding.irb # this line should be highlighted
    # binding.irb this line should not be highlighted

    binding.pry # this line should be highlighted
    # binding.pry this line should not be highlighted
  end
end
```
smile13241324 pushed a commit that referenced this issue May 11, 2024
Fixes #16357

The change expands the matching regex to only highlight lines where the debugger
is the first word on a line.

The intended behavior is to highlight lines that are calling a ruby debugger.
The purpose is to warn developers that might push code to production
with a debugger enabled. The change expands the matching regex to only highlight
lines where the debugger is the first word on a line.

However, there are cases in which the regex is highlighting lines as a
false-positive. I first noticed this in my `Gemfile` when it was highlighting the
line below:

```ruby
gem 'pry-byebug'
```

Other cases include: commented lines and defined function names that match a known
debugger.

See below for cases in which the line should and should not be highlighted.

```ruby

class Test
  # This line below should not be highlighted
  def byebug
    byebug # this line should be highlighted
    # byebug This comment shouldn't be highlighted

    binding.irb # this line should be highlighted
    # binding.irb this line should not be highlighted

    binding.pry # this line should be highlighted
    # binding.pry this line should not be highlighted
  end
end
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant