rubocop-sketchup 1.0.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f127a24e47b19d2fdfcc67dbd345a4c2a7ad60425ec65b6d966f28244fcb081
4
- data.tar.gz: cd916a3de6ebb7e3b51d0a57c3176be7898bd2b4cea2cf3cbfecf508fe1d94aa
3
+ metadata.gz: e9935671119993e41eef012a5f69fca2709a59d7db06d28c2e89ff9ea5721aa7
4
+ data.tar.gz: 05cba02d5fa27e8eab8b32cae46d586c68d5fec8922b959febf89ebd36660ced
5
5
  SHA512:
6
- metadata.gz: f805d4810dd4711b760763ed4d83b9185a13b7c8c9e14cf89472fff1acbb9c1246defcdbdfc593350b5b3e4213b4523decc060639b46b12c6a73eee26d4a3d68
7
- data.tar.gz: e5d41dd9aa462d62be7804076803f9969e7dbc5b100169c339654e88d9b518e4a06d72859450ea645aba2ea8b7b981a9c76a17ee2eb449b220b8e627b1778194
6
+ metadata.gz: 06e197b228db557e7d1b0ab9eeec6550e9a70a8e64fa4079f6f4e093249f0057390f9ce6f4270d15e1be956e36b684ff66f5e926a55d0a2b862e33d113a8a3c2
7
+ data.tar.gz: 54242ae1e4bb983394e9976f02893d98794ae46971755751bdbcea1b4ecdfd9e1c6e3c9e4dde6cd995e7977b788d8ec5fa3dab693723bdd84f30dd3717b8a590
data/Gemfile CHANGED
@@ -9,6 +9,8 @@ group :test do
9
9
  gem 'rake', '~> 12.0', require: false
10
10
  gem 'rspec', '~> 3.7', require: false
11
11
  gem 'rubocop-performance', '~> 1.11.0', require: false
12
+ gem 'rubocop-rake', '~> 0.6.0', require: false
13
+ gem 'rubocop-rspec', require: false
12
14
  gem 'simplecov', '~> 0.10', require: false
13
15
  end
14
16
 
@@ -13,18 +13,19 @@ module RuboCop
13
13
 
14
14
  include SketchUp::NoCommentDisable
15
15
 
16
- MSG = '`exit` 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/
20
20
  def_node_matcher :exit?, <<-PATTERN
21
- (send {(const nil? :Kernel) nil?} {:exit :exit!} ...)
21
+ (send {(const nil? :Kernel) nil?} {:abort :exit :exit!} ...)
22
22
  PATTERN
23
23
 
24
24
  def on_send(node)
25
25
  return unless exit?(node)
26
26
 
27
- add_offense(node, location: :selector)
27
+ message = format(MSG, node.method_name)
28
+ add_offense(node, location: :selector, message: message)
28
29
  end
29
30
  end
30
31
  end
@@ -41,6 +41,51 @@ module RuboCop
41
41
 
