rubocop-sketchup 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +20 -19
- data/assets/output.html.erb +301 -301
- data/config/default.yml +379 -355
- data/lib/rubocop-sketchup.rb +49 -48
- data/lib/rubocop/sketchup.rb +12 -12
- data/lib/rubocop/sketchup/config.rb +63 -63
- data/lib/rubocop/sketchup/cop.rb +111 -111
- data/lib/rubocop/sketchup/cop/bugs/material_name.rb +108 -0
- data/lib/rubocop/sketchup/cop/bugs/render_mode.rb +72 -0
- data/lib/rubocop/sketchup/cop/bugs/uniform_scaling.rb +36 -0
- data/lib/rubocop/sketchup/cop/deprecations/add_separator_to_menu.rb +25 -25
- data/lib/rubocop/sketchup/cop/deprecations/operation_next_transparent.rb +30 -30
- data/lib/rubocop/sketchup/cop/deprecations/require_all.rb +27 -27
- data/lib/rubocop/sketchup/cop/deprecations/set_texture_projection.rb +26 -26
- data/lib/rubocop/sketchup/cop/deprecations/show_ruby_panel.rb +25 -25
- data/lib/rubocop/sketchup/cop/deprecations/sketchup_set.rb +30 -30
- data/lib/rubocop/sketchup/cop/performance/openssl.rb +41 -41
- data/lib/rubocop/sketchup/cop/performance/operation_disable_ui.rb +33 -33
- data/lib/rubocop/sketchup/cop/performance/selection_bulk.rb +79 -79
- data/lib/rubocop/sketchup/cop/performance/type_check.rb +63 -63
- data/lib/rubocop/sketchup/cop/performance/typename.rb +24 -24
- data/lib/rubocop/sketchup/cop/requirements/api_namespace.rb +30 -30
- data/lib/rubocop/sketchup/cop/requirements/exit.rb +32 -32
- data/lib/rubocop/sketchup/cop/requirements/extension_namespace.rb +108 -108
- data/lib/rubocop/sketchup/cop/requirements/file_structure.rb +97 -97
- data/lib/rubocop/sketchup/cop/requirements/gem_install.rb +45 -45
- data/lib/rubocop/sketchup/cop/requirements/get_extension_license.rb +95 -95
- data/lib/rubocop/sketchup/cop/requirements/global_constants.rb +38 -38
- data/lib/rubocop/sketchup/cop/requirements/global_include.rb +42 -42
- data/lib/rubocop/sketchup/cop/requirements/global_methods.rb +65 -65
- data/lib/rubocop/sketchup/cop/requirements/global_variables.rb +95 -95
- data/lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb +46 -46
- data/lib/rubocop/sketchup/cop/requirements/load_path.rb +83 -83
- data/lib/rubocop/sketchup/cop/requirements/minimal_registration.rb +73 -73
- data/lib/rubocop/sketchup/cop/requirements/observers_start_operation.rb +161 -161
- data/lib/rubocop/sketchup/cop/requirements/register_extension.rb +45 -45
- data/lib/rubocop/sketchup/cop/requirements/ruby_core_namespace.rb +291 -291
- data/lib/rubocop/sketchup/cop/requirements/ruby_stdlib_namespace.rb +634 -634
- data/lib/rubocop/sketchup/cop/requirements/shipped_extensions_namespace.rb +61 -61
- data/lib/rubocop/sketchup/cop/requirements/sketchup_extension.rb +119 -119
- data/lib/rubocop/sketchup/cop/requirements/sketchup_require.rb +163 -163
- data/lib/rubocop/sketchup/cop/suggestions/add_group.rb +49 -49
- data/lib/rubocop/sketchup/cop/suggestions/compatibility.rb +121 -117
- data/lib/rubocop/sketchup/cop/suggestions/dc_internals.rb +34 -34
- data/lib/rubocop/sketchup/cop/suggestions/file_encoding.rb +78 -78
- data/lib/rubocop/sketchup/cop/suggestions/model_entities.rb +58 -58
- data/lib/rubocop/sketchup/cop/suggestions/monkey_patched_api.rb +45 -45
- data/lib/rubocop/sketchup/cop/suggestions/operation_name.rb +137 -103
- data/lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb +39 -39
- data/lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb +44 -44
- data/lib/rubocop/sketchup/cop/suggestions/tool_invalidate.rb +66 -66
- data/lib/rubocop/sketchup/cop/suggestions/tool_user_input.rb +41 -41
- data/lib/rubocop/sketchup/cop/suggestions/toolbar_timer.rb +65 -65
- data/lib/rubocop/sketchup/dc_globals.rb +24 -24
- data/lib/rubocop/sketchup/dc_methods.rb +130 -130
- data/lib/rubocop/sketchup/extension_project.rb +65 -65
- data/lib/rubocop/sketchup/features.rb +738 -738
- data/lib/rubocop/sketchup/formatter/extension_review.rb +269 -259
- data/lib/rubocop/sketchup/inject.rb +19 -19
- data/lib/rubocop/sketchup/namespace.rb +47 -47
- data/lib/rubocop/sketchup/namespace_checker.rb +46 -46
- data/lib/rubocop/sketchup/no_comment_disable.rb +17 -17
- data/lib/rubocop/sketchup/range_help.rb +52 -52
- data/lib/rubocop/sketchup/sketchup_target_range.rb +75 -0
- data/lib/rubocop/sketchup/sketchup_version.rb +117 -87
- data/lib/rubocop/sketchup/tool_checker.rb +43 -43
- data/lib/rubocop/sketchup/version.rb +5 -5
- data/rubocop-sketchup.gemspec +27 -27
- metadata +8 -4
@@ -1,161 +1,161 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupRequirements
|
6
|
-
# Observers that perform model changes must create transparent operations
|
7
|
-
# to ensure the user can easily undo.
|
8
|
-
#
|
9
|
-
# An important part of SketchUp's user experience is to be able to easily
|
10
|
-
# undo any modification to the model. This is important to prevent
|
11
|
-
# accidental loss of work.
|
12
|
-
#
|
13
|
-
# If you for example have an observer that assigns a material to new faces
|
14
|
-
# then the user would still expect to undo this in a single operation.
|
15
|
-
#
|
16
|
-
# To achieve this, set the fourth argument in `model.start_operation` to
|
17
|
-
# `true` in order to chain your observer operation to the previous
|
18
|
-
# operation.
|
19
|
-
#
|
20
|
-
# @example
|
21
|
-
# class ExampleObserver < Sketchup::EntitiesObserver
|
22
|
-
# def onElementAdded(entities, entity)
|
23
|
-
# return unless entity.valid?
|
24
|
-
# return unless entity.is_a?(Sketchup::Face)
|
25
|
-
# entity.model.start_operation('Paint Face', true, false, true)
|
26
|
-
# entity.material = 'red'
|
27
|
-
# entity.model.commit_operation
|
28
|
-
# end
|
29
|
-
# end
|
30
|
-
class ObserversStartOperation < SketchUp::Cop
|
31
|
-
|
32
|
-
include SketchUp::NoCommentDisable
|
33
|
-
include RangeHelp
|
34
|
-
|
35
|
-
MSG = 'Observers should create transparent operations.'.freeze
|
36
|
-
|
37
|
-
def_node_search :start_operation, <<-PATTERN
|
38
|
-
(send
|
39
|
-
_ :start_operation
|
40
|
-
...)
|
41
|
-
PATTERN
|
42
|
-
|
43
|
-
OBSERVER_METHODS = %i[
|
44
|
-
onActivateModel
|
45
|
-
onNewModel
|
46
|
-
onOpenModel
|
47
|
-
onQuit
|
48
|
-
onUnloadExtension
|
49
|
-
|
50
|
-
onComponentInstanceAdded
|
51
|
-
onComponentInstanceRemoved
|
52
|
-
|
53
|
-
onComponentAdded
|
54
|
-
onComponentPropertiesChanged
|
55
|
-
onComponentRemoved
|
56
|
-
onComponentTypeChanged
|
57
|
-
|
58
|
-
onTextChanged
|
59
|
-
|
60
|
-
onActiveSectionPlaneChanged
|
61
|
-
onElementAdded
|
62
|
-
onElementModified
|
63
|
-
onElementRemoved
|
64
|
-
onEraseEntities
|
65
|
-
|
66
|
-
onChangeEntity
|
67
|
-
onEraseEntity
|
68
|
-
|
69
|
-
onClose
|
70
|
-
onOpen
|
71
|
-
|
72
|
-
onCurrentLayerChanged
|
73
|
-
onLayerAdded
|
74
|
-
onLayerChanged
|
75
|
-
onLayerRemoved
|
76
|
-
onRemoveAllLayers
|
77
|
-
|
78
|
-
onMaterialAdd
|
79
|
-
onMaterialChange
|
80
|
-
onMaterialRefChange
|
81
|
-
onMaterialRemove
|
82
|
-
onMaterialSetCurrent
|
83
|
-
onMaterialUndoRedo
|
84
|
-
|
85
|
-
onActivePathChanged
|
86
|
-
onAfterComponentSaveAs
|
87
|
-
onBeforeComponentSaveAs
|
88
|
-
onDeleteModel
|
89
|
-
onEraseAll
|
90
|
-
onExplode
|
91
|
-
onPidChanged
|
92
|
-
onPlaceComponent
|
93
|
-
onPostSaveModel
|
94
|
-
onPreSaveModel
|
95
|
-
onSaveModel
|
96
|
-
onTransactionAbort
|
97
|
-
onTransactionCommit
|
98
|
-
onTransactionEmpty
|
99
|
-
onTransactionRedo
|
100
|
-
onTransactionStart
|
101
|
-
onTransactionUndo
|
102
|
-
|
103
|
-
onOptionsProviderChanged
|
104
|
-
|
105
|
-
onContentsModified
|
106
|
-
onElementAdded
|
107
|
-
onElementRemoved
|
108
|
-
|
109
|
-
onRenderingOptionsChanged
|
110
|
-
|
111
|
-
onSelectionAdded
|
112
|
-
onSelectionBulkChange
|
113
|
-
onSelectionCleared
|
114
|
-
onSelectionRemoved
|
115
|
-
|
116
|
-
onShadowInfoChanged
|
117
|
-
|
118
|
-
onActiveToolChanged
|
119
|
-
onToolStateChanged
|
120
|
-
|
121
|
-
onViewChanged
|
122
|
-
].freeze
|
123
|
-
|
124
|
-
def on_def(node)
|
125
|
-
return unless observer_event?(node)
|
126
|
-
|
127
|
-
operations = start_operation(node)
|
128
|
-
operations.each { |operation|
|
129
|
-
_name, _disable_ui, _next_tr, transparent = operation.arguments
|
130
|
-
next unless transparent.nil? || transparent.falsey_literal?
|
131
|
-
|
132
|
-
location = operation_location(operation)
|
133
|
-
add_offense(operation, location: location)
|
134
|
-
}
|
135
|
-
end
|
136
|
-
|
137
|
-
private
|
138
|
-
|
139
|
-
def range(node)
|
140
|
-
range_between(node.begin_pos, node.end_pos)
|
141
|
-
end
|
142
|
-
|
143
|
-
def operation_location(node)
|
144
|
-
# Highlight the fourth argument if it's used. Fall back to the method
|
145
|
-
# name.
|
146
|
-
transparent_argument = node.arguments[3]
|
147
|
-
if transparent_argument
|
148
|
-
range(transparent_argument.loc.expression)
|
149
|
-
else
|
150
|
-
:selector
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
def observer_event?(node)
|
155
|
-
OBSERVER_METHODS.include?(node.method_name)
|
156
|
-
end
|
157
|
-
|
158
|
-
end
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupRequirements
|
6
|
+
# Observers that perform model changes must create transparent operations
|
7
|
+
# to ensure the user can easily undo.
|
8
|
+
#
|
9
|
+
# An important part of SketchUp's user experience is to be able to easily
|
10
|
+
# undo any modification to the model. This is important to prevent
|
11
|
+
# accidental loss of work.
|
12
|
+
#
|
13
|
+
# If you for example have an observer that assigns a material to new faces
|
14
|
+
# then the user would still expect to undo this in a single operation.
|
15
|
+
#
|
16
|
+
# To achieve this, set the fourth argument in `model.start_operation` to
|
17
|
+
# `true` in order to chain your observer operation to the previous
|
18
|
+
# operation.
|
19
|
+
#
|
20
|
+
# @example
|
21
|
+
# class ExampleObserver < Sketchup::EntitiesObserver
|
22
|
+
# def onElementAdded(entities, entity)
|
23
|
+
# return unless entity.valid?
|
24
|
+
# return unless entity.is_a?(Sketchup::Face)
|
25
|
+
# entity.model.start_operation('Paint Face', true, false, true)
|
26
|
+
# entity.material = 'red'
|
27
|
+
# entity.model.commit_operation
|
28
|
+
# end
|
29
|
+
# end
|
30
|
+
class ObserversStartOperation < SketchUp::Cop
|
31
|
+
|
32
|
+
include SketchUp::NoCommentDisable
|
33
|
+
include RangeHelp
|
34
|
+
|
35
|
+
MSG = 'Observers should create transparent operations.'.freeze
|
36
|
+
|
37
|
+
def_node_search :start_operation, <<-PATTERN
|
38
|
+
(send
|
39
|
+
_ :start_operation
|
40
|
+
...)
|
41
|
+
PATTERN
|
42
|
+
|
43
|
+
OBSERVER_METHODS = %i[
|
44
|
+
onActivateModel
|
45
|
+
onNewModel
|
46
|
+
onOpenModel
|
47
|
+
onQuit
|
48
|
+
onUnloadExtension
|
49
|
+
|
50
|
+
onComponentInstanceAdded
|
51
|
+
onComponentInstanceRemoved
|
52
|
+
|
53
|
+
onComponentAdded
|
54
|
+
onComponentPropertiesChanged
|
55
|
+
onComponentRemoved
|
56
|
+
onComponentTypeChanged
|
57
|
+
|
58
|
+
onTextChanged
|
59
|
+
|
60
|
+
onActiveSectionPlaneChanged
|
61
|
+
onElementAdded
|
62
|
+
onElementModified
|
63
|
+
onElementRemoved
|
64
|
+
onEraseEntities
|
65
|
+
|
66
|
+
onChangeEntity
|
67
|
+
onEraseEntity
|
68
|
+
|
69
|
+
onClose
|
70
|
+
onOpen
|
71
|
+
|
72
|
+
onCurrentLayerChanged
|
73
|
+
onLayerAdded
|
74
|
+
onLayerChanged
|
75
|
+
onLayerRemoved
|
76
|
+
onRemoveAllLayers
|
77
|
+
|
78
|
+
onMaterialAdd
|
79
|
+
onMaterialChange
|
80
|
+
onMaterialRefChange
|
81
|
+
onMaterialRemove
|
82
|
+
onMaterialSetCurrent
|
83
|
+
onMaterialUndoRedo
|
84
|
+
|
85
|
+
onActivePathChanged
|
86
|
+
onAfterComponentSaveAs
|
87
|
+
onBeforeComponentSaveAs
|
88
|
+
onDeleteModel
|
89
|
+
onEraseAll
|
90
|
+
onExplode
|
91
|
+
onPidChanged
|
92
|
+
onPlaceComponent
|
93
|
+
onPostSaveModel
|
94
|
+
onPreSaveModel
|
95
|
+
onSaveModel
|
96
|
+
onTransactionAbort
|
97
|
+
onTransactionCommit
|
98
|
+
onTransactionEmpty
|
99
|
+
onTransactionRedo
|
100
|
+
onTransactionStart
|
101
|
+
onTransactionUndo
|
102
|
+
|
103
|
+
onOptionsProviderChanged
|
104
|
+
|
105
|
+
onContentsModified
|
106
|
+
onElementAdded
|
107
|
+
onElementRemoved
|
108
|
+
|
109
|
+
onRenderingOptionsChanged
|
110
|
+
|
111
|
+
onSelectionAdded
|
112
|
+
onSelectionBulkChange
|
113
|
+
onSelectionCleared
|
114
|
+
onSelectionRemoved
|
115
|
+
|
116
|
+
onShadowInfoChanged
|
117
|
+
|
118
|
+
onActiveToolChanged
|
119
|
+
onToolStateChanged
|
120
|
+
|
121
|
+
onViewChanged
|
122
|
+
].freeze
|
123
|
+
|
124
|
+
def on_def(node)
|
125
|
+
return unless observer_event?(node)
|
126
|
+
|
127
|
+
operations = start_operation(node)
|
128
|
+
operations.each { |operation|
|
129
|
+
_name, _disable_ui, _next_tr, transparent = operation.arguments
|
130
|
+
next unless transparent.nil? || transparent.falsey_literal?
|
131
|
+
|
132
|
+
location = operation_location(operation)
|
133
|
+
add_offense(operation, location: location)
|
134
|
+
}
|
135
|
+
end
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
def range(node)
|
140
|
+
range_between(node.begin_pos, node.end_pos)
|
141
|
+
end
|
142
|
+
|
143
|
+
def operation_location(node)
|
144
|
+
# Highlight the fourth argument if it's used. Fall back to the method
|
145
|
+
# name.
|
146
|
+
transparent_argument = node.arguments[3]
|
147
|
+
if transparent_argument
|
148
|
+
range(transparent_argument.loc.expression)
|
149
|
+
else
|
150
|
+
:selector
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def observer_event?(node)
|
155
|
+
OBSERVER_METHODS.include?(node.method_name)
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -1,45 +1,45 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupRequirements
|
6
|
-
# Always register extensions to load by default. Otherwise it might
|
7
|
-
# confuse users to think the extension isn't working.
|
8
|
-
#
|
9
|
-
# @example Good - Extension will load upon first run.
|
10
|
-
# module Example
|
11
|
-
# unless file_loaded?(__FILE__)
|
12
|
-
# extension = SketchupExtension.new('Hello World', 'example/main')
|
13
|
-
# Sketchup.register_extension(extension, true)
|
14
|
-
# file_loaded(__FILE__)
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
class RegisterExtension < SketchUp::Cop
|
18
|
-
|
19
|
-
include SketchUp::NoCommentDisable
|
20
|
-
|
21
|
-
MSG = 'Always register extensions to load by default.'.freeze
|
22
|
-
|
23
|
-
def_node_search :sketchup_register_extension, <<-PATTERN
|
24
|
-
(send
|
25
|
-
(const nil? :Sketchup) :register_extension
|
26
|
-
$...)
|
27
|
-
PATTERN
|
28
|
-
|
29
|
-
def on_send(node)
|
30
|
-
sketchup_register_extension(node).each { |args|
|
31
|
-
if args.size < 2
|
32
|
-
add_offense(node, location: :selector)
|
33
|
-
next
|
34
|
-
end
|
35
|
-
load_arg = args[1]
|
36
|
-
next if load_arg.true_type?
|
37
|
-
|
38
|
-
add_offense(load_arg)
|
39
|
-
}
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupRequirements
|
6
|
+
# Always register extensions to load by default. Otherwise it might
|
7
|
+
# confuse users to think the extension isn't working.
|
8
|
+
#
|
9
|
+
# @example Good - Extension will load upon first run.
|
10
|
+
# module Example
|
11
|
+
# unless file_loaded?(__FILE__)
|
12
|
+
# extension = SketchupExtension.new('Hello World', 'example/main')
|
13
|
+
# Sketchup.register_extension(extension, true)
|
14
|
+
# file_loaded(__FILE__)
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
class RegisterExtension < SketchUp::Cop
|
18
|
+
|
19
|
+
include SketchUp::NoCommentDisable
|
20
|
+
|
21
|
+
MSG = 'Always register extensions to load by default.'.freeze
|
22
|
+
|
23
|
+
def_node_search :sketchup_register_extension, <<-PATTERN
|
24
|
+
(send
|
25
|
+
(const nil? :Sketchup) :register_extension
|
26
|
+
$...)
|
27
|
+
PATTERN
|
28
|
+
|
29
|
+
def on_send(node)
|
30
|
+
sketchup_register_extension(node).each { |args|
|
31
|
+
if args.size < 2
|
32
|
+
add_offense(node, location: :selector)
|
33
|
+
next
|
34
|
+
end
|
35
|
+
load_arg = args[1]
|
36
|
+
next if load_arg.true_type?
|
37
|
+
|
38
|
+
add_offense(load_arg)
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -1,291 +1,291 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupRequirements
|
6
|
-
# Extensions in SketchUp all share the same Ruby environment on the user's
|
7
|
-
# machine. Because of this it's important that each extension isolate
|
8
|
-
# itself to avoid clashing with other extensions.
|
9
|
-
#
|
10
|
-
# Extensions submitted to Extension Warehouse is expected to not modify
|
11
|
-
# core Ruby functionality.
|
12
|
-
class RubyCoreNamespace < SketchUp::Cop
|
13
|
-
|
14
|
-
include SketchUp::NoCommentDisable
|
15
|
-
include SketchUp::NamespaceChecker
|
16
|
-
|
17
|
-
MSG = 'Do not modify Ruby core functionality.'.freeze
|
18
|
-
|
19
|
-
# We check only against the top level namespaces. The core define more
|
20
|
-
# objects, but they are under one of the top level namespaces listed.
|
21
|
-
|
22
|
-
NAMESPACES_RUBY_186 = %w[
|
23
|
-
ArgumentError
|
24
|
-
Array
|
25
|
-
Bignum
|
26
|
-
Binding
|
27
|
-
Class
|
28
|
-
Comparable
|
29
|
-
Continuation
|
30
|
-
Data
|
31
|
-
Dir
|
32
|
-
EOFError
|
33
|
-
Enumerable
|
34
|
-
Errno
|
35
|
-
Exception
|
36
|
-
FalseClass
|
37
|
-
File
|
38
|
-
FileTest
|
39
|
-
Fixnum
|
40
|
-
Float
|
41
|
-
FloatDomainError
|
42
|
-
GC
|
43
|
-
Hash
|
44
|
-
IO
|
45
|
-
IOError
|
46
|
-
IndexError
|
47
|
-
Integer
|
48
|
-
Interrupt
|
49
|
-
Kernel
|
50
|
-
LoadError
|
51
|
-
LocalJumpError
|
52
|
-
Marshal
|
53
|
-
MatchData
|
54
|
-
Math
|
55
|
-
Method
|
56
|
-
Module
|
57
|
-
NameError
|
58
|
-
NilClass
|
59
|
-
NoMemoryError
|
60
|
-
NoMethodError
|
61
|
-
NotImplementedError
|
62
|
-
Numeric
|
63
|
-
Object
|
64
|
-
ObjectSpace
|
65
|
-
Precision
|
66
|
-
Proc
|
67
|
-
Process
|
68
|
-
Range
|
69
|
-
RangeError
|
70
|
-
Regexp
|
71
|
-
RegexpError
|
72
|
-
RuntimeError
|
73
|
-
ScriptError
|
74
|
-
SecurityError
|
75
|
-
Signal
|
76
|
-
SignalException
|
77
|
-
StandardError
|
78
|
-
String
|
79
|
-
Struct
|
80
|
-
Symbol
|
81
|
-
SyntaxError
|
82
|
-
SystemCallError
|
83
|
-
SystemExit
|
84
|
-
SystemStackError
|
85
|
-
Thread
|
86
|
-
ThreadError
|
87
|
-
ThreadGroup
|
88
|
-
Time
|
89
|
-
TrueClass
|
90
|
-
TypeError
|
91
|
-
UnboundMethod
|
92
|
-
ZeroDivisionError
|
93
|
-
].freeze
|
94
|
-
|
95
|
-
NAMESPACES_RUBY_200 = %w[
|
96
|
-
ARGF
|
97
|
-
ArgumentError
|
98
|
-
Array
|
99
|
-
BasicObject
|
100
|
-
Bignum
|
101
|
-
Binding
|
102
|
-
Class
|
103
|
-
Comparable
|
104
|
-
Complex
|
105
|
-
Continuation
|
106
|
-
Data
|
107
|
-
Dir
|
108
|
-
ENV
|
109
|
-
EOFError
|
110
|
-
Encoding
|
111
|
-
EncodingError
|
112
|
-
Enumerable
|
113
|
-
Enumerator
|
114
|
-
Errno
|
115
|
-
Exception
|
116
|
-
FalseClass
|
117
|
-
Fiber
|
118
|
-
FiberError
|
119
|
-
File
|
120
|
-
FileTest
|
121
|
-
Fixnum
|
122
|
-
Float
|
123
|
-
FloatDomainError
|
124
|
-
GC
|
125
|
-
Hash
|
126
|
-
IO
|
127
|
-
IOError
|
128
|
-
IndexError
|
129
|
-
Integer
|
130
|
-
Interrupt
|
131
|
-
Kernel
|
132
|
-
KeyError
|
133
|
-
LoadError
|
134
|
-
LocalJumpError
|
135
|
-
Marshal
|
136
|
-
MatchData
|
137
|
-
Math
|
138
|
-
Method
|
139
|
-
Module
|
140
|
-
Mutex
|
141
|
-
NameError
|
142
|
-
NilClass
|
143
|
-
NoMemoryError
|
144
|
-
NoMethodError
|
145
|
-
NotImplementedError
|
146
|
-
Numeric
|
147
|
-
Object
|
148
|
-
ObjectSpace
|
149
|
-
Proc
|
150
|
-
Process
|
151
|
-
Random
|
152
|
-
Range
|
153
|
-
RangeError
|
154
|
-
Rational
|
155
|
-
Regexp
|
156
|
-
RegexpError
|
157
|
-
RubyVM
|
158
|
-
RuntimeError
|
159
|
-
ScriptError
|
160
|
-
SecurityError
|
161
|
-
Signal
|
162
|
-
SignalException
|
163
|
-
StandardError
|
164
|
-
StopIteration
|
165
|
-
String
|
166
|
-
Struct
|
167
|
-
Symbol
|
168
|
-
SyntaxError
|
169
|
-
SystemCallError
|
170
|
-
SystemExit
|
171
|
-
SystemStackError
|
172
|
-
Thread
|
173
|
-
ThreadError
|
174
|
-
ThreadGroup
|
175
|
-
Time
|
176
|
-
TracePoint
|
177
|
-
TrueClass
|
178
|
-
TypeError
|
179
|
-
UnboundMethod
|
180
|
-
ZeroDivisionError
|
181
|
-
].freeze
|
182
|
-
|
183
|
-
NAMESPACES_RUBY_220 = %w[
|
184
|
-
ArgumentError
|
185
|
-
Array
|
186
|
-
BasicObject
|
187
|
-
Bignum
|
188
|
-
Binding
|
189
|
-
Class
|
190
|
-
Comparable
|
191
|
-
Complex
|
192
|
-
ConditionVariable
|
193
|
-
Continuation
|
194
|
-
Data
|
195
|
-
Dir
|
196
|
-
ENV
|
197
|
-
EOFError
|
198
|
-
Encoding
|
199
|
-
EncodingError
|
200
|
-
Enumerable
|
201
|
-
Enumerator
|
202
|
-
Errno
|
203
|
-
Exception
|
204
|
-
FalseClass
|
205
|
-
Fiber
|
206
|
-
FiberError
|
207
|
-
File
|
208
|
-
FileTest
|
209
|
-
Fixnum
|
210
|
-
Float
|
211
|
-
FloatDomainError
|
212
|
-
GC
|
213
|
-
Hash
|
214
|
-
IO
|
215
|
-
IOError
|
216
|
-
IndexError
|
217
|
-
Integer
|
218
|
-
Interrupt
|
219
|
-
Kernel
|
220
|
-
KeyError
|
221
|
-
LoadError
|
222
|
-
LocalJumpError
|
223
|
-
Marshal
|
224
|
-
MatchData
|
225
|
-
Math
|
226
|
-
Method
|
227
|
-
Module
|
228
|
-
Mutex
|
229
|
-
NameError
|
230
|
-
NilClass
|
231
|
-
NoMemoryError
|
232
|
-
NoMethodError
|
233
|
-
NotImplementedError
|
234
|
-
Numeric
|
235
|
-
Object
|
236
|
-
ObjectSpace
|
237
|
-
Proc
|
238
|
-
Process
|
239
|
-
Queue
|
240
|
-
Random
|
241
|
-
Range
|
242
|
-
RangeError
|
243
|
-
Rational
|
244
|
-
Regexp
|
245
|
-
RegexpError
|
246
|
-
RubyVM
|
247
|
-
RuntimeError
|
248
|
-
ScriptError
|
249
|
-
SecurityError
|
250
|
-
Signal
|
251
|
-
SignalException
|
252
|
-
SizedQueue
|
253
|
-
StandardError
|
254
|
-
StopIteration
|
255
|
-
String
|
256
|
-
Struct
|
257
|
-
Symbol
|
258
|
-
SyntaxError
|
259
|
-
SystemCallError
|
260
|
-
SystemExit
|
261
|
-
SystemStackError
|
262
|
-
Thread
|
263
|
-
ThreadError
|
264
|
-
ThreadGroup
|
265
|
-
Time
|
266
|
-
TracePoint
|
267
|
-
TrueClass
|
268
|
-
TypeError
|
269
|
-
UnboundMethod
|
270
|
-
UncaughtThrowError
|
271
|
-
ZeroDivisionError
|
272
|
-
].freeze
|
273
|
-
|
274
|
-
NAMESPACES = (
|
275
|
-
(
|
276
|
-
NAMESPACES_RUBY_186 |
|
277
|
-
NAMESPACES_RUBY_200 |
|
278
|
-
NAMESPACES_RUBY_220
|
279
|
-
# Remove Object because this is the global namespace and there are
|
280
|
-
# other checks for this.
|
281
|
-
) - ['Object']
|
282
|
-
).freeze
|
283
|
-
|
284
|
-
def namespaces
|
285
|
-
NAMESPACES
|
286
|
-
end
|
287
|
-
|
288
|
-
end
|
289
|
-
end
|
290
|
-
end
|
291
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupRequirements
|
6
|
+
# Extensions in SketchUp all share the same Ruby environment on the user's
|
7
|
+
# machine. Because of this it's important that each extension isolate
|
8
|
+
# itself to avoid clashing with other extensions.
|
9
|
+
#
|
10
|
+
# Extensions submitted to Extension Warehouse is expected to not modify
|
11
|
+
# core Ruby functionality.
|
12
|
+
class RubyCoreNamespace < SketchUp::Cop
|
13
|
+
|
14
|
+
include SketchUp::NoCommentDisable
|
15
|
+
include SketchUp::NamespaceChecker
|
16
|
+
|
17
|
+
MSG = 'Do not modify Ruby core functionality.'.freeze
|
18
|
+
|
19
|
+
# We check only against the top level namespaces. The core define more
|
20
|
+
# objects, but they are under one of the top level namespaces listed.
|
21
|
+
|
22
|
+
NAMESPACES_RUBY_186 = %w[
|
23
|
+
ArgumentError
|
24
|
+
Array
|
25
|
+
Bignum
|
26
|
+
Binding
|
27
|
+
Class
|
28
|
+
Comparable
|
29
|
+
Continuation
|
30
|
+
Data
|
31
|
+
Dir
|
32
|
+
EOFError
|
33
|
+
Enumerable
|
34
|
+
Errno
|
35
|
+
Exception
|
36
|
+
FalseClass
|
37
|
+
File
|
38
|
+
FileTest
|
39
|
+
Fixnum
|
40
|
+
Float
|
41
|
+
FloatDomainError
|
42
|
+
GC
|
43
|
+
Hash
|
44
|
+
IO
|
45
|
+
IOError
|
46
|
+
IndexError
|
47
|
+
Integer
|
48
|
+
Interrupt
|
49
|
+
Kernel
|
50
|
+
LoadError
|
51
|
+
LocalJumpError
|
52
|
+
Marshal
|
53
|
+
MatchData
|
54
|
+
Math
|
55
|
+
Method
|
56
|
+
Module
|
57
|
+
NameError
|
58
|
+
NilClass
|
59
|
+
NoMemoryError
|
60
|
+
NoMethodError
|
61
|
+
NotImplementedError
|
62
|
+
Numeric
|
63
|
+
Object
|
64
|
+
ObjectSpace
|
65
|
+
Precision
|
66
|
+
Proc
|
67
|
+
Process
|
68
|
+
Range
|
69
|
+
RangeError
|
70
|
+
Regexp
|
71
|
+
RegexpError
|
72
|
+
RuntimeError
|
73
|
+
ScriptError
|
74
|
+
SecurityError
|
75
|
+
Signal
|
76
|
+
SignalException
|
77
|
+
StandardError
|
78
|
+
String
|
79
|
+
Struct
|
80
|
+
Symbol
|
81
|
+
SyntaxError
|
82
|
+
SystemCallError
|
83
|
+
SystemExit
|
84
|
+
SystemStackError
|
85
|
+
Thread
|
86
|
+
ThreadError
|
87
|
+
ThreadGroup
|
88
|
+
Time
|
89
|
+
TrueClass
|
90
|
+
TypeError
|
91
|
+
UnboundMethod
|
92
|
+
ZeroDivisionError
|
93
|
+
].freeze
|
94
|
+
|
95
|
+
NAMESPACES_RUBY_200 = %w[
|
96
|
+
ARGF
|
97
|
+
ArgumentError
|
98
|
+
Array
|
99
|
+
BasicObject
|
100
|
+
Bignum
|
101
|
+
Binding
|
102
|
+
Class
|
103
|
+
Comparable
|
104
|
+
Complex
|
105
|
+
Continuation
|
106
|
+
Data
|
107
|
+
Dir
|
108
|
+
ENV
|
109
|
+
EOFError
|
110
|
+
Encoding
|
111
|
+
EncodingError
|
112
|
+
Enumerable
|
113
|
+
Enumerator
|
114
|
+
Errno
|
115
|
+
Exception
|
116
|
+
FalseClass
|
117
|
+
Fiber
|
118
|
+
FiberError
|
119
|
+
File
|
120
|
+
FileTest
|
121
|
+
Fixnum
|
122
|
+
Float
|
123
|
+
FloatDomainError
|
124
|
+
GC
|
125
|
+
Hash
|
126
|
+
IO
|
127
|
+
IOError
|
128
|
+
IndexError
|
129
|
+
Integer
|
130
|
+
Interrupt
|
131
|
+
Kernel
|
132
|
+
KeyError
|
133
|
+
LoadError
|
134
|
+
LocalJumpError
|
135
|
+
Marshal
|
136
|
+
MatchData
|
137
|
+
Math
|
138
|
+
Method
|
139
|
+
Module
|
140
|
+
Mutex
|
141
|
+
NameError
|
142
|
+
NilClass
|
143
|
+
NoMemoryError
|
144
|
+
NoMethodError
|
145
|
+
NotImplementedError
|
146
|
+
Numeric
|
147
|
+
Object
|
148
|
+
ObjectSpace
|
149
|
+
Proc
|
150
|
+
Process
|
151
|
+
Random
|
152
|
+
Range
|
153
|
+
RangeError
|
154
|
+
Rational
|
155
|
+
Regexp
|
156
|
+
RegexpError
|
157
|
+
RubyVM
|
158
|
+
RuntimeError
|
159
|
+
ScriptError
|
160
|
+
SecurityError
|
161
|
+
Signal
|
162
|
+
SignalException
|
163
|
+
StandardError
|
164
|
+
StopIteration
|
165
|
+
String
|
166
|
+
Struct
|
167
|
+
Symbol
|
168
|
+
SyntaxError
|
169
|
+
SystemCallError
|
170
|
+
SystemExit
|
171
|
+
SystemStackError
|
172
|
+
Thread
|
173
|
+
ThreadError
|
174
|
+
ThreadGroup
|
175
|
+
Time
|
176
|
+
TracePoint
|
177
|
+
TrueClass
|
178
|
+
TypeError
|
179
|
+
UnboundMethod
|
180
|
+
ZeroDivisionError
|
181
|
+
].freeze
|
182
|
+
|
183
|
+
NAMESPACES_RUBY_220 = %w[
|
184
|
+
ArgumentError
|
185
|
+
Array
|
186
|
+
BasicObject
|
187
|
+
Bignum
|
188
|
+
Binding
|
189
|
+
Class
|
190
|
+
Comparable
|
191
|
+
Complex
|
192
|
+
ConditionVariable
|
193
|
+
Continuation
|
194
|
+
Data
|
195
|
+
Dir
|
196
|
+
ENV
|
197
|
+
EOFError
|
198
|
+
Encoding
|
199
|
+
EncodingError
|
200
|
+
Enumerable
|
201
|
+
Enumerator
|
202
|
+
Errno
|
203
|
+
Exception
|
204
|
+
FalseClass
|
205
|
+
Fiber
|
206
|
+
FiberError
|
207
|
+
File
|
208
|
+
FileTest
|
209
|
+
Fixnum
|
210
|
+
Float
|
211
|
+
FloatDomainError
|
212
|
+
GC
|
213
|
+
Hash
|
214
|
+
IO
|
215
|
+
IOError
|
216
|
+
IndexError
|
217
|
+
Integer
|
218
|
+
Interrupt
|
219
|
+
Kernel
|
220
|
+
KeyError
|
221
|
+
LoadError
|
222
|
+
LocalJumpError
|
223
|
+
Marshal
|
224
|
+
MatchData
|
225
|
+
Math
|
226
|
+
Method
|
227
|
+
Module
|
228
|
+
Mutex
|
229
|
+
NameError
|
230
|
+
NilClass
|
231
|
+
NoMemoryError
|
232
|
+
NoMethodError
|
233
|
+
NotImplementedError
|
234
|
+
Numeric
|
235
|
+
Object
|
236
|
+
ObjectSpace
|
237
|
+
Proc
|
238
|
+
Process
|
239
|
+
Queue
|
240
|
+
Random
|
241
|
+
Range
|
242
|
+
RangeError
|
243
|
+
Rational
|
244
|
+
Regexp
|
245
|
+
RegexpError
|
246
|
+
RubyVM
|
247
|
+
RuntimeError
|
248
|
+
ScriptError
|
249
|
+
SecurityError
|
250
|
+
Signal
|
251
|
+
SignalException
|
252
|
+
SizedQueue
|
253
|
+
StandardError
|
254
|
+
StopIteration
|
255
|
+
String
|
256
|
+
Struct
|
257
|
+
Symbol
|
258
|
+
SyntaxError
|
259
|
+
SystemCallError
|
260
|
+
SystemExit
|
261
|
+
SystemStackError
|
262
|
+
Thread
|
263
|
+
ThreadError
|
264
|
+
ThreadGroup
|
265
|
+
Time
|
266
|
+
TracePoint
|
267
|
+
TrueClass
|
268
|
+
TypeError
|
269
|
+
UnboundMethod
|
270
|
+
UncaughtThrowError
|
271
|
+
ZeroDivisionError
|
272
|
+
].freeze
|
273
|
+
|
274
|
+
NAMESPACES = (
|
275
|
+
(
|
276
|
+
NAMESPACES_RUBY_186 |
|
277
|
+
NAMESPACES_RUBY_200 |
|
278
|
+
NAMESPACES_RUBY_220
|
279
|
+
# Remove Object because this is the global namespace and there are
|
280
|
+
# other checks for this.
|
281
|
+
) - ['Object']
|
282
|
+
).freeze
|
283
|
+
|
284
|
+
def namespaces
|
285
|
+
NAMESPACES
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|