Comments (5)
This certainly is a bug, that we'll address soon. On a related note - interpolating variables like this is considered bad style(it's a remnant of the ancient Ruby history), so we should add a check for this as well.
from rubocop.
@jonas054 Here's where the problem with the existing check lies:
[3] pry(main)> Ripper.lex('puts "test#@@top"')
=> [[[1, 0], :on_ident, "puts"],
[[1, 4], :on_sp, " "],
[[1, 5], :on_tstring_beg, "\""],
[[1, 6], :on_tstring_content, "test"],
[[1, 10], :on_embvar, "#"],
[[1, 11], :on_cvar, "@@top"],
[[1, 16], :on_tstring_end, "\""]]
[4] pry(main)> Ripper.lex('puts "test#{@@top}"')
=> [[[1, 0], :on_ident, "puts"],
[[1, 4], :on_sp, " "],
[[1, 5], :on_tstring_beg, "\""],
[[1, 6], :on_tstring_content, "test"],
[[1, 10], :on_embexpr_beg, "\#{"],
[[1, 12], :on_cvar, "@@top"],
[[1, 17], :on_embexpr_end, "}"],
[[1, 18], :on_tstring_end, "\""]]
The code in StringLiterals
currently checks only for :on_embexpr_beg
.
from rubocop.
Thanks, I'll try to solve it tonight.
from rubocop.
That won't be needed - I got a bit of an inspiration and fixed it myself :-) I've also implemented a cop to warn against the use of interpolated variables.
from rubocop.
Great!
from rubocop.
Related Issues (20)
- Lint/Debugger does not catch require "debug/start" HOT 3
- Invalid offense/autocorrect for `Style/RedundantLineContinuation` HOT 1
- Wrong Style/RedundantLineContinuation and autocorrect HOT 1
- Fix auto-generation of outstanding issues to respect XDG configuration
- `AssignmentInCondition` didn't find the style problem HOT 6
- Invalid autocorrect in Layout/SpaceInsideHashLiteralBraces
- Infinite loop in `Style/Encoding` with uppercase token
- Improve the error message in expect_offense
- def_node_matcher for explicit and implicit nil HOT 5
- rubocop-1.61.0 crashes when the project's gemspec dynamically sets `spec.required_ruby_version` HOT 1
- Many methods on `Parser::Source::Range` from `Offense.highlighted_area` raise `NoMethodError` HOT 2
- False positive for `Lint/ToEnumArguments`
- Incompatibility between `parser_prism` and `ruby_extractors` HOT 4
- Error for `Lint/MixedCaseRange` when invalid utf8 and offense exists
- Infinite loop with `Style/IfUnlessModifier -> Layout/EndAlignment, Layout/IndentationWidth`
- False positives for Lint/UnusedBlockArgument when using parser_prism HOT 4
- Invalid offense/autocorrect for `Style/RedundantLineContinuation`
- invalid offense Style/HashEachMethods
- False positive for `Lint/RedundantWithIndex` when calling with_index without each beforehand
- Should esoteric cop errors be fixed? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rubocop.