We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
代入の右辺で代入される変数を使用すると、それは必ずnilなのでなんらかの間違いである可能性が高い。 そのため、そのような代入を検出するCopが欲しい
a = a # 右辺のaは常にnil a = x do a # このaは常にnil end
これは、実装が大変だとおもう(たぶんね)。VariableForceとか見ると答えがあるかも知れないけど、私もよく知らない。
The text was updated successfully, but these errors were encountered:
Lint/SelfAssignment cop で実現されているためクローズします。RuboCop 0.89 以上で利用可能です。 https://docs.rubocop.org/rubocop/1.37/cops_lint.html#lintselfassignment
Lint/SelfAssignment
ただし、以下のケースはサポートされていなさそうで、別途拡張できそうです。
a = x do a # このaは常にnil end
Sorry, something went wrong.
Issueの整理ありがとうございます 🙏
改めて考えてみると、これは必ずしもこうはならなさそうですね。
a = Thread.new do sleep 0.1 p a # => #<Thread:0x0000000102f176d0 /path/top/test.rb:1 run> end a.join
このブロックがa変数が初期化される前にだけ呼ばれるのかを判定するのは、静的には難しそうな気がするので、拡張も難しそうな気がしています 💭
a
No branches or pull requests
代入の右辺で代入される変数を使用すると、それは必ずnilなのでなんらかの間違いである可能性が高い。
そのため、そのような代入を検出するCopが欲しい
これは、実装が大変だとおもう(たぶんね)。VariableForceとか見ると答えがあるかも知れないけど、私もよく知らない。
The text was updated successfully, but these errors were encountered: