inspecstyle 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +12 -7
- data/README.md +39 -1
- data/Rakefile +3 -0
- data/config/default.yml +95 -2
- data/doc/RuboCop.html +128 -0
- data/doc/RuboCop/Cop.html +117 -0
- data/doc/RuboCop/Cop/InSpecStyle.html +117 -0
- data/doc/RuboCop/Cop/InSpecStyle/AzureGenericResource.html +249 -0
- data/doc/RuboCop/Cop/InSpecStyle/DeprecatedAttributes.html +310 -0
- data/doc/RuboCop/Cop/InSpecStyle/FirstCop.html +345 -0
- data/doc/RuboCop/InSpecStyle.html +140 -0
- data/doc/RuboCop/InSpecStyle/Error.html +124 -0
- data/doc/RuboCop/InSpecStyle/Inject.html +195 -0
- data/doc/_index.html +211 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +131 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +131 -0
- data/doc/js/app.js +314 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +99 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/rubocop/cop/inspecstyle/apache.rb +57 -0
- data/lib/rubocop/cop/inspecstyle/aws_iam_user_property.rb +96 -0
- data/lib/rubocop/cop/inspecstyle/azure_generic_resource.rb +35 -0
- data/lib/rubocop/cop/inspecstyle/deprecated_attributes.rb +16 -16
- data/lib/rubocop/cop/inspecstyle/file_be_mounted.rb +65 -0
- data/lib/rubocop/cop/inspecstyle/file_size.rb +77 -0
- data/lib/rubocop/cop/inspecstyle/host_proto.rb +71 -0
- data/lib/rubocop/cop/inspecstyle/iis_website.rb +36 -0
- data/lib/rubocop/cop/inspecstyle/linux_kernel_parameter.rb +41 -0
- data/lib/rubocop/cop/inspecstyle/mssql_session_pass.rb +59 -0
- data/lib/rubocop/cop/inspecstyle/oracle_db_session_pass.rb +59 -0
- data/lib/rubocop/cop/inspecstyle/ppa_resource.rb +36 -0
- data/lib/rubocop/cop/inspecstyle/processes_list.rb +77 -0
- data/lib/rubocop/cop/inspecstyle/script_resource.rb +48 -0
- data/lib/rubocop/cop/inspecstyle/shadow_properties.rb +83 -0
- data/lib/rubocop/cop/inspecstyle/users_resource_matchers.rb +98 -0
- data/lib/rubocop/cop/inspecstyle/windows_registry_key.rb +36 -0
- data/lib/rubocop/cop/inspecstyle/wmi_wmis_class.rb +37 -0
- data/lib/rubocop/cop/inspecstyle_cops.rb +17 -1
- data/lib/rubocop/inspecstyle/version.rb +1 -1
- data/notes-for-development.md +10 -0
- data/tasks/cops_documentation.rake +300 -0
- metadata +43 -3
- data/lib/rubocop/cop/inspecstyle/first_cop.rb +0 -69
@@ -1,69 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# TODO: when finished, run `rake generate_cops_documentation` to update the docs
|
4
|
-
module RuboCop
|
5
|
-
module Cop
|
6
|
-
module InSpecStyle
|
7
|
-
# TODO: Write cop description and example of bad / good code. For every
|
8
|
-
# `SupportedStyle` and unique configuration, there needs to be examples.
|
9
|
-
# Examples must have valid Ruby syntax. Do not use upticks.
|
10
|
-
#
|
11
|
-
# @example EnforcedStyle: bar (default)
|
12
|
-
# # Description of the `bar` style.
|
13
|
-
#
|
14
|
-
# # bad
|
15
|
-
# bad_bar_method
|
16
|
-
#
|
17
|
-
# # bad
|
18
|
-
# bad_bar_method(args)
|
19
|
-
#
|
20
|
-
# # good
|
21
|
-
# good_bar_method
|
22
|
-
#
|
23
|
-
# # good
|
24
|
-
# good_bar_method(args)
|
25
|
-
#
|
26
|
-
# @example EnforcedStyle: foo
|
27
|
-
# # Description of the `foo` style.
|
28
|
-
#
|
29
|
-
# # bad
|
30
|
-
# bad_foo_method
|
31
|
-
#
|
32
|
-
# # bad
|
33
|
-
# bad_foo_method(args)
|
34
|
-
#
|
35
|
-
# # good
|
36
|
-
# good_foo_method
|
37
|
-
#
|
38
|
-
# # good
|
39
|
-
# good_foo_method(args)
|
40
|
-
#
|
41
|
-
class FirstCop < Cop
|
42
|
-
# TODO: Implement the cop in here.
|
43
|
-
#
|
44
|
-
# In many cases, you can use a node matcher for matching node pattern.
|
45
|
-
# See https://github.com/rubocop-hq/rubocop/blob/master/lib/rubocop/node_pattern.rb
|
46
|
-
#
|
47
|
-
# For example
|
48
|
-
MSG = 'Use `#good_method` instead of `#bad_method`. %<example_insertion>'
|
49
|
-
|
50
|
-
def_node_matcher :bad_method?, <<~PATTERN
|
51
|
-
(send nil? :bad_method ...)
|
52
|
-
PATTERN
|
53
|
-
|
54
|
-
def on_send(node)
|
55
|
-
return unless bad_method?(node)
|
56
|
-
message = format(MSG, example_insertion: node.first.source)
|
57
|
-
add_offense(node, message: message)
|
58
|
-
end
|
59
|
-
|
60
|
-
def autocorrect(node)
|
61
|
-
->(corrector) do
|
62
|
-
corrector.insert_before(node.source_range, 'good_method')
|
63
|
-
corrector.remove(node.source_range)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|