42
42
  FEATURES = [
43
43
 
44
+ {
45
+ version: 'LayOut 2022.0',
46
+ types: {
47
+ method: [
48
+ 'Layout::AutoTextDefinition#end_page',
49
+ 'Layout::AutoTextDefinition#end_page=',
50
+ 'Layout::AutoTextDefinition#increment',
51
+ 'Layout::AutoTextDefinition#increment=',
52
+ 'Layout::AutoTextDefinition#number_style',
53
+ 'Layout::AutoTextDefinition#number_style=',
54
+ 'Layout::AutoTextDefinition#renumber',
55
+ 'Layout::AutoTextDefinition#sequence_format',
56
+ 'Layout::AutoTextDefinition#sequence_format=',
57
+ 'Layout::AutoTextDefinition#start_page',
58
+ 'Layout::AutoTextDefinition#start_page=',
59
+ ],
60
+ },
61
+ },
62
+
63
+ {
64
+ version: 'SketchUp 2022.0',
65
+ types: {
66
+ class: [
67
+ 'Sketchup::EntitiesBuilder',
68
+ ],
69
+ method: [
70
+ 'Sketchup::AppObserver#onExtensionsLoaded',
71
+ 'Sketchup::ComponentDefinition#save_copy',
72
+ 'Sketchup::Entities#build',
73
+ 'Sketchup::EntitiesBuilder#add_edge',
74
+ 'Sketchup::EntitiesBuilder#add_edges',
75
+ 'Sketchup::EntitiesBuilder#add_face',
76
+ 'Sketchup::EntitiesBuilder#add_line',
77
+ 'Sketchup::EntitiesBuilder#entities',
78
+ 'Sketchup::EntitiesBuilder#valid?',
79
+ 'Sketchup::EntitiesBuilder#vertex_at',
80
+ 'Sketchup::Face#clear_texture_position',
81
+ 'UI::Command#extension',
82
+ 'UI::Command#extension=',
83
+ 'UI::Command#get_validation_proc',
84
+ 'UI::Command#proc',
85
+ ],
86
+ },
87
+ },
88
+
44
89
  {
45
90
  version: 'SketchUp 2021.1',
46
91
  types: {
@@ -1231,6 +1276,7 @@ module RuboCop
1231
1276
  camera_modified?
1232
1277
  center_2d
1233
1278
  classifications
1279
+ clear_texture_position
1234
1280
  clip_to_margins?
1235
1281
  clip_to_margins=
1236
1282
  colorize_deltas
@@ -1259,6 +1305,7 @@ module RuboCop
1259
1305
  get_drawingelement_visibility
1260
1306
  get_glued_instances
1261
1307
  get_texture_projection
1308
+ get_validation_proc
1262
1309
  has_aligned_text?
1263
1310
  has_aligned_text=
1264
1311
  icon_name
@@ -1340,6 +1387,7 @@ module RuboCop
1340
1387
  unload_schema
1341
1388
  upper_left
1342
1389
  upper_right
1390
+ vertex_at
1343
1391
  visible_on_new_pages?
1344
1392
  visible_on_new_pages=
1345
1393
  winding
@@ -1352,6 +1400,7 @@ module RuboCop
1352
1400
  onAfterComponentSaveAs
1353
1401
  onBeforeComponentSaveAs
1354
1402
  onElementModified
1403
+ onExtensionsLoaded
1355
1404
  onExplode
1356
1405
  onLayerChanged
1357
1406
  onLayerFolderAdded
@@ -4,6 +4,35 @@ module RuboCop
4
4
  module SketchUp
5
5
  module NamespaceChecker
6
6
 
7
+ extend NodePattern::Macros
8
+
9
+ # Example:
10
+ # Array.include(Example)
11
+ def_node_matcher :klass_include, <<-PATTERN
12
+ (send
13
+ (const nil? $_) { :include | :extend } _)
14
+ PATTERN
15
+
16
+ # Example:
17
+ # class Array
18
+ # include Example
19
+ # end
20
+ def_node_matcher :klass_scope_include, <<-PATTERN
21
+ (
22
+ {
23
+ class (const nil? $_) nil? |
24
+ module (const nil? $_)
25
+ }
26
+ (send nil? { :include | :extend } _))
27
+ PATTERN
28
+
29
+ # Example:
30
+ # include Example
31
+ def_node_matcher :include_call?, <<-PATTERN
32
+ (send nil? { :include | :extend } _)
33
+ PATTERN
34
+
35
+
7
36
  def on_class(node)
8
37
  check_namespace(node)
9
38
  end
@@ -22,12 +51,40 @@ module RuboCop
22
51
  check_namespace(node)
23
52
  end
24
53
 
54
+ def on_send(node)
55
+ klass = klass_include(node) || klass_scope_include(node.parent)
56
+
57
+ if klass
58
+ namespace = SketchUp::Namespace.new(klass.to_s)
59
+ return unless namespaces.include?(namespace.first)
60
+ else
61
+ # If klass is `nil` we either don't have a `include` call or we're in
62
+ # global namespace.
63
+ return unless top_level_include?(node)
64
+ end
65
+
66
+ add_offense(node, location: :selector, severity: :error)
67
+ end
68
+
25
69
  def check_namespace(node)
26
70
  return unless in_namespace?(node)
27
71
 
28
72
  add_offense(node, location: :name, severity: :error)
29
73
  end
30
74
 
75
+ def top_level?(node)
76
+ # parent_module_name might return nil if for instance a method is
77
+ # defined within a block. (Apparently that is possible...)
78
+ return false if node.parent_module_name.nil?
79
+
80
+ namespace = SketchUp::Namespace.new(node.parent_module_name)
81
+ namespace.top_level?
82
+ end
83
+
84
+ def top_level_include?(node)
85
+ include_call?(node) && top_level?(node)
86
+ end
87
+
31
88
  def in_namespace?(node)
32
89
  # parent_module_name might return nil if for instance a method is
33
90
  # defined within a block. (Apparently that is possible...)
@@ -67,6 +67,7 @@ module RuboCop
67
67
  #
68
68
  # The second item in the array is maintenance annotation
69
69
  VALID_VERSIONS = [
70
+ [2022.0, 0],
70
71
  [2021.1, 0],
71
72
  [2021.0, 0],
72
73
  [2020.1, 0],
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module SketchUp
5
- VERSION = '1.0.0'
5
+ VERSION = '1.3.0'
6
6
  end
7
7
  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.0.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trimble Inc, SketchUp Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2022-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  requirements: []
147
- rubygems_version: 3.0.3
147
+ rubygems_version: 3.2.15
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: RuboCop rules for SketchUp extensions.