rubocop-sketchup 1.3.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/config/default.yml +21 -0
  4. data/lib/rubocop/sketchup/config.rb +1 -1
  5. data/lib/rubocop/sketchup/cop/bugs/material_name.rb +1 -1
  6. data/lib/rubocop/sketchup/cop/bugs/render_mode.rb +2 -2
  7. data/lib/rubocop/sketchup/cop/bugs/uniform_scaling.rb +1 -1
  8. data/lib/rubocop/sketchup/cop/deprecations/require_all.rb +1 -1
  9. data/lib/rubocop/sketchup/cop/deprecations/show_ruby_panel.rb +1 -1
  10. data/lib/rubocop/sketchup/cop/performance/openssl.rb +2 -2
  11. data/lib/rubocop/sketchup/cop/performance/selection_bulk.rb +1 -1
  12. data/lib/rubocop/sketchup/cop/performance/type_check.rb +1 -1
  13. data/lib/rubocop/sketchup/cop/requirements/debug_mode.rb +27 -0
  14. data/lib/rubocop/sketchup/cop/requirements/exit.rb +1 -1
  15. data/lib/rubocop/sketchup/cop/requirements/extension_namespace.rb +1 -1
  16. data/lib/rubocop/sketchup/cop/requirements/file_structure.rb +3 -3
  17. data/lib/rubocop/sketchup/cop/requirements/gem_install.rb +1 -1
  18. data/lib/rubocop/sketchup/cop/requirements/get_extension_license.rb +1 -1
  19. data/lib/rubocop/sketchup/cop/requirements/initialize_entity.rb +76 -0
  20. data/lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb +2 -2
  21. data/lib/rubocop/sketchup/cop/requirements/minimal_registration.rb +1 -1
  22. data/lib/rubocop/sketchup/cop/requirements/sketchup_require.rb +8 -7
  23. data/lib/rubocop/sketchup/cop/suggestions/compatibility.rb +2 -2
  24. data/lib/rubocop/sketchup/cop/suggestions/monkey_patched_api.rb +1 -1
  25. data/lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb +1 -1
  26. data/lib/rubocop/sketchup/cop/suggestions/sleep.rb +25 -0
  27. data/lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb +2 -2
  28. data/lib/rubocop/sketchup/cop/suggestions/tool_invalidate.rb +4 -4
  29. data/lib/rubocop/sketchup/cop/suggestions/tool_user_input.rb +1 -1
  30. data/lib/rubocop/sketchup/cop/suggestions/toolbar_timer.rb +1 -1
  31. data/lib/rubocop/sketchup/features.rb +94 -0
  32. data/lib/rubocop/sketchup/formatter/extension_review.rb +2 -2
  33. data/lib/rubocop/sketchup/generator.rb +21 -0
  34. data/lib/rubocop/sketchup/sketchup_version.rb +3 -0
  35. data/lib/rubocop/sketchup/tool_checker.rb +0 -2
  36. data/lib/rubocop/sketchup/version.rb +1 -1
  37. data/rubocop-sketchup.gemspec +1 -2
  38. metadata +12 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9935671119993e41eef012a5f69fca2709a59d7db06d28c2e89ff9ea5721aa7
4
- data.tar.gz: 05cba02d5fa27e8eab8b32cae46d586c68d5fec8922b959febf89ebd36660ced
3
+ metadata.gz: 14a5adab07c22fb2c09430a96c7f4376db73489c8015cb46445e71065cd377a0
4
+ data.tar.gz: d966dfb2e361f1f147357048d1d5db235d19ba3053ff5bd93f254436ef658612
5
5
  SHA512:
6
- metadata.gz: 06e197b228db557e7d1b0ab9eeec6550e9a70a8e64fa4079f6f4e093249f0057390f9ce6f4270d15e1be956e36b684ff66f5e926a55d0a2b862e33d113a8a3c2
7
- data.tar.gz: 54242ae1e4bb983394e9976f02893d98794ae46971755751bdbcea1b4ecdfd9e1c6e3c9e4dde6cd995e7977b788d8ec5fa3dab693723bdd84f30dd3717b8a590
6
+ metadata.gz: 1174647c4482bdc0d30cb55898c8d2ded2c0a3faee7ce8c174b6b1948ef81a880c32433bf09c116e40629ccfd56fbddd07cdafbc01bf5b84f794c24d6cc94ea5
7
+ data.tar.gz: f051f128770b9467ee64dedeb7acd2f92d4f645546519d944dd8782b6174d2ea465cd5bf444f09bc22757d00b9621cef5fd185a69b824c639e9192ead7e38e3d
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :test do
8
- gem 'appveyor-worker', '~> 0.2', require: false
9
8
  gem 'rake', '~> 12.0', require: false
