Dynamic type used in static context
Reports usages of dynamic types (instance
, class
, and self
) in static contexts. Usage of a dynamic type in a static context can be considered confusing as the type will never change.
A quick fix is available to replace the dynamic type usage with its static equivalent.
Example:
class Example
# 'instance' used in a static context
INSTANCE: instance
# 'class' used in a static context
CLASS: class
end
After the quick fix:
class Example
INSTANCE: Example
CLASS: singleton(Example)
end
Inspection Details | |
---|---|
Available in: | Qodana for Ruby 2023.3, RubyMine 2023.3 |
Plugin: | Ruby, 233.SNAPSHOT |
Last modified: 13 July 2023