Class: RuboCop::Cop::PackageProtections::OnlyClassMethods
- Inherits:
-
Packs::ClassMethodsAsPublicApis
- Object
- Packs::ClassMethodsAsPublicApis
- RuboCop::Cop::PackageProtections::OnlyClassMethods
show all
- Extended by:
- T::Sig
- Includes:
- PackageProtections::RubocopProtectionInterface
- Defined in:
- lib/rubocop/cop/package_protections/only_class_methods.rb
Constant Summary
collapse
- IDENTIFIER =
'prevent_this_package_from_exposing_instance_method_public_apis'.freeze
Instance Method Summary
collapse
#cop_configs, #get_offenses_for_existing_violations, #get_offenses_for_new_violations, #unmet_preconditions_for_behavior
#get_offenses, #get_offenses_for_existing_violations, #get_offenses_for_new_violations, #supports_violation_behavior?, #unmet_preconditions_for_behavior
Instance Method Details
#cop_name ⇒ Object
56
57
58
|
# File 'lib/rubocop/cop/package_protections/only_class_methods.rb', line 56
def cop_name
'PackageProtections/OnlyClassMethods'
end
|
#custom_cop_config ⇒ Object
39
40
41
42
43
|
# File 'lib/rubocop/cop/package_protections/only_class_methods.rb', line 39
def custom_cop_config
{
'AcceptableParentClasses' => ::PackageProtections.config.acceptable_parent_classes
}
end
|
#default_behavior ⇒ Object
#humanized_protection_description ⇒ Object
13
14
15
16
17
18
19
20
|
# File 'lib/rubocop/cop/package_protections/only_class_methods.rb', line 13
def humanized_protection_description
<<~MESSAGE
Public API methods can only be static methods.
This is failing because these files are in `.rubocop_todo.yml` under `#{cop_name}`.
If you want to be able to ignore these files, you'll need to open the file's package's `package.yml` file and
change `#{IDENTIFIER}` to `#{::PackageProtections::ViolationBehavior::FailOnNew.serialize}`
MESSAGE
end
|
#humanized_protection_name ⇒ Object
51
52
53
|
# File 'lib/rubocop/cop/package_protections/only_class_methods.rb', line 51
def humanized_protection_name
'Class Method Public APIs'
end
|
#identifier ⇒ Object
46
47
48
|
# File 'lib/rubocop/cop/package_protections/only_class_methods.rb', line 46
def identifier
IDENTIFIER
end
|
#included_globs_for_pack ⇒ Object
30
31
32
33
34
|
# File 'lib/rubocop/cop/package_protections/only_class_methods.rb', line 30
def included_globs_for_pack
[
'app/public/**/*'
]
end
|
#message_for_fail_on_any(file) ⇒ Object
25
26
27
|
# File 'lib/rubocop/cop/package_protections/only_class_methods.rb', line 25
def message_for_fail_on_any(file)
"`#{file}` must only contain static (class or module level) methods"
end
|