10
9
  gem 'rspec', '~> 3.7', require: false
11
10
  gem 'rubocop-performance', '~> 1.11.0', require: false
@@ -16,6 +15,7 @@ end
16
15
 
17
16
  group :development do
18
17
  gem 'bump', '~> 0.5', require: false
18
+ gem 'bundler', '>= 1.13', '< 3.0', require: false
19
19
  gem 'solargraph', '~> 0.34', require: false
20
20
  gem 'yard', '~> 0.9', require: false
21
21
  end
data/config/default.yml CHANGED
@@ -142,6 +142,14 @@ SketchupRequirements/ApiNamespace:
142
142
  Reference: https://github.com/SketchUp/rubocop-sketchup/tree/main/manual/cops_requirements.md#apinamespace
143
143
  Enabled: true
144
144
 
145
+ SketchupRequirements/DebugMode:
146
+ Description: Don't change the SketchUp debug mode in production.
147
+ Details: >-
148
+ Disabling the SketchUp debug mode hides warnings other extension
149
+ developers may rely on.
150
+ Reference: https://github.com/SketchUp/rubocop-sketchup/tree/main/manual/cops_requirements.md#debugmode
151
+ Enabled: true
152
+
145
153
  SketchupRequirements/Exit:
146
154
  Description: Exit attempts to kill the Ruby interpreter.
147
155
  Details: >-
@@ -201,6 +209,11 @@ SketchupRequirements/GlobalVariables:
201
209
  Reference: https://github.com/SketchUp/rubocop-sketchup/tree/main/manual/cops_requirements.md#globalvariables
202
210
  Enabled: true
203
211
 
212
+ SketchupRequirements/InitializeEntity:
213
+ Description: Do not initialize SketchUp Entity objects with `new`.
214
+ Reference: https://github.com/SketchUp/rubocop-sketchup/tree/main/manual/cops_requirements.md#initializeentity
215
+ Enabled: true
216
+
204
217
  SketchupRequirements/LanguageHandlerGlobals:
205
218
  Description: Don't use other known global variables.
206
219
  Details: >-
@@ -352,6 +365,14 @@ SketchupSuggestions/SketchupFindSupportFile:
352
365
  Reference: https://github.com/SketchUp/rubocop-sketchup/tree/main/manual/cops_suggestions.md#sketchupfindsupportfile
353
366
  Enabled: true
354
367
 
368
+ SketchupSuggestions/Sleep:
369
+ Description: Avoid kernel `sleep` as it freezes up SketchUp.
370
+ Details: >-
371
+ Prefer `UI.start_timer` or a callback from the resource you are
372
+ waiting for.
373
+ Reference: https://github.com/SketchUp/rubocop-sketchup/tree/main/manual/cops_suggestions.md#sleep
374
+ Enabled: true
375
+
355
376
  SketchupSuggestions/ToolDrawingBounds:
356
377
  Description: >-
357
378
  When drawing to the viewport implement `getExtents` so drawn
@@ -19,7 +19,7 @@ module RuboCop
19
19
 
20
20
 
21
21
  def sketchup_config_key?(key)
22
- return unless all_cops_config.key?('SketchUp')
22
+ return false unless all_cops_config.key?('SketchUp')
23
23
 
24
24
  all_cops_config.fetch('SketchUp').key?(key)
25
25
  end
