rubocop-sketchup 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/lib/rubocop-sketchup.rb +2 -0
- data/lib/rubocop/sketchup.rb +2 -0
- data/lib/rubocop/sketchup/cop/bugs/material_name.rb +1 -1
- data/lib/rubocop/sketchup/cop/bugs/render_mode.rb +2 -2
- data/lib/rubocop/sketchup/cop/bugs/uniform_scaling.rb +1 -1
- data/lib/rubocop/sketchup/cop/deprecations/add_separator_to_menu.rb +1 -1
- data/lib/rubocop/sketchup/cop/deprecations/operation_next_transparent.rb +1 -1
- data/lib/rubocop/sketchup/cop/deprecations/require_all.rb +1 -1
- data/lib/rubocop/sketchup/cop/deprecations/set_texture_projection.rb +1 -1
- data/lib/rubocop/sketchup/cop/deprecations/show_ruby_panel.rb +1 -1
- data/lib/rubocop/sketchup/cop/deprecations/sketchup_set.rb +1 -1
- data/lib/rubocop/sketchup/cop/performance/openssl.rb +1 -1
- data/lib/rubocop/sketchup/cop/performance/operation_disable_ui.rb +1 -1
- data/lib/rubocop/sketchup/cop/performance/selection_bulk.rb +1 -1
- data/lib/rubocop/sketchup/cop/performance/type_check.rb +1 -1
- data/lib/rubocop/sketchup/cop/performance/typename.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/api_namespace.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/exit.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/extension_namespace.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/file_structure.rb +6 -6
- data/lib/rubocop/sketchup/cop/requirements/gem_install.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/get_extension_license.rb +3 -3
- data/lib/rubocop/sketchup/cop/requirements/global_constants.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/global_include.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/global_methods.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/global_variables.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/load_path.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/minimal_registration.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/observers_start_operation.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/register_extension.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/ruby_core_namespace.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/ruby_stdlib_namespace.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/shipped_extensions_namespace.rb +1 -1
- data/lib/rubocop/sketchup/cop/requirements/sketchup_extension.rb +14 -14
- data/lib/rubocop/sketchup/cop/requirements/sketchup_require.rb +5 -5
- data/lib/rubocop/sketchup/cop/suggestions/add_group.rb +1 -1
- data/lib/rubocop/sketchup/cop/suggestions/compatibility.rb +3 -3
- data/lib/rubocop/sketchup/cop/suggestions/dc_internals.rb +1 -1
- data/lib/rubocop/sketchup/cop/suggestions/file_encoding.rb +1 -1
- data/lib/rubocop/sketchup/cop/suggestions/model_entities.rb +1 -1
- data/lib/rubocop/sketchup/cop/suggestions/monkey_patched_api.rb +5 -5
- data/lib/rubocop/sketchup/cop/suggestions/operation_name.rb +4 -4
- data/lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb +1 -1
- data/lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb +1 -1
- data/lib/rubocop/sketchup/cop/suggestions/tool_invalidate.rb +2 -2
- data/lib/rubocop/sketchup/cop/suggestions/tool_user_input.rb +1 -1
- data/lib/rubocop/sketchup/cop/suggestions/toolbar_timer.rb +2 -2
- data/lib/rubocop/sketchup/formatter/extension_review.rb +1 -1
- data/lib/rubocop/sketchup/namespace.rb +1 -1
- data/lib/rubocop/sketchup/range_help.rb +1 -1
- data/lib/rubocop/sketchup/version.rb +3 -1
- data/rubocop-sketchup.gemspec +4 -2
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f191f3c6933aecafd8276d46cf582094e4562b7d1a9d7e2c62031351d83c7318
|
|
4
|
+
data.tar.gz: '0854e6c51bfec535cf5c626fdf5f44d335ef392daa979e56bfdff9fc0deb2a8e'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f2755cbefe2667ef8d2888c269f16561109b6c848bb7ce089cbe0d03273e801bc68862f773e5e95be170734bc5c28b71b9848d602a9ce89fe6bd0cc98b74abf
|
|
7
|
+
data.tar.gz: 62f91f9d6adf7da13fdd3da9ab0f1f75145c7d8172d6c5cc21217352df3d3a875e6e450a825ac46632a594a4cdaa200771475f5c968a25f08df58c21dec1462d
|
data/Gemfile
CHANGED
|
@@ -12,9 +12,9 @@ end
|
|
|
12
12
|
|
|
13
13
|
group :development do
|
|
14
14
|
gem 'bump', '~> 0.5', require: false
|
|
15
|
-
gem '
|
|
15
|
+
gem 'rubocop-performance', require: false
|
|
16
16
|
gem 'simplecov', '~> 0.10', require: false
|
|
17
|
-
gem 'solargraph', '~> 0.
|
|
17
|
+
gem 'solargraph', '~> 0.34', require: false
|
|
18
18
|
gem 'thor', '~> 0.20', require: false
|
|
19
19
|
gem 'yard', '~> 0.9', require: false
|
|
20
20
|
end
|
data/lib/rubocop-sketchup.rb
CHANGED
data/lib/rubocop/sketchup.rb
CHANGED
|
@@ -43,10 +43,10 @@ module RuboCop
|
|
|
43
43
|
PATTERN
|
|
44
44
|
|
|
45
45
|
MSG_OBSOLETE = 'Obsolete render mode will crash in SU2017 and '\
|
|
46
|
-
'newer versions.'
|
|
46
|
+
'newer versions.'
|
|
47
47
|
|
|
48
48
|
MSG_INVALID = 'Invalid render mode will crash in SU2017 and '\
|
|
49
|
-
'newer versions.'
|
|
49
|
+
'newer versions.'
|
|
50
50
|
|
|
51
51
|
def on_send(node)
|
|
52
52
|
return unless valid_for_target_sketchup_version?
|
|
@@ -13,7 +13,7 @@ module RuboCop
|
|
|
13
13
|
# Only use this flag if you have no other option, for instance to work
|
|
14
14
|
# around bug in how `Sketchup::Model#place_component` starts operations.
|
|
15
15
|
class OperationNextTransparent < SketchUp::Cop
|
|
16
|
-
MSG = 'Third argument is deprecated.'
|
|
16
|
+
MSG = 'Third argument is deprecated.'
|
|
17
17
|
|
|
18
18
|
def on_send(node)
|
|
19
19
|
_, method_name, *args = *node
|
|
@@ -8,7 +8,7 @@ module RuboCop
|
|
|
8
8
|
# repaired. Once repaired the UV mapping will visually change.
|
|
9
9
|
class SetTextureProjection < SketchUp::Cop
|
|
10
10
|
|
|
11
|
-
MSG = 'Method is deprecated. It can create invalid UV mapping.'
|
|
11
|
+
MSG = 'Method is deprecated. It can create invalid UV mapping.'
|
|
12
12
|
|
|
13
13
|
def_node_matcher :set_texture_projection?, <<-PATTERN
|
|
14
14
|
(send _ :set_texture_projection ...)
|
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
|
16
16
|
class OpenSSL < SketchUp::Cop
|
|
17
17
|
|
|
18
18
|
MSG = 'Avoid use of OpenSSL within SketchUp due to severe performance '\
|
|
19
|
-
'issues.'
|
|
19
|
+
'issues.'
|
|
20
20
|
|
|
21
21
|
# http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
|
22
22
|
# https://rubocop.readthedocs.io/en/latest/node_pattern/
|
|
@@ -11,7 +11,7 @@ module RuboCop
|
|
|
11
11
|
# # <model changes>
|
|
12
12
|
# model.commit_operation
|
|
13
13
|
class OperationDisableUI < SketchUp::Cop
|
|
14
|
-
MSG = 'Operations should disable the UI for performance gain.'
|
|
14
|
+
MSG = 'Operations should disable the UI for performance gain.'
|
|
15
15
|
|
|
16
16
|
def on_send(node)
|
|
17
17
|
_, method_name, *args = *node
|
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
|
29
29
|
include RangeHelp
|
|
30
30
|
|
|
31
31
|
MSG = 'Prefer changing selection in bulk instead of modifying '\
|
|
32
|
-
'selection within loops.'
|
|
32
|
+
'selection within loops.'
|
|
33
33
|
|
|
34
34
|
# http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
|
35
35
|
# https://rubocop.readthedocs.io/en/latest/node_pattern/
|
|
@@ -8,7 +8,7 @@ module RuboCop
|
|
|
8
8
|
# `entity.typename == 'Face'` is slow because it performs a string
|
|
9
9
|
# comparison. `is_a?` is much faster because it's a simple type check.
|
|
10
10
|
class Typename < SketchUp::Cop
|
|
11
|
-
MSG = '`.typename` is very slow, prefer `.is_a?` instead.'
|
|
11
|
+
MSG = '`.typename` is very slow, prefer `.is_a?` instead.'
|
|
12
12
|
|
|
13
13
|
def on_send(node)
|
|
14
14
|
_, method_name = *node
|
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
|
14
14
|
include SketchUp::NoCommentDisable
|
|
15
15
|
|
|
16
16
|
MSG = '`exit` attempts to kill the Ruby interpreter. Use `return`, '\
|
|
17
|
-
'`next`, `break` or `raise` instead.'
|
|
17
|
+
'`next`, `break` or `raise` instead.'
|
|
18
18
|
|
|
19
19
|
# Reference: http://rubocop.readthedocs.io/en/latest/development/
|
|
20
20
|
def_node_matcher :exit?, <<-PATTERN
|
|
@@ -88,7 +88,7 @@ module RuboCop
|
|
|
88
88
|
namespace = Namespace.new(node.defined_module_name).from_root
|
|
89
89
|
format('Use a single root namespace. '\
|
|
90
90
|
'(Found `%<found>s`; Previously found `%<expected>s`)',
|
|
91
|
-
|
|
91
|
+
found: namespace, expected: @@namespace)
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
def exempted?(namespace)
|
|
@@ -40,8 +40,8 @@ module RuboCop
|
|
|
40
40
|
msg = 'Extensions must have exactly one root Ruby (.rb) file. '\
|
|
41
41
|
'Found: %d'
|
|
42
42
|
add_offense(nil,
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
location: range,
|
|
44
|
+
message: format(msg, root_ruby_files.size))
|
|
45
45
|
return
|
|
46
46
|
end
|
|
47
47
|
|
|
@@ -57,8 +57,8 @@ module RuboCop
|
|
|
57
57
|
if sub_folders.size != 1
|
|
58
58
|
msg = 'Extensions must have exactly one support directory. Found %d'
|
|
59
59
|
add_offense(nil,
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
location: range,
|
|
61
|
+
message: format(msg, sub_folders.size))
|
|
62
62
|
return
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -69,8 +69,8 @@ module RuboCop
|
|
|
69
69
|
'of the root Ruby file. Expected %s, found %s'
|
|
70
70
|
msg = format(msg, extension_basename, support_directory.basename)
|
|
71
71
|
add_offense(nil,
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
location: range,
|
|
73
|
+
message: msg)
|
|
74
74
|
end
|
|
75
75
|
end
|
|
76
76
|
|
|
@@ -26,7 +26,7 @@ module RuboCop
|
|
|
26
26
|
include SketchUp::NoCommentDisable
|
|
27
27
|
|
|
28
28
|
MSG = '`Gem.install` is unreliable in SketchUp, and can cause '\
|
|
29
|
-
'extensions to clash.'
|
|
29
|
+
'extensions to clash.'
|
|
30
30
|
|
|
31
31
|
# Reference: http://rubocop.readthedocs.io/en/latest/development/
|
|
32
32
|
def_node_matcher :gem_install?, <<-PATTERN
|
|
@@ -14,12 +14,12 @@ module RuboCop
|
|
|
14
14
|
include RangeHelp
|
|
15
15
|
include SketchUp::NoCommentDisable
|
|
16
16
|
|
|
17
|
-
MSG_INVALID = 'Invalid extension GUID'
|
|
17
|
+
MSG_INVALID = 'Invalid extension GUID'
|
|
18
18
|
|
|
19
19
|
MSG_WRONG_TYPE = 'Only pass in extension GUID from local string '\
|
|
20
|
-
'literals.'
|
|
20
|
+
'literals.'
|
|
21
21
|
|
|
22
|
-
MSG_TRAILING_SPACE = 'Extra space in extension GUID'
|
|
22
|
+
MSG_TRAILING_SPACE = 'Extra space in extension GUID'
|
|
23
23
|
|
|
24
24
|
def_node_matcher :get_extension_license, <<-PATTERN
|
|
25
25
|
(send
|
|
@@ -21,7 +21,7 @@ module RuboCop
|
|
|
21
21
|
include SketchUp::NoCommentDisable
|
|
22
22
|
include SketchUp::DynamicComponentGlobals
|
|
23
23
|
|
|
24
|
-
MSG = 'Do not introduce global variables.'
|
|
24
|
+
MSG = 'Do not introduce global variables.'
|
|
25
25
|
|
|
26
26
|
# predefined global variables their English aliases
|
|
27
27
|
# http://www.zenspider.com/Languages/Ruby/QuickRef.html
|
|
@@ -33,7 +33,7 @@ module RuboCop
|
|
|
33
33
|
include SketchUp::ExtensionProject
|
|
34
34
|
|
|
35
35
|
MSG = "Don't load extension files in the root file registering the "\
|
|
36
|
-
'extension.'
|
|
36
|
+
'extension.'
|
|
37
37
|
|
|
38
38
|
# Reference: http://rubocop.readthedocs.io/en/latest/node_pattern/
|
|
39
39
|
def_node_matcher :require_filename, <<-PATTERN
|
|
@@ -32,7 +32,7 @@ module RuboCop
|
|
|
32
32
|
include SketchUp::NoCommentDisable
|
|
33
33
|
include RangeHelp
|
|
34
34
|
|
|
35
|
-
MSG = 'Observers should create transparent operations.'
|
|
35
|
+
MSG = 'Observers should create transparent operations.'
|
|
36
36
|
|
|
37
37
|
def_node_search :start_operation, <<-PATTERN
|
|
38
38
|
(send
|
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
|
14
14
|
include SketchUp::NoCommentDisable
|
|
15
15
|
include SketchUp::NamespaceChecker
|
|
16
16
|
|
|
17
|
-
MSG = 'Do not modify Ruby core functionality.'
|
|
17
|
+
MSG = 'Do not modify Ruby core functionality.'
|
|
18
18
|
|
|
19
19
|
# We check only against the top level namespaces. The core define more
|
|
20
20
|
# objects, but they are under one of the top level namespaces listed.
|
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
|
14
14
|
include SketchUp::NoCommentDisable
|
|
15
15
|
include SketchUp::NamespaceChecker
|
|
16
16
|
|
|
17
|
-
MSG = 'Do not modify Ruby stdlib functionality.'
|
|
17
|
+
MSG = 'Do not modify Ruby stdlib functionality.'
|
|
18
18
|
|
|
19
19
|
# We check only against the top level namespaces. The stdlib define more
|
|
20
20
|
# objects, but they are under one of the top level namespaces listed.
|
|
@@ -9,7 +9,7 @@ module RuboCop
|
|
|
9
9
|
include SketchUp::NoCommentDisable
|
|
10
10
|
include SketchUp::NamespaceChecker
|
|
11
11
|
|
|
12
|
-
MSG = 'Do not modify shipped extensions.'
|
|
12
|
+
MSG = 'Do not modify shipped extensions.'
|
|
13
13
|
|
|
14
14
|
# We check only against the top level namespaces. The core define more
|
|
15
15
|
# objects, but they are under one of the top level namespaces listed.
|
|
@@ -21,11 +21,11 @@ module RuboCop
|
|
|
21
21
|
include RangeHelp
|
|
22
22
|
|
|
23
23
|
# rubocop:disable Metrics/LineLength
|
|
24
|
-
MSG = 'Create and register one SketchupExtension instance per extension.'
|
|
25
|
-
MSG_CREATE_ONE = 'Create only SketchupExtension instance per extension.'
|
|
26
|
-
MSG_CREATE_MISSING = 'SketchupExtension.new not found.'
|
|
27
|
-
MSG_REGISTER_ONE = 'Only register one SketchupExtension instance per extension.'
|
|
28
|
-
MSG_REGISTER_MISSING = 'Registration of SketchupExtension not found. Expected %s'
|
|
24
|
+
MSG = 'Create and register one SketchupExtension instance per extension.'
|
|
25
|
+
MSG_CREATE_ONE = 'Create only SketchupExtension instance per extension.'
|
|
26
|
+
MSG_CREATE_MISSING = 'SketchupExtension.new not found.'
|
|
27
|
+
MSG_REGISTER_ONE = 'Only register one SketchupExtension instance per extension.'
|
|
28
|
+
MSG_REGISTER_MISSING = 'Registration of SketchupExtension not found. Expected %s'
|
|
29
29
|
# rubocop:enable Metrics/LineLength
|
|
30
30
|
|
|
31
31
|
# Reference: http://rubocop.readthedocs.io/en/latest/node_pattern/
|
|
@@ -53,14 +53,14 @@ module RuboCop
|
|
|
53
53
|
|
|
54
54
|
# Threat instances not assigned to anything as non-existing.
|
|
55
55
|
extension_nodes.select! { |node|
|
|
56
|
-
node.parent
|
|
56
|
+
node.parent&.assignment?
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
# There should not be multiple instances.
|
|
60
60
|
if extension_nodes.size > 1
|
|
61
61
|
add_offense(nil,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
location: range,
|
|
63
|
+
message: MSG_CREATE_ONE)
|
|
64
64
|
return
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -68,8 +68,8 @@ module RuboCop
|
|
|
68
68
|
extension_node = extension_nodes.first
|
|
69
69
|
if extension_node.nil?
|
|
70
70
|
add_offense(nil,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
location: range,
|
|
72
|
+
message: MSG_CREATE_MISSING)
|
|
73
73
|
return
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -81,7 +81,7 @@ module RuboCop
|
|
|
81
81
|
'Missing required name arguments'
|
|
82
82
|
end
|
|
83
83
|
add_offense(extension_node,
|
|
84
|
-
|
|
84
|
+
message: message)
|
|
85
85
|
return
|
|
86
86
|
end
|
|
87
87
|
|
|
@@ -100,7 +100,7 @@ module RuboCop
|
|
|
100
100
|
# Make sure there is only one call to `register_extension`.
|
|
101
101
|
if registered_vars.size > 1
|
|
102
102
|
add_offense(registered_vars[1],
|
|
103
|
-
|
|
103
|
+
message: MSG_REGISTER_ONE)
|
|
104
104
|
return
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -108,8 +108,8 @@ module RuboCop
|
|
|
108
108
|
unless registered_var == extension_var
|
|
109
109
|
msg = MSG_REGISTER_MISSING % extension_var.to_s
|
|
110
110
|
add_offense(nil,
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
location: range,
|
|
112
|
+
message: msg)
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
|
|
@@ -28,19 +28,19 @@ module RuboCop
|
|
|
28
28
|
include RangeHelp
|
|
29
29
|
|
|
30
30
|
MSG_SKETCHUP_REQUIRE_EXT_NAME = 'Do not hard code file extensions '\
|
|
31
|
-
'with `Sketchup.require`.'
|
|
31
|
+
'with `Sketchup.require`.'
|
|
32
32
|
|
|
33
33
|
MSG_EXTENSION_NEW_EXT_NAME = 'Do not hard code file extensions '\
|
|
34
|
-
'with `SketchupExtension.new`.'
|
|
34
|
+
'with `SketchupExtension.new`.'
|
|
35
35
|
|
|
36
36
|
MSG_REQUIRE_FOR_BINARY = 'Use `require` instead of `Sketchup.require` '\
|
|
37
|
-
'to load binary Ruby libraries.'
|
|
37
|
+
'to load binary Ruby libraries.'
|
|
38
38
|
|
|
39
39
|
MSG_OMIT_BINARY_EXT = 'Do not hard code .so/.bundle file '\
|
|
40
|
-
'extensions'
|
|
40
|
+
'extensions'
|
|
41
41
|
|
|
42
42
|
MSG_REQUIRE_ENCRYPTED = 'Use `Sketchup.require` when loading Ruby '\
|
|
43
|
-
'files for encrypted extensions.'
|
|
43
|
+
'files for encrypted extensions.'
|
|
44
44
|
|
|
45
45
|
def_node_matcher :ruby_require, <<-PATTERN
|
|
46
46
|
(send nil? :require (str $_))
|
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
|
16
16
|
include SketchUp::Features
|
|
17
17
|
include SketchUp
|
|
18
18
|
|
|
19
|
-
MSG = 'Incompatible feature with target SketchUp version'
|
|
19
|
+
MSG = 'Incompatible feature with target SketchUp version'
|
|
20
20
|
|
|
21
21
|
def on_def(node)
|
|
22
22
|
return unless observer_method?(node)
|
|
@@ -43,7 +43,7 @@ module RuboCop
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def on_const(node)
|
|
46
|
-
if node.parent
|
|
46
|
+
if node.parent&.module_definition?
|
|
47
47
|
# This catches definition of classes and modules.
|
|
48
48
|
namespace = Namespace.new(node.parent_module_name)
|
|
49
49
|
return unless namespace.top_level?
|
|
@@ -103,7 +103,7 @@ module RuboCop
|
|
|
103
103
|
end
|
|
104
104
|
|
|
105
105
|
def module_method?(node)
|
|
106
|
-
node.receiver
|
|
106
|
+
node.receiver&.const_type?
|
|
107
107
|
end
|
|
108
108
|
|
|
109
109
|
def instance_method?(feature_name)
|
|
@@ -17,7 +17,7 @@ module RuboCop
|
|
|
17
17
|
# basename = File.basename(file, '.*')
|
|
18
18
|
class FileEncoding < SketchUp::Cop
|
|
19
19
|
|
|
20
|
-
MSG = 'Beware encoding bug with `__FILE__` and `__dir__`.'
|
|
20
|
+
MSG = 'Beware encoding bug with `__FILE__` and `__dir__`.'
|
|
21
21
|
|
|
22
22
|
def_node_matcher :file_loaded?, <<-PATTERN
|
|
23
23
|
(send nil? {:file_loaded? :file_loaded} ...)
|
|
@@ -11,7 +11,7 @@ module RuboCop
|
|
|
11
11
|
# have an explicit reason to work in the root model context.
|
|
12
12
|
class ModelEntities < SketchUp::Cop
|
|
13
13
|
|
|
14
|
-
MSG = 'Prefer `model.active_entities` over `model.entities`.'
|
|
14
|
+
MSG = 'Prefer `model.active_entities` over `model.entities`.'
|
|
15
15
|
|
|
16
16
|
# Reference: http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
|
17
17
|
def_node_matcher :active_model_entities?, <<-PATTERN
|
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
|
14
14
|
|
|
15
15
|
def on_send(node)
|
|
16
16
|
# Only check instance methods.
|
|
17
|
-
return if node.receiver
|
|
17
|
+
return if node.receiver&.const_type?
|
|
18
18
|
|
|
19
19
|
name = node.method_name
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ module RuboCop
|
|
|
22
22
|
return unless dc_method
|
|
23
23
|
|
|
24
24
|
if dc_method.key?(:variables)
|
|
25
|
-
return unless node.receiver
|
|
25
|
+
return unless node.receiver&.variable?
|
|
26
26
|
|
|
27
27
|
receiver_name = node.receiver.children.first
|
|
28
28
|
# Account for instance and class variables.
|
|
@@ -34,9 +34,9 @@ module RuboCop
|
|
|
34
34
|
message = "#{path}##{name} is not part of the official API. "\
|
|
35
35
|
"It's a monkey-patched addition by Dynamic Components."
|
|
36
36
|
add_offense(node,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
location: :selector,
|
|
38
|
+
severity: :warning,
|
|
39
|
+
message: message)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
end
|
|
@@ -48,8 +48,8 @@ module RuboCop
|
|
|
48
48
|
|
|
49
49
|
include RangeHelp
|
|
50
50
|
|
|
51
|
-
MSG = 'Operation name should be a short capitalized description.'
|
|
52
|
-
MSG_MAX = 'Operation names should not be short and concise. [%d/%d]'
|
|
51
|
+
MSG = 'Operation name should be a short capitalized description.'
|
|
52
|
+
MSG_MAX = 'Operation names should not be short and concise. [%d/%d]'
|
|
53
53
|
|
|
54
54
|
def on_send(node)
|
|
55
55
|
_, method_name, *args = *node
|
|
@@ -72,8 +72,8 @@ module RuboCop
|
|
|
72
72
|
unless operation_name.size <= max_operation_name_length
|
|
73
73
|
message = format(MSG_MAX, operation_name.size, max_operation_name_length)
|
|
74
74
|
add_offense(args.first,
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
location: excess_range(args.first, operation_name),
|
|
76
|
+
message: message)
|
|
77
77
|
end
|
|
78
78
|
# Ensure operation name is not empty.
|
|
79
79
|
if operation_name.empty?
|
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
|
16
16
|
class SketchupFindSupportFile < SketchUp::Cop
|
|
17
17
|
|
|
18
18
|
MSG = 'Avoid `Sketchup.find_support_file` to find your '\
|
|
19
|
-
"extension's files."
|
|
19
|
+
"extension's files."
|
|
20
20
|
|
|
21
21
|
# http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
|
22
22
|
# https://rubocop.readthedocs.io/en/latest/node_pattern/
|
|
@@ -29,7 +29,7 @@ module RuboCop
|
|
|
29
29
|
include SketchUp::ToolChecker
|
|
30
30
|
|
|
31
31
|
MSG_MISSING_GET_EXTENTS = 'When drawing to the viewport implement '\
|
|
32
|
-
'`getExtents` so drawn geometry is not clipped.'
|
|
32
|
+
'`getExtents` so drawn geometry is not clipped.'
|
|
33
33
|
|
|
34
34
|
def on_tool_class(class_node, body_methods)
|
|
35
35
|
return unless find_method(body_methods, :draw)
|
|
@@ -31,10 +31,10 @@ module RuboCop
|
|
|
31
31
|
include SketchUp::ToolChecker
|
|
32
32
|
|
|
33
33
|
MSG_MISSING_INVALIDATE_METHOD = 'When drawing to the viewport, make '\
|
|
34
|
-
'sure to `suspend` and `deactivate` calls `view.invalidate`.'
|
|
34
|
+
'sure to `suspend` and `deactivate` calls `view.invalidate`.'
|
|
35
35
|
|
|
36
36
|
MSG_MISSING_INVALIDATE = 'When drawing to the viewport, make sure to '\
|
|
37
|
-
'call `view.invalidate` when the tool becomes inactive.'
|
|
37
|
+
'call `view.invalidate` when the tool becomes inactive.'
|
|
38
38
|
|
|
39
39
|
def_node_search :view_invalidate?, <<-PATTERN
|
|
40
40
|
(send (lvar :view) :invalidate ...)
|
|
@@ -24,7 +24,7 @@ module RuboCop
|
|
|
24
24
|
include SketchUp::ToolChecker
|
|
25
25
|
|
|
26
26
|
MSG_MISSING_ENABLE_VCB = 'When accepting user input, make sure to '\
|
|
27
|
-
'define `enableVCB?`.'
|
|
27
|
+
'define `enableVCB?`.'
|
|
28
28
|
|
|
29
29
|
def on_tool_class(class_node, body_methods)
|
|
30
30
|
return unless find_method(body_methods, :onUserText)
|
|
@@ -25,7 +25,7 @@ module RuboCop
|
|
|
25
25
|
include RangeHelp
|
|
26
26
|
|
|
27
27
|
MSG = 'Wrapping `toolbar.restore` in `UI.start_timer` is '\
|
|
28
|
-
'redundant.'
|
|
28
|
+
'redundant.'
|
|
29
29
|
|
|
30
30
|
def_node_matcher :toolbar_new?, <<-PATTERN
|
|
31
31
|
(send (const (const nil? :UI) :Toolbar) :new _)
|
|
@@ -50,7 +50,7 @@ module RuboCop
|
|
|
50
50
|
toolbar_variable_name = assignment_node.children.first
|
|
51
51
|
|
|
52
52
|
receiver = ui_start_timer_restore(assignment_node.parent).first
|
|
53
|
-
return unless receiver
|
|
53
|
+
return unless receiver&.variable?
|
|
54
54
|
|
|
55
55
|
receiver_variable_name = receiver.children.first
|
|
56
56
|
|
|
@@ -10,7 +10,7 @@ module RuboCop
|
|
|
10
10
|
module Formatter
|
|
11
11
|
# This formatter saves the output as an html file.
|
|
12
12
|
class ExtensionReviewFormatter < BaseFormatter
|
|
13
|
-
ELLIPSES = '<span class="extra-code">...</span>'
|
|
13
|
+
ELLIPSES = '<span class="extra-code">...</span>'
|
|
14
14
|
TEMPLATE_PATH =
|
|
15
15
|
File.expand_path('../../../../assets/output.html.erb', __dir__)
|
|
16
16
|
|
data/rubocop-sketchup.gemspec
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
|
2
4
|
require 'rubocop/sketchup/version'
|
|
3
5
|
|
|
@@ -11,7 +13,7 @@ Gem::Specification.new do |spec|
|
|
|
11
13
|
|
|
12
14
|
spec.version = RuboCop::SketchUp::VERSION
|
|
13
15
|
spec.platform = Gem::Platform::RUBY
|
|
14
|
-
spec.required_ruby_version = '>= 2.
|
|
16
|
+
spec.required_ruby_version = '>= 2.3.0'
|
|
15
17
|
|
|
16
18
|
spec.require_paths = ['lib']
|
|
17
19
|
spec.files = Dir[
|
|
@@ -22,6 +24,6 @@ Gem::Specification.new do |spec|
|
|
|
22
24
|
'Gemfile'
|
|
23
25
|
]
|
|
24
26
|
|
|
25
|
-
spec.add_dependency 'rubocop', '~> 0.
|
|
27
|
+
spec.add_dependency 'rubocop', '~> 0.69.0'
|
|
26
28
|
spec.add_development_dependency 'bundler', '>= 1.13', '< 3.0'
|
|
27
29
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-sketchup
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Trimble Inc, SketchUp Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-08-
|
|
11
|
+
date: 2019-08-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubocop
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.69.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0.
|
|
26
|
+
version: 0.69.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: bundler
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
131
131
|
requirements:
|
|
132
132
|
- - ">="
|
|
133
133
|
- !ruby/object:Gem::Version
|
|
134
|
-
version: 2.
|
|
134
|
+
version: 2.3.0
|
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
|
137
137
|
- - ">="
|