rubocop-sketchup 0.5.0 → 0.6.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +19 -19
  3. data/assets/output.html.erb +301 -301
  4. data/config/default.yml +355 -355
  5. data/lib/rubocop/sketchup/config.rb +63 -63
  6. data/lib/rubocop/sketchup/cop/deprecations/add_separator_to_menu.rb +25 -25
  7. data/lib/rubocop/sketchup/cop/deprecations/operation_next_transparent.rb +30 -30
  8. data/lib/rubocop/sketchup/cop/deprecations/require_all.rb +27 -27
  9. data/lib/rubocop/sketchup/cop/deprecations/set_texture_projection.rb +26 -26
  10. data/lib/rubocop/sketchup/cop/deprecations/show_ruby_panel.rb +25 -25
  11. data/lib/rubocop/sketchup/cop/deprecations/sketchup_set.rb +30 -30
  12. data/lib/rubocop/sketchup/cop/performance/openssl.rb +41 -41
  13. data/lib/rubocop/sketchup/cop/performance/operation_disable_ui.rb +33 -33
  14. data/lib/rubocop/sketchup/cop/performance/selection_bulk.rb +79 -79
  15. data/lib/rubocop/sketchup/cop/performance/type_check.rb +63 -63
  16. data/lib/rubocop/sketchup/cop/performance/typename.rb +24 -24
  17. data/lib/rubocop/sketchup/cop/requirements/api_namespace.rb +30 -30
  18. data/lib/rubocop/sketchup/cop/requirements/exit.rb +32 -32
  19. data/lib/rubocop/sketchup/cop/requirements/extension_namespace.rb +108 -108
  20. data/lib/rubocop/sketchup/cop/requirements/file_structure.rb +97 -97
  21. data/lib/rubocop/sketchup/cop/requirements/gem_install.rb +45 -45
  22. data/lib/rubocop/sketchup/cop/requirements/get_extension_license.rb +95 -95
  23. data/lib/rubocop/sketchup/cop/requirements/global_constants.rb +38 -38
  24. data/lib/rubocop/sketchup/cop/requirements/global_include.rb +42 -42
  25. data/lib/rubocop/sketchup/cop/requirements/global_methods.rb +65 -65
  26. data/lib/rubocop/sketchup/cop/requirements/global_variables.rb +95 -95
  27. data/lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb +46 -46
  28. data/lib/rubocop/sketchup/cop/requirements/load_path.rb +83 -83
  29. data/lib/rubocop/sketchup/cop/requirements/minimal_registration.rb +73 -73
  30. data/lib/rubocop/sketchup/cop/requirements/observers_start_operation.rb +161 -161
  31. data/lib/rubocop/sketchup/cop/requirements/register_extension.rb +45 -45
  32. data/lib/rubocop/sketchup/cop/requirements/ruby_core_namespace.rb +291 -291
  33. data/lib/rubocop/sketchup/cop/requirements/ruby_stdlib_namespace.rb +634 -634
  34. data/lib/rubocop/sketchup/cop/requirements/shipped_extensions_namespace.rb +61 -61
  35. data/lib/rubocop/sketchup/cop/requirements/sketchup_extension.rb +119 -119
  36. data/lib/rubocop/sketchup/cop/requirements/sketchup_require.rb +163 -163
  37. data/lib/rubocop/sketchup/cop/suggestions/add_group.rb +49 -49
  38. data/lib/rubocop/sketchup/cop/suggestions/compatibility.rb +117 -117
  39. data/lib/rubocop/sketchup/cop/suggestions/dc_internals.rb +34 -34
  40. data/lib/rubocop/sketchup/cop/suggestions/file_encoding.rb +78 -78
  41. data/lib/rubocop/sketchup/cop/suggestions/model_entities.rb +58 -58
  42. data/lib/rubocop/sketchup/cop/suggestions/monkey_patched_api.rb +45 -45
  43. data/lib/rubocop/sketchup/cop/suggestions/operation_name.rb +103 -103
  44. data/lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb +39 -39
  45. data/lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb +44 -44
  46. data/lib/rubocop/sketchup/cop/suggestions/tool_invalidate.rb +66 -66
  47. data/lib/rubocop/sketchup/cop/suggestions/tool_user_input.rb +41 -41
  48. data/lib/rubocop/sketchup/cop/suggestions/toolbar_timer.rb +65 -65
  49. data/lib/rubocop/sketchup/cop.rb +111 -111
  50. data/lib/rubocop/sketchup/dc_globals.rb +24 -24
  51. data/lib/rubocop/sketchup/dc_methods.rb +130 -130
  52. data/lib/rubocop/sketchup/extension_project.rb +65 -65
  53. data/lib/rubocop/sketchup/features.rb +738 -738
  54. data/lib/rubocop/sketchup/formatter/extension_review.rb +259 -259
  55. data/lib/rubocop/sketchup/inject.rb +19 -19
  56. data/lib/rubocop/sketchup/namespace.rb +47 -47
  57. data/lib/rubocop/sketchup/namespace_checker.rb +46 -46
  58. data/lib/rubocop/sketchup/no_comment_disable.rb +17 -17
  59. data/lib/rubocop/sketchup/range_help.rb +52 -52
  60. data/lib/rubocop/sketchup/sketchup_version.rb +87 -87
  61. data/lib/rubocop/sketchup/tool_checker.rb +43 -43
  62. data/lib/rubocop/sketchup/version.rb +5 -5
  63. data/lib/rubocop/sketchup.rb +12 -12
  64. data/lib/rubocop-sketchup.rb +48 -48
  65. data/rubocop-sketchup.gemspec +27 -27
  66. metadata +4 -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