rspec/rules/S3011/ruby/rule.adoc
2022-02-04 16:28:24 +00:00

52 lines
782 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
[source,ruby]
----
class A
def mymethod
puts "I got called"
end
private :mymethod
end
a = A.new()
# => false
puts a.respond_to?(:mymethod)
class << a
public :mymethod # NonCompliant: method was private
end
# => true
puts a.respond_to?(:mymethod)
b = A.new()
# => false
puts b.respond_to?(:mymethod)
A.class_eval do
public :mymethod # NonCompliant: method was private
end
c = A.new()
# => true
puts c.respond_to?(:mymethod)
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]