rubocop-sketchup 0.4.1 → 0.5.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 +7 -1
- data/assets/logo.png +0 -0
- data/assets/output.html.erb +301 -0
- data/config/default.yml +141 -36
- data/lib/rubocop/sketchup/config.rb +28 -8
- data/lib/rubocop/sketchup/cop/deprecations/add_separator_to_menu.rb +4 -1
- data/lib/rubocop/sketchup/cop/deprecations/operation_next_transparent.rb +11 -2
- data/lib/rubocop/sketchup/cop/deprecations/require_all.rb +7 -2
- data/lib/rubocop/sketchup/cop/deprecations/set_texture_projection.rb +6 -2
- data/lib/rubocop/sketchup/cop/deprecations/show_ruby_panel.rb +4 -1
- data/lib/rubocop/sketchup/cop/deprecations/sketchup_set.rb +8 -0
- data/lib/rubocop/sketchup/cop/performance/openssl.rb +5 -3
- data/lib/rubocop/sketchup/cop/performance/operation_disable_ui.rb +10 -2
- data/lib/rubocop/sketchup/cop/performance/selection_bulk.rb +11 -4
- data/lib/rubocop/sketchup/cop/performance/type_check.rb +63 -0
- data/lib/rubocop/sketchup/cop/performance/typename.rb +6 -1
- data/lib/rubocop/sketchup/cop/requirements/api_namespace.rb +8 -2
- data/lib/rubocop/sketchup/cop/requirements/exit.rb +7 -3
- data/lib/rubocop/sketchup/cop/requirements/extension_namespace.rb +32 -2
- data/lib/rubocop/sketchup/cop/requirements/file_structure.rb +22 -10
- data/lib/rubocop/sketchup/cop/requirements/gem_install.rb +45 -0
- data/lib/rubocop/sketchup/cop/requirements/get_extension_license.rb +95 -0
- data/lib/rubocop/sketchup/cop/requirements/global_constants.rb +10 -1
- data/lib/rubocop/sketchup/cop/requirements/global_include.rb +9 -2
- data/lib/rubocop/sketchup/cop/requirements/global_methods.rb +10 -1
- data/lib/rubocop/sketchup/cop/requirements/global_variables.rb +13 -4
- data/lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb +6 -4
- data/lib/rubocop/sketchup/cop/requirements/load_path.rb +9 -6
- data/lib/rubocop/sketchup/cop/requirements/minimal_registration.rb +26 -2
- data/lib/rubocop/sketchup/cop/requirements/observers_start_operation.rb +28 -2
- data/lib/rubocop/sketchup/cop/requirements/register_extension.rb +12 -2
- data/lib/rubocop/sketchup/cop/requirements/ruby_core_namespace.rb +14 -8
- data/lib/rubocop/sketchup/cop/requirements/ruby_stdlib_namespace.rb +594 -588
- data/lib/rubocop/sketchup/cop/requirements/shipped_extensions_namespace.rb +6 -6
- data/lib/rubocop/sketchup/cop/requirements/sketchup_extension.rb +28 -9
- data/lib/rubocop/sketchup/cop/requirements/sketchup_require.rb +163 -0
- data/lib/rubocop/sketchup/cop/suggestions/add_group.rb +49 -0
- data/lib/rubocop/sketchup/cop/suggestions/compatibility.rb +35 -6
- data/lib/rubocop/sketchup/cop/suggestions/dc_internals.rb +6 -3
- data/lib/rubocop/sketchup/cop/suggestions/file_encoding.rb +3 -0
- data/lib/rubocop/sketchup/cop/suggestions/model_entities.rb +9 -2
- data/lib/rubocop/sketchup/cop/suggestions/monkey_patched_api.rb +5 -1
- data/lib/rubocop/sketchup/cop/suggestions/operation_name.rb +20 -9
- data/lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb +13 -2
- data/lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb +44 -0
- data/lib/rubocop/sketchup/cop/suggestions/tool_invalidate.rb +66 -0
- data/lib/rubocop/sketchup/cop/suggestions/tool_user_input.rb +41 -0
- data/lib/rubocop/sketchup/cop/suggestions/toolbar_timer.rb +65 -0
- data/lib/rubocop/sketchup/cop.rb +38 -18
- data/lib/rubocop/sketchup/dc_globals.rb +1 -1
- data/lib/rubocop/sketchup/dc_methods.rb +27 -27
- data/lib/rubocop/sketchup/extension_project.rb +19 -2
- data/lib/rubocop/sketchup/formatter/extension_review.rb +35 -15
- data/lib/rubocop/sketchup/inject.rb +1 -1
- data/lib/rubocop/sketchup/namespace.rb +1 -0
- data/lib/rubocop/sketchup/namespace_checker.rb +4 -1
- data/lib/rubocop/sketchup/no_comment_disable.rb +1 -1
- data/lib/rubocop/sketchup/range_help.rb +52 -0
- data/lib/rubocop/sketchup/sketchup_version.rb +4 -2
- data/lib/rubocop/sketchup/tool_checker.rb +43 -0
- data/lib/rubocop/sketchup/version.rb +1 -1
- data/lib/rubocop/sketchup.rb +1 -1
- data/lib/rubocop-sketchup.rb +9 -0
- data/rubocop-sketchup.gemspec +8 -11
- metadata +18 -6
- data/lib/rubocop/sketchup/cop/suggestions/sketchup_require.rb +0 -67
data/config/default.yml
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
-
|
1
|
+
# Common configuration.
|
2
|
+
|
2
3
|
AllCops:
|
3
4
|
SketchUp:
|
5
|
+
# The path to the extension source. This needs to be correct in order to
|
6
|
+
# correctly validate file structure.
|
4
7
|
SourcePath: src
|
8
|
+
# Set target SketchUp version. Compatibility checks can then warn if you
|
9
|
+
# use features that belong to older SketchUp versions. Refer to the manual
|
10
|
+
# for list of valid versions.
|
5
11
|
TargetSketchUpVersion: 2016
|
12
|
+
# Indicate if you plan to scramble/encrypt this extension using the .RBS or
|
13
|
+
# .RBE format. It changes the technical requirements for requiring files.
|
14
|
+
EncryptedExtension: false
|
15
|
+
# Binary Ruby C Extension must always be loaded using Ruby's own `require`.
|
16
|
+
# If you enable `AllCops/SketchUp/EncryptedExtension` you need to list
|
17
|
+
# the require paths for your Ruby C Extensions if you have any.
|
18
|
+
ExtensionBinaries: []
|
19
|
+
# You can set up exclude pattens for all SketchUp departments.
|
20
|
+
Exclude: []
|
21
|
+
# Alternativly you can set up department wide exclusion.
|
6
22
|
SketchupDeprecations:
|
7
23
|
Exclude: []
|
8
24
|
SketchupPerformance:
|
@@ -12,77 +28,94 @@ AllCops:
|
|
12
28
|
SketchupSuggestions:
|
13
29
|
Exclude: []
|
14
30
|
|
31
|
+
|
15
32
|
SketchupDeprecations/AddSeparatorToMenu:
|
16
33
|
Description: The method `add_separator_to_menu` is deprecated.
|
17
34
|
Details: >-
|
18
|
-
|
19
|
-
|
35
|
+
Avoid adding separators to top level menus. If you require
|
36
|
+
grouping use a sub-menu instead.
|
37
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_deprecations.md#addseparatortomenu
|
20
38
|
Enabled: true
|
21
39
|
|
22
40
|
SketchupDeprecations/OperationNextTransparent:
|
23
41
|
Description: Third argument in `model.start_operation` is deprecated.
|
24
42
|
Details: >-
|
25
|
-
|
26
|
-
|
43
|
+
It is not possible to predict what operation will come next. Avoid
|
44
|
+
making the next operation transparent.
|
45
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_deprecations.md#operationnexttransparent
|
27
46
|
Enabled: true
|
28
47
|
|
29
48
|
SketchupDeprecations/RequireAll:
|
30
49
|
Description: The method `require_all` is deprecated.
|
31
50
|
Details: >-
|
32
|
-
|
33
|
-
|
51
|
+
This method adds the path given to `$LOAD_PATH` which can affect
|
52
|
+
other extensions.
|
53
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_deprecations.md#requireall
|
34
54
|
Enabled: true
|
35
55
|
|
36
56
|
SketchupDeprecations/SetTextureProjection:
|
37
57
|
Description: The method `Sketchup::Face#set_texture_projection` is deprecated.
|
38
58
|
Details: >-
|
39
|
-
|
40
|
-
|
59
|
+
This method never worked right. It's not possible to control the
|
60
|
+
position and orientation of the texture.
|
61
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_deprecations.md#settextureprojection
|
41
62
|
Enabled: true
|
42
63
|
|
43
64
|
SketchupDeprecations/ShowRubyPanel:
|
44
65
|
Description: The method `show_ruby_panel` is deprecated.
|
45
|
-
Details:
|
46
|
-
|
66
|
+
Details: Use `SKETCHUP_CONSOLE.show` instead.
|
67
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_deprecations.md#showrubypanel
|
47
68
|
Enabled: true
|
48
69
|
|
49
70
|
SketchupDeprecations/SketchupSet:
|
50
71
|
Description: The class `Sketchup::Set` is deprecated.
|
51
72
|
Details: >-
|
52
|
-
|
53
|
-
|
73
|
+
It's slow and with limited functionality. Use the `Set` class in
|
74
|
+
the Ruby StdLib instead.
|
75
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_deprecations.md#sketchupset
|
54
76
|
Enabled: true
|
55
77
|
|
78
|
+
|
56
79
|
SketchupPerformance/OpenSSL:
|
57
80
|
Description: Avoid using Ruby's OpenSSL within SketchUp.
|
58
81
|
Details: >-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
82
|
+
A flaw in how it obtain random bits under Windows can severely
|
83
|
+
affect performance, freezing SketchUp for many minutes. This also
|
84
|
+
affects SecureRandom and anything else that depend on OpenSSL.
|
85
|
+
Net::HTTP is affected if connecting via HTTPS. Connecting via
|
86
|
+
plain HTTP is unaffected.
|
87
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_performance.md#openssl
|
64
88
|
Enabled: true
|
65
89
|
|
66
90
|
SketchupPerformance/OperationDisableUI:
|
67
91
|
Description: Operations should disable the UI for performance gain.
|
92
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_performance.md#operationdisableui
|
68
93
|
Enabled: true
|
69
94
|
|
70
95
|
SketchupPerformance/SelectionBulkChanges:
|
71
96
|
Description: >-
|
72
97
|
Avoid modifying the selection set within loops. It's much
|
73
98
|
faster to change the selection in bulk.
|
99
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_performance.md#selectionbulkchanges
|
100
|
+
Enabled: true
|
101
|
+
|
102
|
+
SketchupPerformance/TypeCheck:
|
103
|
+
Description: String comparisons for type checks are very slow.
|
104
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_performance.md#typecheck
|
74
105
|
Enabled: true
|
75
106
|
|
76
107
|
SketchupPerformance/Typename:
|
77
108
|
Description: Using `.typename` is very slow, prefer `.is_a?` instead.
|
109
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_performance.md#typename
|
78
110
|
Enabled: true
|
79
111
|
|
80
112
|
|
81
113
|
SketchupRequirements/ApiNamespace:
|
82
114
|
Description: Don't modify the SketchUp API namespace.
|
83
115
|
Details: >-
|
84
|
-
|
85
|
-
|
116
|
+
Modifying the API namespace could affect other extensions - making
|
117
|
+
it hard for other developers to determine what is going on.
|
118
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#apinamespace
|
86
119
|
Enabled: true
|
87
120
|
|
88
121
|
SketchupRequirements/Exit:
|
@@ -90,8 +123,9 @@ SketchupRequirements/Exit:
|
|
90
123
|
Details: >-
|
91
124
|
SketchUp will trap `exit` and prevent that, with a message in the
|
92
125
|
console. But `exit!` is not trapped and with terminate SketchUp
|
93
|
-
without shutting down cleanly.
|
94
|
-
|
126
|
+
without shutting down cleanly. Use `return`, `next` or `break`
|
127
|
+
instead.
|
128
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#exit
|
95
129
|
Enabled: true
|
96
130
|
|
97
131
|
SketchupRequirements/ExtensionNamespace:
|
@@ -99,38 +133,57 @@ SketchupRequirements/ExtensionNamespace:
|
|
99
133
|
Details: >-
|
100
134
|
To avoid clashing with other extensions a single root namespace
|
101
135
|
should all the extension's code.
|
102
|
-
|
136
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#extensionnamespace
|
103
137
|
Exceptions: []
|
138
|
+
Enabled: true
|
104
139
|
|
105
140
|
SketchupRequirements/FileStructure:
|
106
141
|
Description: Expected extension file structure not found.
|
107
142
|
Details: >-
|
108
143
|
Check that the extension conform to expected file structure with a
|
109
144
|
single root .rb file and a support folder with matching name.
|
145
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#filestructure
|
146
|
+
Enabled: true
|
147
|
+
|
148
|
+
SketchupRequirements/GemInstall:
|
149
|
+
Description: >-
|
150
|
+
Gem.install is unreliable in SketchUp, and can cause
|
151
|
+
extensions to clash.
|
152
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#geminstall
|
153
|
+
Enabled: true
|
154
|
+
|
155
|
+
SketchupRequirements/GetExtensionLicense:
|
156
|
+
Description: Pass in valid extension ID from local string literals.
|
157
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#getextensionlicense
|
110
158
|
Enabled: true
|
111
159
|
|
112
160
|
SketchupRequirements/GlobalConstants:
|
113
161
|
Description: Do not introduce global constants.
|
162
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#globalconstants
|
114
163
|
Enabled: true
|
115
164
|
|
116
165
|
SketchupRequirements/GlobalInclude:
|
117
166
|
Description: Do not include modules into global namespace.
|
167
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#globalinclude
|
118
168
|
Enabled: true
|
119
169
|
|
120
170
|
SketchupRequirements/GlobalMethods:
|
121
171
|
Description: Extensions should not define global methods.
|
172
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#globalmethods
|
122
173
|
Enabled: true
|
123
174
|
|
124
175
|
SketchupRequirements/GlobalVariables:
|
125
176
|
Description: Do not introduce global variables.
|
177
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#globalvariables
|
126
178
|
Enabled: true
|
127
179
|
|
128
180
|
SketchupRequirements/LanguageHandlerGlobals:
|
129
181
|
Description: Don't use other known global variables.
|
130
182
|
Details: >-
|
131
|
-
Avoid using globals in general, but
|
132
|
-
known to be in use by other extensions made by SketchUp.
|
133
|
-
|
183
|
+
Avoid using globals in general, but especially these which are
|
184
|
+
known to be in use by other extensions made by SketchUp. They are
|
185
|
+
still in use due to compatibility reasons.
|
186
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#languagehandlerglobals
|
134
187
|
Enabled: true
|
135
188
|
|
136
189
|
SketchupRequirements/LoadPath:
|
@@ -138,6 +191,7 @@ SketchupRequirements/LoadPath:
|
|
138
191
|
Details: >-
|
139
192
|
This can cause other extensions from not loading correctly. Always
|
140
193
|
load files relative to the installation path for the extension.
|
194
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#loadpath
|
141
195
|
Enabled: true
|
142
196
|
|
143
197
|
SketchupRequirements/MinimalRegistration:
|
@@ -145,6 +199,7 @@ SketchupRequirements/MinimalRegistration:
|
|
145
199
|
Don't load extension files in the root file registering the
|
146
200
|
extension. Extensions should not load additional files when
|
147
201
|
it's disabled.
|
202
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#minimalregistration
|
148
203
|
Enabled: true
|
149
204
|
|
150
205
|
SketchupRequirements/ObserversStartOperation:
|
@@ -152,12 +207,14 @@ SketchupRequirements/ObserversStartOperation:
|
|
152
207
|
Details: >-
|
153
208
|
When making model changes within an observer event, start a
|
154
209
|
transparent operation to ensure a clean undo-stack.
|
210
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#observersstartoperation
|
155
211
|
Enabled: true
|
156
212
|
|
157
213
|
SketchupRequirements/RegisterExtension:
|
158
214
|
Description: >-
|
159
215
|
Always register extensions to load by default. Otherwise it
|
160
216
|
might confuse users to think the extension isn't working.
|
217
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#registerextension
|
161
218
|
Enabled: true
|
162
219
|
|
163
220
|
SketchupRequirements/RequireToolsRubyFiles:
|
@@ -166,18 +223,29 @@ SketchupRequirements/RequireToolsRubyFiles:
|
|
166
223
|
has been loaded, files from SketchUp's Tools folder should be
|
167
224
|
required in using `require` and with their file extension to
|
168
225
|
avoid duplicate loading.
|
226
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#requiretoolsrubyfiles
|
169
227
|
Enabled: true
|
170
228
|
|
171
229
|
SketchupRequirements/RubyCoreNamespace:
|
172
230
|
Description: Do not modify Ruby core functionality.
|
231
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#rubycorenamespace
|
173
232
|
Enabled: true
|
174
233
|
|
175
234
|
SketchupRequirements/RubyStdLibNamespace:
|
176
235
|
Description: Do not modify Ruby stdlib functionality.
|
236
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#rubystdlibnamespace
|
237
|
+
Enabled: true
|
238
|
+
|
239
|
+
SketchupRequirements/SketchupRequire:
|
240
|
+
Description: >-
|
241
|
+
Omit file extensions when using `Sketchup.require` to allow
|
242
|
+
encrypted files to be loaded.
|
243
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#sketchuprequire
|
177
244
|
Enabled: true
|
178
245
|
|
179
246
|
SketchupRequirements/ShippedExtensionsNamespace:
|
180
247
|
Description: Don't use the namespace of SketchUp's shipped extensions.
|
248
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#shippedextensionsnamespace
|
181
249
|
Enabled: true
|
182
250
|
|
183
251
|
SketchupRequirements/SketchupExtension:
|
@@ -185,33 +253,47 @@ SketchupRequirements/SketchupExtension:
|
|
185
253
|
Register a single instance of SketchupExtension per extension.
|
186
254
|
This should be done by the root .rb file in the extension
|
187
255
|
package.
|
256
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_requirements.md#sketchupextension
|
188
257
|
Enabled: true
|
189
258
|
|
190
259
|
|
260
|
+
SketchupSuggestions/AddGroup:
|
261
|
+
Description: Avoid creating groups out of existing entities.
|
262
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#addgroup
|
263
|
+
Enabled: true
|
264
|
+
|
265
|
+
SketchupSuggestions/Compatibility:
|
266
|
+
Description: Incompatible feature with target SketchUp version.
|
267
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#compatibility
|
268
|
+
Enabled: true
|
269
|
+
|
191
270
|
SketchupSuggestions/DynamicComponentInternals:
|
192
271
|
Description: >-
|
193
272
|
Avoid relying on internal logic of Dynamic Components. It's
|
194
273
|
behavior might change between versions.
|
274
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#dynamiccomponentinternals
|
195
275
|
Enabled: true
|
196
276
|
|
197
277
|
SketchupSuggestions/FileEncoding:
|
198
278
|
Description: Beware encoding bug in Ruby when using `__FILE__` and `__dir__`.
|
199
279
|
Details: >-
|
200
|
-
When using `__FILE__` and `__dir__`, beware that Ruby doesn't
|
201
|
-
the correct encoding to the strings under Windows. When they
|
280
|
+
When using `__FILE__` and `__dir__`, beware that Ruby doesn't
|
281
|
+
apply the correct encoding to the strings under Windows. When they
|
202
282
|
contain non-english characters it will lead to exceptions being
|
203
283
|
raised when the strings are used. Force encoding to work around
|
204
284
|
this.
|
285
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#fileencoding
|
205
286
|
Enabled: true
|
206
287
|
|
207
288
|
SketchupSuggestions/ModelEntities:
|
208
289
|
Description: >-
|
209
|
-
Typically one should use `model.active_entities` instead
|
210
|
-
|
290
|
+
Typically one should use `model.active_entities` instead of
|
291
|
+
`model.entities`.
|
211
292
|
Details: >-
|
212
293
|
In SketchUp the norm is that editing is performed in the opened
|
213
294
|
instance (`model.active_entities`). `model.entities` refer to the
|
214
295
|
model root.
|
296
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#modelentities
|
215
297
|
Enabled: true
|
216
298
|
|
217
299
|
SketchupSuggestions/MonkeyPatchedApi:
|
@@ -221,6 +303,7 @@ SketchupSuggestions/MonkeyPatchedApi:
|
|
221
303
|
Details: >-
|
222
304
|
These methods stops working when the extensions are disabled and
|
223
305
|
may change or be removed.
|
306
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#monkeypatchedapi
|
224
307
|
Enabled: true
|
225
308
|
|
226
309
|
SketchupSuggestions/OperationName:
|
@@ -228,10 +311,11 @@ SketchupSuggestions/OperationName:
|
|
228
311
|
Check that operation names are human friendly and consistent
|
229
312
|
with SketchUp.
|
230
313
|
Details: >-
|
231
|
-
This check is very naive and might produce false positives. Use
|
232
|
-
|
233
|
-
|
314
|
+
This check is very naive and might produce false positives. Use as
|
315
|
+
guidance only.
|
316
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#operationname
|
234
317
|
Max: 25
|
318
|
+
Enabled: true
|
235
319
|
|
236
320
|
SketchupSuggestions/SketchupFindSupportFile:
|
237
321
|
Description: >-
|
@@ -241,10 +325,31 @@ SketchupSuggestions/SketchupFindSupportFile:
|
|
241
325
|
Extensions might be installed outside the SketchUp Plugins folder.
|
242
326
|
Use `__FILE__` and `__dir__` to locate your files relative to the
|
243
327
|
executing file.
|
328
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#sketchupfindsupportfile
|
244
329
|
Enabled: true
|
245
330
|
|
246
|
-
SketchupSuggestions/
|
331
|
+
SketchupSuggestions/ToolDrawingBounds:
|
247
332
|
Description: >-
|
248
|
-
|
249
|
-
|
333
|
+
When drawing to the viewport implement `getExtents` so drawn
|
334
|
+
geometry is not clipped.
|
335
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#tooldrawingbounds
|
336
|
+
Enabled: true
|
337
|
+
|
338
|
+
SketchupSuggestions/ToolInvalidate:
|
339
|
+
Description: >-
|
340
|
+
When drawing to the viewport, make sure tools invalidate when
|
341
|
+
tool becomes inactive.
|
342
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#toolinvalidate
|
343
|
+
Enabled: true
|
344
|
+
|
345
|
+
SketchupSuggestions/ToolUserInput:
|
346
|
+
Description: >-
|
347
|
+
When a tool is accepting user input, make sure to define
|
348
|
+
enableVCB?.
|
349
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#tooluserinput
|
350
|
+
Enabled: true
|
351
|
+
|
352
|
+
SketchupSuggestions/ToolbarTimer:
|
353
|
+
Description: Wrapping `toolbar.restore` in `UI.start_timer` is redundant.
|
354
|
+
Reference: https://github.com/SketchUp/rubocop-sketchup/tree/master/manual/cops_suggestions.md#toolbartimer
|
250
355
|
Enabled: true
|
@@ -5,7 +5,7 @@ module RuboCop
|
|
5
5
|
module Config
|
6
6
|
|
7
7
|
DEFAULT_CONFIGURATION =
|
8
|
-
|
8
|
+
SketchUp::CONFIG.fetch('AllCops').fetch('SketchUp')
|
9
9
|
|
10
10
|
private
|
11
11
|
|
@@ -18,19 +18,15 @@ module RuboCop
|
|
18
18
|
end
|
19
19
|
|
20
20
|
|
21
|
-
def
|
21
|
+
def sketchup_config_key?(key)
|
22
22
|
return unless all_cops_config.key?('SketchUp')
|
23
|
-
all_cops_config.fetch('SketchUp').key?('SourcePath')
|
24
|
-
end
|
25
23
|
|
26
|
-
|
27
|
-
sketchup_cops_config.fetch('SourcePath')
|
24
|
+
all_cops_config.fetch('SketchUp').key?(key)
|
28
25
|
end
|
29
26
|
|
30
27
|
|
31
28
|
def sketchup_target_version?
|
32
|
-
|
33
|
-
all_cops_config.fetch('SketchUp').key?('TargetSketchUpVersion')
|
29
|
+
sketchup_config_key?('TargetSketchUpVersion')
|
34
30
|
end
|
35
31
|
|
36
32
|
def sketchup_target_version
|
@@ -38,6 +34,30 @@ module RuboCop
|
|
38
34
|
version ? SketchUpVersion.new(version) : nil
|
39
35
|
end
|
40
36
|
|
37
|
+
|
38
|
+
def extension_source_path_config?
|
39
|
+
sketchup_config_key?('SourcePath')
|
40
|
+
end
|
41
|
+
|
42
|
+
def extension_source_path_config
|
43
|
+
sketchup_cops_config.fetch('SourcePath')
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def encrypted_extension?
|
48
|
+
sketchup_config_key?('EncryptedExtension') &&
|
49
|
+
sketchup_cops_config.fetch('EncryptedExtension')
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def extension_binaries?
|
54
|
+
sketchup_config_key?('ExtensionBinaries')
|
55
|
+
end
|
56
|
+
|
57
|
+
def extension_binaries
|
58
|
+
sketchup_cops_config.fetch('ExtensionBinaries')
|
59
|
+
end
|
60
|
+
|
41
61
|
end
|
42
62
|
end
|
43
63
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module SketchupDeprecations
|
6
|
+
# Avoid adding separators to top level menus. If you require grouping use
|
7
|
+
# a sub-menu instead.
|
6
8
|
class AddSeparatorToMenu < SketchUp::Cop
|
7
9
|
|
8
10
|
MSG = 'Method is deprecated.'.freeze
|
@@ -13,7 +15,8 @@ module RuboCop
|
|
13
15
|
|
14
16
|
def on_send(node)
|
15
17
|
return unless add_separator_to_menu?(node)
|
16
|
-
|
18
|
+
|
19
|
+
add_offense(node, location: :selector)
|
17
20
|
end
|
18
21
|
|
19
22
|
end
|
@@ -3,7 +3,15 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module SketchupDeprecations
|
6
|
-
#
|
6
|
+
# If set to true, then whatever operation comes after this one will be
|
7
|
+
# appended into one combined operation, allowing the user the undo both
|
8
|
+
# actions with a single undo command.
|
9
|
+
#
|
10
|
+
# This flag is a highly difficult one, since there are so many ways that a
|
11
|
+
# SketchUp user can interrupt a given operation with one of their own.
|
12
|
+
#
|
13
|
+
# Only use this flag if you have no other option, for instance to work
|
14
|
+
# around bug in how `Sketchup::Model#place_component` starts operations.
|
7
15
|
class OperationNextTransparent < SketchUp::Cop
|
8
16
|
MSG = 'Third argument is deprecated.'.freeze
|
9
17
|
|
@@ -11,8 +19,9 @@ module RuboCop
|
|
11
19
|
_, method_name, *args = *node
|
12
20
|
return unless method_name == :start_operation
|
13
21
|
return if args.size < 3
|
22
|
+
|
14
23
|
argument = args[2]
|
15
|
-
next_transparent = argument.type == :true
|
24
|
+
next_transparent = (argument.type == :true)
|
16
25
|
add_offense(argument, location: :expression) if next_transparent
|
17
26
|
end
|
18
27
|
end
|
@@ -3,9 +3,13 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module SketchupDeprecations
|
6
|
+
# Method is deprecated because it adds the given path to `$LOAD_PATH`.
|
7
|
+
# Modifying `$LOAD_PATH` is bad practice because it can cause extensions
|
8
|
+
# to inadvertently load the wrong file.
|
6
9
|
class RequireAll < SketchUp::Cop
|
7
10
|
|
8
|
-
MSG = 'Method is deprecated because it adds the given path
|
11
|
+
MSG = 'Method is deprecated because it adds the given path '\
|
12
|
+
'to $LOAD_PATH.'.freeze
|
9
13
|
|
10
14
|
def_node_matcher :require_all?, <<-PATTERN
|
11
15
|
(send nil? :require_all _)
|
@@ -13,7 +17,8 @@ module RuboCop
|
|
13
17
|
|
14
18
|
def on_send(node)
|
15
19
|
return unless require_all?(node)
|
16
|
-
|
20
|
+
|
21
|
+
add_offense(node, location: :selector)
|
17
22
|
end
|
18
23
|
|
19
24
|
end
|
@@ -3,9 +3,12 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module SketchupDeprecations
|
6
|
+
# Method is deprecated because it creates invalid UV mapping. Saving the
|
7
|
+
# model will display a dialog indicating that the model needs to be
|
8
|
+
# repaired. Once repaired the UV mapping will visually change.
|
6
9
|
class SetTextureProjection < SketchUp::Cop
|
7
10
|
|
8
|
-
MSG = 'Method is deprecated. It
|
11
|
+
MSG = 'Method is deprecated. It can create invalid UV mapping.'.freeze
|
9
12
|
|
10
13
|
def_node_matcher :set_texture_projection?, <<-PATTERN
|
11
14
|
(send _ :set_texture_projection ...)
|
@@ -13,7 +16,8 @@ module RuboCop
|
|
13
16
|
|
14
17
|
def on_send(node)
|
15
18
|
return unless set_texture_projection?(node)
|
16
|
-
|
19
|
+
|
20
|
+
add_offense(node, location: :selector)
|
17
21
|
end
|
18
22
|
|
19
23
|
end
|
@@ -3,9 +3,11 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module SketchupDeprecations
|
6
|
+
# Method is deprecated. Use `SKETCHUP_CONSOLE.show` instead.
|
6
7
|
class ShowRubyPanel < SketchUp::Cop
|
7
8
|
|
8
|
-
MSG = 'Method is deprecated. Use `SKETCHUP_CONSOLE.show`
|
9
|
+
MSG = 'Method is deprecated. Use `SKETCHUP_CONSOLE.show` '\
|
10
|
+
'instead.'.freeze
|
9
11
|
|
10
12
|
def_node_matcher :show_ruby_panel?, <<-PATTERN
|
11
13
|
(send nil? :show_ruby_panel)
|
@@ -13,6 +15,7 @@ module RuboCop
|
|
13
15
|
|
14
16
|
def on_send(node)
|
15
17
|
return unless show_ruby_panel?(node)
|
18
|
+
|
16
19
|
add_offense(node, location: :expression)
|
17
20
|
end
|
18
21
|
|
@@ -3,6 +3,13 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module SketchupDeprecations
|
6
|
+
# From SketchUp 6 until SketchUp 2013 the SketchUp API shipped with a
|
7
|
+
# `Set` class. When SketchUp started shipping with the Ruby StdLib in
|
8
|
+
# SketchUp 2014 the class was changed from `Set` to `Sketchup::Set` in
|
9
|
+
# order to avoid conflict with the Ruby Standard Library.
|
10
|
+
#
|
11
|
+
# The `Sketchup::Set` class is much slower than Ruby's own `Set` class
|
12
|
+
# and less versatile.
|
6
13
|
class SketchupSet < SketchUp::Cop
|
7
14
|
|
8
15
|
MSG = 'Class is deprecated.'.freeze
|
@@ -13,6 +20,7 @@ module RuboCop
|
|
13
20
|
|
14
21
|
def on_const(node)
|
15
22
|
return unless sketchup_set?(node)
|
23
|
+
|
16
24
|
add_offense(node, location: :expression)
|
17
25
|
end
|
18
26
|
|
@@ -12,10 +12,11 @@ module RuboCop
|
|
12
12
|
#
|
13
13
|
# `SecureRandom` is also affected by this, as it uses OpenSSL to seed.
|
14
14
|
#
|
15
|
-
# It also affects Net::HTTP if making HTTPS connections.
|
15
|
+
# It also affects `Net::HTTP` if making HTTPS connections.
|
16
16
|
class OpenSSL < SketchUp::Cop
|
17
17
|
|
18
|
-
MSG = 'Avoid use of OpenSSL within SketchUp due to severe performance
|
18
|
+
MSG = 'Avoid use of OpenSSL within SketchUp due to severe performance '\
|
19
|
+
'issues.'.freeze
|
19
20
|
|
20
21
|
# http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
21
22
|
# https://rubocop.readthedocs.io/en/latest/node_pattern/
|
@@ -25,12 +26,13 @@ module RuboCop
|
|
25
26
|
)
|
26
27
|
PATTERN
|
27
28
|
|
28
|
-
OPEN_SSL_USAGE = %w[openssl securerandom net/https net/http]
|
29
|
+
OPEN_SSL_USAGE = %w[openssl securerandom net/https net/http].freeze
|
29
30
|
|
30
31
|
def on_send(node)
|
31
32
|
filename = require(node)
|
32
33
|
return if filename.nil?
|
33
34
|
return unless OPEN_SSL_USAGE.include?(filename.downcase)
|
35
|
+
|
34
36
|
add_offense(node, location: :expression)
|
35
37
|
end
|
36
38
|
end
|
@@ -3,20 +3,28 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module SketchupPerformance
|
6
|
-
#
|
6
|
+
# Operations should disable the UI for performance gain.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# model = Sketchup.active_model
|
10
|
+
# model.start_operation('Operation Name', true)
|
11
|
+
# # <model changes>
|
12
|
+
# model.commit_operation
|
7
13
|
class OperationDisableUI < SketchUp::Cop
|
8
14
|
MSG = 'Operations should disable the UI for performance gain.'.freeze
|
9
15
|
|
10
16
|
def on_send(node)
|
11
17
|
_, method_name, *args = *node
|
12
18
|
return unless method_name == :start_operation
|
19
|
+
|
13
20
|
if args.size < 2
|
14
|
-
add_offense(node, location: :
|
21
|
+
add_offense(node, location: :selector)
|
15
22
|
return
|
16
23
|
end
|
17
24
|
argument = args[1]
|
18
25
|
disable_ui = argument.truthy_literal?
|
19
26
|
return if disable_ui
|
27
|
+
|
20
28
|
add_offense(argument, location: :expression)
|
21
29
|
end
|
22
30
|
end
|