@@ -78,7 +78,7 @@ module RuboCop
78
78
  (send #material? :name= _)
79
79
  PATTERN
80
80
 
81
- MSG_SET_NAME = '`material.name=` might add duplicate materials in '\
81
+ MSG_SET_NAME = '`material.name=` might add duplicate materials in ' \
82
82
  'SU2017 and older versions.'
83
83
 
84
84
  def on_send(node)
@@ -42,10 +42,10 @@ module RuboCop
42
42
  (send _ :[]= (str "RenderMode") (int $_))
43
43
  PATTERN
44
44
 
45
- MSG_OBSOLETE = 'Obsolete render mode will crash in SU2017 and '\
45
+ MSG_OBSOLETE = 'Obsolete render mode will crash in SU2017 and ' \
46
46
  'newer versions.'
47
47
 
48
- MSG_INVALID = 'Invalid render mode will crash in SU2017 and '\
48
+ MSG_INVALID = 'Invalid render mode will crash in SU2017 and ' \
49
49
  'newer versions.'
50
50
 
51
51
  def on_send(node)
@@ -20,7 +20,7 @@ module RuboCop
20
20
  (send (const (const nil? :Geom) :Transformation) :scaling _)
21
21
  PATTERN
22
22
 
23
- MSG = 'Resulting transformation matrix might yield unexpected '\
23
+ MSG = 'Resulting transformation matrix might yield unexpected ' \
24
24
  'results.'
25
25
 
26
26
  def on_send(node)
@@ -8,7 +8,7 @@ module RuboCop
8
8
  # to inadvertently load the wrong file.
9
9
  class RequireAll < SketchUp::Cop
10
10
 
11
- MSG = 'Method is deprecated because it adds the given path '\
11
+ MSG = 'Method is deprecated because it adds the given path ' \
12
12
  'to $LOAD_PATH.'
13
13
 
14
14
  def_node_matcher :require_all?, <<-PATTERN
@@ -6,7 +6,7 @@ module RuboCop
6
6
  # Method is deprecated. Use `SKETCHUP_CONSOLE.show` instead.
7
7
  class ShowRubyPanel < SketchUp::Cop
8
8
 
9
- MSG = 'Method is deprecated. Use `SKETCHUP_CONSOLE.show` '\
9
+ MSG = 'Method is deprecated. Use `SKETCHUP_CONSOLE.show` ' \
10
10
  'instead.'
11
11
 
12
12
  def_node_matcher :show_ruby_panel?, <<-PATTERN
@@ -15,8 +15,8 @@ module RuboCop
15
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 '\
19
- 'issues.'
18
+ MSG = 'Avoid use of OpenSSL within SketchUp due to severe ' \
19
+ 'performance issues.'
20
20
 
21
21
  # http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
22
22
  # https://rubocop.readthedocs.io/en/latest/node_pattern/
@@ -28,7 +28,7 @@ module RuboCop
28
28
 
29
29
  include RangeHelp
30
30
 
31
- MSG = 'Prefer changing selection in bulk instead of modifying '\
31
+ MSG = 'Prefer changing selection in bulk instead of modifying ' \
32
32
  'selection within loops.'
33
33
 
34
34
  # http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
@@ -30,7 +30,7 @@ module RuboCop
30
30
 
31
31
  include RangeHelp
32
32
 
33
- MSG = 'String comparisons are very slow, prefer `.is_a?` '\
33
+ MSG = 'String comparisons are very slow, prefer `.is_a?` ' \
34
34
  'instead.'
35
35
 
36
36
  def_node_matcher :string_class_compare?, <<-PATTERN
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module SketchupRequirements
6
+ # Changing the global SketchUp debug mode can cause warnings from other
7
+ # extensions to be silenced.
8
+ # Don't let your extension change the debug mode in a production setting.
9
+ class DebugMode < SketchUp::Cop
10
+
11
+ def_node_matcher :sketchup_set_debug?, <<-PATTERN
12
+ (send (const nil? :Sketchup) :debug_mode= _)
13
+ PATTERN
14
+
15
+ MSG_SET_NAME = 'Changing `Sketchup.debug_mode=` may hide warnings ' \
16
+ 'other extension developers rely on.'
17
+
18
+ def on_send(node)
19
+ return unless sketchup_set_debug?(node)
20
+
21
+ add_offense(node, message: MSG_SET_NAME)
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -13,7 +13,7 @@ module RuboCop
13
13
 
14
14
  include SketchUp::NoCommentDisable
15
15
 
16
- MSG = '`%s` attempts to kill the Ruby interpreter. Use `return`, '\
16
+ MSG = '`%s` attempts to kill the Ruby interpreter. Use `return`, ' \
17
17
  '`next`, `break` or `raise` instead.'
18
18
 
19
19
  # Reference: http://rubocop.readthedocs.io/en/latest/development/
@@ -103,7 +103,7 @@ module RuboCop
103
103
 
104
104
  def message(node)
105
105
  namespace = Namespace.new(node.defined_module_name).from_root
106
- format('Use a single root namespace. '\
106
+ format('Use a single root namespace. ' \
107
107
  '(Found `%<found>s`; Previously found `%<expected>s`)',
108
108
  found: namespace, expected: @@namespace)
109
109
  end
@@ -37,7 +37,7 @@ module RuboCop
37
37
 
38
38
  # Ensure there is only one root Ruby file.
39
39
  if root_ruby_files.size != 1
40
- msg = 'Extensions must have exactly one root Ruby (.rb) file. '\
40
+ msg = 'Extensions must have exactly one root Ruby (.rb) file. ' \
41
41
  'Found: %d'
42
42
  add_offense(nil,
43
43
  location: range,
@@ -65,8 +65,8 @@ module RuboCop
65
65
  # Ensure support directory's name match the root Ruby file.
66
66
  support_directory = sub_folders.first
67
67
  unless support_directory.basename.to_s == extension_basename
68
- msg = 'Extensions must have a support directory matching the name '\
69
- 'of the root Ruby file. Expected %s, found %s'
68
+ msg = 'Extensions must have a support directory matching the ' \
69
+ 'name 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
72
  location: range,
@@ -25,7 +25,7 @@ module RuboCop
25
25
  include RangeHelp
26
26
  include SketchUp::NoCommentDisable
27
27
 
28
- MSG = '`Gem.install` is unreliable in SketchUp, and can cause '\
28
+ MSG = '`Gem.install` is unreliable in SketchUp, and can cause ' \
29
29
  'extensions to clash.'
30
30
 
31
31
  # Reference: http://rubocop.readthedocs.io/en/latest/development/
@@ -16,7 +16,7 @@ module RuboCop
16
16
 
17
17
  MSG_INVALID = 'Invalid extension GUID'
18
18
 
19
- MSG_WRONG_TYPE = 'Only pass in extension GUID from local string '\
19
+ MSG_WRONG_TYPE = 'Only pass in extension GUID from local string ' \
20
20
  'literals.'
21
21
 
22
22
  MSG_TRAILING_SPACE = 'Extra space in extension GUID'
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module SketchupRequirements
6
+ # SketchUp Entity objects (`Face`, `Edge`, `Group` etc) should not be
7
+ # initialized using the `new` constructor. These objects are managed by
8
+ # SketchUp. Instead use the `Sketchup::Entities#add_*` methods to create
9
+ # them.
10
+ class InitializeEntity < SketchUp::Cop
11
+
12
+ ENTITY_CLASSES = %i[
13
+ ComponentDefinition
14
+ ComponentInstance
15
+ ConstructionLine
16
+ ConstructionPoint
17
+ Dimension
18
+ DimensionLinear
19
+ DimensionRadial
20
+ Edge
21
+ Face
22
+ Group
23
+ Image
24
+ SectionPlane
25
+ Text
26
+ AttributeDictionaries
27
+ AttributeDictionary
28
+ Axes
29
+ Behavior
30
+ Curve
31
+ DefinitionList
32
+ Drawingelement
33
+ EdgeUse
34
+ Layer
35
+ LayerFolder
36
+ Layers
37
+ LineStyle
38
+ LineStyles
39
+ Loop
40
+ Material
41
+ Materials
42
+ Page
43
+ Pages
44
+ RenderingOptions
45
+ ShadowInfo
46
+ Style
47
+ Styles
48
+ Texture
49
+ Vertex
50
+ ].freeze
51
+
52
+ def_node_matcher :init_entity?, <<-PATTERN
53
+ (send (const (const nil? :Sketchup) #entity? ) :new ... )
54
+ PATTERN
55
+
56
+ MSG_INITIALIZE_ENTITY = 'Entity objects (Face, Edge, Group etc) are ' \
57
+ 'managed SketchUp. Instead of using the ' \
58
+ '`new` constructor, use the ' \
59
+ '`Sketchup::Entities#add_*` methods.'
60
+
61
+ def on_send(node)
62
+ return unless init_entity?(node)
63
+
64
+ add_offense(node, message: MSG_INITIALIZE_ENTITY)
65
+ end
66
+
67
+ private
68
+
69
+ def entity?(sym)
70
+ ENTITY_CLASSES.include?(sym)
71
+ end
72
+
73
+ end
74
+ end
75
+ end
76
+ end
@@ -10,8 +10,8 @@ module RuboCop
10
10
 
11
11
  include SketchUp::NoCommentDisable
12
12
 
13
- MSG = 'Avoid globals in general, but especially these which are known '\
14
- 'to be in use.'
13
+ MSG = 'Avoid globals in general, but especially these which are ' \
14
+ 'known to be in use.'
15
15
 
16
16
  LH_GLOBALS = %i[
17
17
  $dc_strings
@@ -32,7 +32,7 @@ module RuboCop
32
32
  include SketchUp::NoCommentDisable
33
33
  include SketchUp::ExtensionProject
34
34
 
35
- MSG = "Don't load extension files in the root file registering the "\
35
+ MSG = "Don't load extension files in the root file registering the " \
36
36
  'extension.'
37
37
 
38
38
  # Reference: http://rubocop.readthedocs.io/en/latest/node_pattern/
@@ -26,16 +26,17 @@ module RuboCop
26
26
  include SketchUp::NoCommentDisable
27
27
  include RangeHelp
28
28
 
29
- MSG_SKETCHUP_REQUIRE_EXT_NAME = 'Do not hard code file extensions '\
29
+ MSG_SKETCHUP_REQUIRE_EXT_NAME = 'Do not hard code file extensions ' \
30
30
  'with `Sketchup.require`.'
31
31
 
32
- MSG_EXTENSION_NEW_EXT_NAME = 'Do not hard code file extensions '\
32
+ MSG_EXTENSION_NEW_EXT_NAME = 'Do not hard code file extensions ' \
33
33
  'with `SketchupExtension.new`.'
34
34
 
35
- MSG_REQUIRE_FOR_BINARY = 'Use `require` instead of `Sketchup.require` '\
36
- 'to load binary Ruby libraries.'
35
+ MSG_REQUIRE_FOR_BINARY = 'Use `require` instead of ' \
36
+ '`Sketchup.require` to load binary Ruby ' \
37
+ 'libraries.'
37
38
 
38
- MSG_REQUIRE_ENCRYPTED = 'Use `Sketchup.require` when loading Ruby '\
39
+ MSG_REQUIRE_ENCRYPTED = 'Use `Sketchup.require` when loading Ruby ' \
39
40
  'files for encrypted extensions.'
40
41
 
41
42
  def_node_matcher :ruby_require, <<-PATTERN
@@ -88,8 +89,8 @@ module RuboCop
88
89
  private
89
90
 
90
91
  def binary_require?(filename)
91
- return unless extension_binaries?
92
- return if extension_binaries.empty?
92
+ return false unless extension_binaries?
93
+ return false if extension_binaries.empty?
93
94
 
94
95
  extension_binaries.include?(filename)
95
96
  end
@@ -86,8 +86,8 @@ module RuboCop
86
86
  end
87
87
 
88
88
  def report(node, feature_name, feature_version, feature_type)
89
- message = "The #{feature_type} `#{feature_name}` was added in "\
90
- "#{feature_version} which is incompatible with target "\
89
+ message = "The #{feature_type} `#{feature_name}` was added in " \
90
+ "#{feature_version} which is incompatible with target " \
91
91
  "#{sketchup_target_version}."
92
92
  location = find_node_location(node)
93
93
  add_offense(node, location: location, message: message)
@@ -31,7 +31,7 @@ module RuboCop
31
31
  end
32
32
 
33
33
  path = dc_method[:path]
34
- message = "#{path}##{name} is not part of the official API. "\
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
37
  location: :selector,
@@ -15,7 +15,7 @@ module RuboCop
15
15
  # control.
16
16
  class SketchupFindSupportFile < SketchUp::Cop
17
17
 
18
- MSG = 'Avoid `Sketchup.find_support_file` to find your '\
18
+ MSG = 'Avoid `Sketchup.find_support_file` to find your ' \
19
19
  "extension's files."
20
20
 
21
21
  # http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module SketchupSuggestions
6
+ # Avoid kernel `sleep` as it freezes up SketchUp.
7
+ # Prefer `UI.start_timer` or a callback from the resource you are waiting
8
+ # for.
9
+ class Sleep < SketchUp::Cop
10
+ MSG = '`sleep` freezes up SketchUp. Prefer `UI.start_timer` or a ' \
11
+ 'callback for the resource you are waiting for.'
12
+
13
+ def_node_matcher :sleep?, <<-PATTERN
14
+ (send {(const nil? :Kernel) nil?} :sleep ...)
15
+ PATTERN
16
+
17
+ def on_send(node)
18
+ return unless sleep?(node)
19
+
20
+ add_offense(node, message: MSG)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -28,8 +28,8 @@ module RuboCop
28
28
 
29
29
  include SketchUp::ToolChecker
30
30
 
31
- MSG_MISSING_GET_EXTENTS = 'When drawing to the viewport implement '\
32
- '`getExtents` so drawn geometry is not '\
31
+ MSG_MISSING_GET_EXTENTS = 'When drawing to the viewport implement ' \
32
+ '`getExtents` so drawn geometry is not ' \
33
33
  'clipped.'
34
34
 
35
35
  def on_tool_class(class_node, body_methods)
@@ -30,12 +30,12 @@ module RuboCop
30
30
 
31
31
  include SketchUp::ToolChecker
32
32
 
33
- MSG_MISSING_INVALIDATE_METHOD = 'When drawing to the viewport, make '\
34
- 'sure to `suspend` and `deactivate` '\
33
+ MSG_MISSING_INVALIDATE_METHOD = 'When drawing to the viewport, make ' \
34
+ 'sure to `suspend` and `deactivate` ' \
35
35
  'calls `view.invalidate`.'
36
36
 
37
- MSG_MISSING_INVALIDATE = 'When drawing to the viewport, make sure to '\
38
- 'call `view.invalidate` when the tool '\
37
+ MSG_MISSING_INVALIDATE = 'When drawing to the viewport, make sure to ' \
38
+ 'call `view.invalidate` when the tool ' \
39
39
  'becomes inactive.'
40
40
 
41
41
  def_node_search :view_invalidate?, <<-PATTERN
@@ -23,7 +23,7 @@ module RuboCop
23
23
 
24
24
  include SketchUp::ToolChecker
25
25
 
26
- MSG_MISSING_ENABLE_VCB = 'When accepting user input, make sure to '\
26
+ MSG_MISSING_ENABLE_VCB = 'When accepting user input, make sure to ' \
27
27
  'define `enableVCB?`.'
28
28
 
29
29
  def on_tool_class(class_node, body_methods)
@@ -24,7 +24,7 @@ module RuboCop
24
24
 
25
25
  include RangeHelp
26
26
 
27
- MSG = 'Wrapping `toolbar.restore` in `UI.start_timer` is '\
27
+ MSG = 'Wrapping `toolbar.restore` in `UI.start_timer` is ' \
28
28
  'redundant.'
29
29
 
30
30
  def_node_matcher :toolbar_new?, <<-PATTERN
@@ -41,6 +41,96 @@ module RuboCop
41
41
 
42
42
  FEATURES = [
43
43
 
44
+ {
45
+ version: 'SketchUp 2024.0',
46
+ types: {
47
+ method: [
48
+ 'Sketchup::View#graphics_engine',
49
+ ],
50
+ },
51
+ },
52
+
53
+ {
54
+ version: 'LayOut 2023.1',
55
+ types: {
56
+ method: [
57
+ 'Layout::Document#render_mode_override',
58
+ 'Layout::Document#render_mode_override=',
59
+ 'Layout::PageInfo#image_display_resolution',
60
+ 'Layout::PageInfo#image_display_resolution=',
61
+ 'Layout::PageInfo#image_output_resolution',
62
+ 'Layout::PageInfo#image_output_resolution=',
63
+ 'Layout::SketchUpModel#output_entities',
64
+ ],
65
+ },
66
+ },
67
+
68
+ {
69
+ version: 'SketchUp 2023.1',
70
+ types: {
71
+ method: [
72
+ 'Sketchup::ArcCurve#circular?',
73
+ 'UI.get_clipboard_data',
74
+ 'UI.set_clipboard_data',
75
+ ],
76
+ },
77
+ },
78
+
79
+ {
80
+ version: 'LayOut 2023.0',
81
+ types: {
82
+ class: [
83
+ 'Layout::ReferenceEntity',
84
+ ],
85
+ method: [
86
+ 'Layout::AutoTextDefinition#sequence_type',
87
+ 'Layout::AutoTextDefinition#sequence_type=',
88
+ 'Layout::ReferenceEntity#clip_mask',
89
+ 'Layout::ReferenceEntity#clip_mask=',
90
+ 'Layout::ReferenceEntity#entities',
91
+ ],
92
+ },
93
+ },
94
+
95
+ {
96
+ version: 'SketchUp 2023.0',
97
+ types: {
98
+ class: [
99
+ 'Sketchup::Overlay',
100
+ 'Sketchup::OverlaysManager',
101
+ ],
102
+ method: [
103
+ 'Sketchup.resize_viewport',
104
+ 'Sketchup::ComponentDefinition#thumbnail_camera',
105
+ 'Sketchup::ComponentDefinition#thumbnail_camera=',
106
+ 'Sketchup::Model#overlays',
107
+ 'Sketchup::Overlay#description',
108
+ 'Sketchup::Overlay#description=',
109
+ 'Sketchup::Overlay#draw',
110
+ 'Sketchup::Overlay#enabled=',
111
+ 'Sketchup::Overlay#enabled?',
112
+ 'Sketchup::Overlay#getExtents',
113
+ 'Sketchup::Overlay#initialize',
114
+ 'Sketchup::Overlay#name',
115
+ 'Sketchup::Overlay#onMouseEnter',
116
+ 'Sketchup::Overlay#onMouseLeave',
117
+ 'Sketchup::Overlay#onMouseMove',
118
+ 'Sketchup::Overlay#overlay_id',
119
+ 'Sketchup::Overlay#source',
120
+ 'Sketchup::Overlay#start',
121
+ 'Sketchup::Overlay#stop',
122
+ 'Sketchup::Overlay#valid?',
123
+ 'Sketchup::OverlaysManager#[]',
124
+ 'Sketchup::OverlaysManager#add',
125
+ 'Sketchup::OverlaysManager#at',
126
+ 'Sketchup::OverlaysManager#each',
127
+ 'Sketchup::OverlaysManager#length',
128
+ 'Sketchup::OverlaysManager#remove',
129
+ 'Sketchup::OverlaysManager#size',
130
+ ],
131
+ },
132
+ },
133
+
44
134
  {
45
135
  version: 'LayOut 2022.0',
46
136
  types: {
@@ -1302,6 +1392,7 @@ module RuboCop
1302
1392
  fov_is_height?
1303
1393
  georeferenced?
1304
1394
  get_classification_value
1395
+ get_clipboard_data
1305
1396
  get_drawingelement_visibility
1306
1397
  get_glued_instances
1307
1398
  get_texture_projection
@@ -1364,8 +1455,10 @@ module RuboCop
1364
1455
  same_direction?
1365
1456
  scale_2d
1366
1457
  screen_scale_factor
1458
+ sequence_type
1367
1459
  set_can_close
1368
1460
  set_classification_value
1461
+ set_clipboard_data
1369
1462
  set_download_progress_callback
1370
1463
  set_drawingelement_visibility
1371
1464
  set_full_security
@@ -1383,6 +1476,7 @@ module RuboCop
1383
1476
  status_bar_text
1384
1477
  style_modified?
1385
1478
  text_bounds
1479
+ thumbnail_camera
1386
1480
  unit_vector?
1387
1481
  unload_schema
1388
1482
  upper_left
@@ -62,7 +62,7 @@ module RuboCop
62
62
  context = ERBContext.new(categories, files, summary)
63
63
 
64
64
  template = File.read(TEMPLATE_PATH, encoding: Encoding::UTF_8)
65
- erb = ERB.new(template, nil, '-')
65
+ erb = ERB.new(template, trim_mode: '-')
66
66
  html = erb.result(context.binding)
67
67
 
68
68
  output.write html
@@ -242,7 +242,7 @@ module RuboCop
242
242
 
243
243
  def source_after_highlight(offense)
244
244
  source_line = offense.location.source_line
245
- escape(source_line[offense.highlighted_area.end_pos..-1])
245
+ escape(source_line[offense.highlighted_area.end_pos..])
246
246
  end
247
247
 
248
248
  def possible_ellipses(location)
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubocop'
4
+
5
+ module RuboCop
6
+ module SketchUp
7
+ class Generator < RuboCop::Cop::Generator
8
+ def source_path
9
+ department = snake_case(badge.department.to_s).gsub(/^sketchup_/, '')
10
+ File.join(
11
+ 'lib',
12
+ 'rubocop',
13
+ 'sketchup', # We have our cops nested one extra level.
14
+ 'cop',
15
+ department,
16
+ "#{snake_case(badge.cop_name.to_s)}.rb"
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
@@ -67,6 +67,9 @@ module RuboCop
67
67
  #
68
68
  # The second item in the array is maintenance annotation
69
69
  VALID_VERSIONS = [
70
+ [2024.0, 0],
71
+ [2023.1, 0],
72
+ [2023.0, 0],
70
73
  [2022.0, 0],
71
74
  [2021.1, 0],
72
75
  [2021.0, 0],
@@ -13,11 +13,9 @@ module RuboCop
13
13
 
14
14
  private
15
15
 
16
- # rubocop:disable Lint/UnusedMethodArgument
17
16
  def on_tool_class(class_node, body, body_methods)
18
17
  raise NotImplementedError, 'Implement this method'
19
18
  end
20
- # rubocop:enable Lint/UnusedMethodArgument
21
19
 
22
20
  def body_methods(body)
23
21
  return [body] if body.def_type?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module SketchUp
5
- VERSION = '1.3.0'
5
+ VERSION = '1.5.0'
6
6
  end
7
7
  end
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
 
14
14
  spec.version = RuboCop::SketchUp::VERSION
15
15
  spec.platform = Gem::Platform::RUBY
16
- spec.required_ruby_version = '>= 2.5.0'
16
+ spec.required_ruby_version = '>= 2.6.0'
17
17
 
18
18
  spec.require_paths = ['lib']
19
19
  spec.files = Dir[
@@ -25,5 +25,4 @@ Gem::Specification.new do |spec|
25
25
  ]
26
26
 
27
27
  spec.add_dependency 'rubocop', '>= 0.82', '< 2.0'
28
- spec.add_development_dependency 'bundler', '>= 1.13', '< 3.0'
29
28
  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: 1.3.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trimble Inc, SketchUp Team
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-07 00:00:00.000000000 Z
11
+ date: 2024-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -30,28 +30,8 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.0'
33
- - !ruby/object:Gem::Dependency
34
- name: bundler
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '1.13'
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '3.0'
43
- type: :development
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '1.13'
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '3.0'
53
33
  description: RuboCop rules for SketchUp extensions.
54
- email:
34
+ email:
55
35
  executables: []
56
36
  extensions: []
57
37
  extra_rdoc_files: []
@@ -79,6 +59,7 @@ files:
79
59
  - lib/rubocop/sketchup/cop/performance/type_check.rb
80
60
  - lib/rubocop/sketchup/cop/performance/typename.rb
81
61
  - lib/rubocop/sketchup/cop/requirements/api_namespace.rb
62
+ - lib/rubocop/sketchup/cop/requirements/debug_mode.rb
82
63
  - lib/rubocop/sketchup/cop/requirements/exit.rb
83
64
  - lib/rubocop/sketchup/cop/requirements/extension_namespace.rb
84
65
  - lib/rubocop/sketchup/cop/requirements/file_structure.rb
@@ -88,6 +69,7 @@ files:
88
69
  - lib/rubocop/sketchup/cop/requirements/global_include.rb
89
70
  - lib/rubocop/sketchup/cop/requirements/global_methods.rb
90
71
  - lib/rubocop/sketchup/cop/requirements/global_variables.rb
72
+ - lib/rubocop/sketchup/cop/requirements/initialize_entity.rb
91
73
  - lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb
92
74
  - lib/rubocop/sketchup/cop/requirements/load_path.rb
93
75
  - lib/rubocop/sketchup/cop/requirements/minimal_registration.rb
@@ -106,6 +88,7 @@ files:
106
88
  - lib/rubocop/sketchup/cop/suggestions/monkey_patched_api.rb
107
89
  - lib/rubocop/sketchup/cop/suggestions/operation_name.rb
108
90
  - lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb
91
+ - lib/rubocop/sketchup/cop/suggestions/sleep.rb
109
92
  - lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb
110
93
  - lib/rubocop/sketchup/cop/suggestions/tool_invalidate.rb
111
94
  - lib/rubocop/sketchup/cop/suggestions/tool_user_input.rb
@@ -115,6 +98,7 @@ files:
115
98
  - lib/rubocop/sketchup/extension_project.rb
116
99
  - lib/rubocop/sketchup/features.rb
117
100
  - lib/rubocop/sketchup/formatter/extension_review.rb
101
+ - lib/rubocop/sketchup/generator.rb
118
102
  - lib/rubocop/sketchup/inject.rb
119
103
  - lib/rubocop/sketchup/namespace.rb
120
104
  - lib/rubocop/sketchup/namespace_checker.rb
@@ -129,7 +113,7 @@ homepage: https://github.com/sketchup/rubocop-sketchup
129
113
  licenses:
130
114
  - MIT
131
115
  metadata: {}
132
- post_install_message:
116
+ post_install_message:
133
117
  rdoc_options: []
134
118
  require_paths:
135
119
  - lib
@@ -137,15 +121,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
121
  requirements:
138
122
  - - ">="
139
123
  - !ruby/object:Gem::Version
140
- version: 2.5.0
124
+ version: 2.6.0
141
125
  required_rubygems_version: !ruby/object:Gem::Requirement
142
126
  requirements:
143
127
  - - ">="
144
128
  - !ruby/object:Gem::Version
145
129
  version: '0'
146
130
  requirements: []
147
- rubygems_version: 3.2.15
148
- signing_key:
131
+ rubygems_version: 3.1.6
132
+ signing_key:
149
133
  specification_version: 4
150
134
  summary: RuboCop rules for SketchUp extensions.
151
135
  test_files: []