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.
- checksums.yaml +4 -4
- data/Gemfile +19 -19
- data/assets/output.html.erb +301 -301
- data/config/default.yml +355 -355
- data/lib/rubocop/sketchup/config.rb +63 -63
- 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 +117 -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 +103 -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/cop.rb +111 -111
- 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 +259 -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_version.rb +87 -87
- data/lib/rubocop/sketchup/tool_checker.rb +43 -43
- data/lib/rubocop/sketchup/version.rb +5 -5
- data/lib/rubocop/sketchup.rb +12 -12
- data/lib/rubocop-sketchup.rb +48 -48
- data/rubocop-sketchup.gemspec +27 -27
- metadata +4 -4
@@ -1,63 +1,63 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module SketchUp
|
5
|
-
module Config
|
6
|
-
|
7
|
-
DEFAULT_CONFIGURATION =
|
8
|
-
SketchUp::CONFIG.fetch('AllCops').fetch('SketchUp')
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def all_cops_config
|
13
|
-
config.for_all_cops
|
14
|
-
end
|
15
|
-
|
16
|
-
def sketchup_cops_config
|
17
|
-
config.for_all_cops.fetch('SketchUp', DEFAULT_CONFIGURATION)
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
def sketchup_config_key?(key)
|
22
|
-
return unless all_cops_config.key?('SketchUp')
|
23
|
-
|
24
|
-
all_cops_config.fetch('SketchUp').key?(key)
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def sketchup_target_version?
|
29
|
-
sketchup_config_key?('TargetSketchUpVersion')
|
30
|
-
end
|
31
|
-
|
32
|
-
def sketchup_target_version
|
33
|
-
version = sketchup_cops_config.fetch('TargetSketchUpVersion')
|
34
|
-
version ? SketchUpVersion.new(version) : nil
|
35
|
-
end
|
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
|
-
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module SketchUp
|
5
|
+
module Config
|
6
|
+
|
7
|
+
DEFAULT_CONFIGURATION =
|
8
|
+
SketchUp::CONFIG.fetch('AllCops').fetch('SketchUp')
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def all_cops_config
|
13
|
+
config.for_all_cops
|
14
|
+
end
|
15
|
+
|
16
|
+
def sketchup_cops_config
|
17
|
+
config.for_all_cops.fetch('SketchUp', DEFAULT_CONFIGURATION)
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
def sketchup_config_key?(key)
|
22
|
+
return unless all_cops_config.key?('SketchUp')
|
23
|
+
|
24
|
+
all_cops_config.fetch('SketchUp').key?(key)
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def sketchup_target_version?
|
29
|
+
sketchup_config_key?('TargetSketchUpVersion')
|
30
|
+
end
|
31
|
+
|
32
|
+
def sketchup_target_version
|
33
|
+
version = sketchup_cops_config.fetch('TargetSketchUpVersion')
|
34
|
+
version ? SketchUpVersion.new(version) : nil
|
35
|
+
end
|
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
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupDeprecations
|
6
|
-
# Avoid adding separators to top level menus. If you require grouping use
|
7
|
-
# a sub-menu instead.
|
8
|
-
class AddSeparatorToMenu < SketchUp::Cop
|
9
|
-
|
10
|
-
MSG = 'Method is deprecated.'.freeze
|
11
|
-
|
12
|
-
def_node_matcher :add_separator_to_menu?, <<-PATTERN
|
13
|
-
(send nil? :add_separator_to_menu _)
|
14
|
-
PATTERN
|
15
|
-
|
16
|
-
def on_send(node)
|
17
|
-
return unless add_separator_to_menu?(node)
|
18
|
-
|
19
|
-
add_offense(node, location: :selector)
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupDeprecations
|
6
|
+
# Avoid adding separators to top level menus. If you require grouping use
|
7
|
+
# a sub-menu instead.
|
8
|
+
class AddSeparatorToMenu < SketchUp::Cop
|
9
|
+
|
10
|
+
MSG = 'Method is deprecated.'.freeze
|
11
|
+
|
12
|
+
def_node_matcher :add_separator_to_menu?, <<-PATTERN
|
13
|
+
(send nil? :add_separator_to_menu _)
|
14
|
+
PATTERN
|
15
|
+
|
16
|
+
def on_send(node)
|
17
|
+
return unless add_separator_to_menu?(node)
|
18
|
+
|
19
|
+
add_offense(node, location: :selector)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupDeprecations
|
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.
|
15
|
-
class OperationNextTransparent < SketchUp::Cop
|
16
|
-
MSG = 'Third argument is deprecated.'.freeze
|
17
|
-
|
18
|
-
def on_send(node)
|
19
|
-
_, method_name, *args = *node
|
20
|
-
return unless method_name == :start_operation
|
21
|
-
return if args.size < 3
|
22
|
-
|
23
|
-
argument = args[2]
|
24
|
-
next_transparent = (argument.type == :true)
|
25
|
-
add_offense(argument, location: :expression) if next_transparent
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupDeprecations
|
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.
|
15
|
+
class OperationNextTransparent < SketchUp::Cop
|
16
|
+
MSG = 'Third argument is deprecated.'.freeze
|
17
|
+
|
18
|
+
def on_send(node)
|
19
|
+
_, method_name, *args = *node
|
20
|
+
return unless method_name == :start_operation
|
21
|
+
return if args.size < 3
|
22
|
+
|
23
|
+
argument = args[2]
|
24
|
+
next_transparent = (argument.type == :true)
|
25
|
+
add_offense(argument, location: :expression) if next_transparent
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
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.
|
9
|
-
class RequireAll < SketchUp::Cop
|
10
|
-
|
11
|
-
MSG = 'Method is deprecated because it adds the given path '\
|
12
|
-
'to $LOAD_PATH.'.freeze
|
13
|
-
|
14
|
-
def_node_matcher :require_all?, <<-PATTERN
|
15
|
-
(send nil? :require_all _)
|
16
|
-
PATTERN
|
17
|
-
|
18
|
-
def on_send(node)
|
19
|
-
return unless require_all?(node)
|
20
|
-
|
21
|
-
add_offense(node, location: :selector)
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
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.
|
9
|
+
class RequireAll < SketchUp::Cop
|
10
|
+
|
11
|
+
MSG = 'Method is deprecated because it adds the given path '\
|
12
|
+
'to $LOAD_PATH.'.freeze
|
13
|
+
|
14
|
+
def_node_matcher :require_all?, <<-PATTERN
|
15
|
+
(send nil? :require_all _)
|
16
|
+
PATTERN
|
17
|
+
|
18
|
+
def on_send(node)
|
19
|
+
return unless require_all?(node)
|
20
|
+
|
21
|
+
add_offense(node, location: :selector)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
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.
|
9
|
-
class SetTextureProjection < SketchUp::Cop
|
10
|
-
|
11
|
-
MSG = 'Method is deprecated. It can create invalid UV mapping.'.freeze
|
12
|
-
|
13
|
-
def_node_matcher :set_texture_projection?, <<-PATTERN
|
14
|
-
(send _ :set_texture_projection ...)
|
15
|
-
PATTERN
|
16
|
-
|
17
|
-
def on_send(node)
|
18
|
-
return unless set_texture_projection?(node)
|
19
|
-
|
20
|
-
add_offense(node, location: :selector)
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
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.
|
9
|
+
class SetTextureProjection < SketchUp::Cop
|
10
|
+
|
11
|
+
MSG = 'Method is deprecated. It can create invalid UV mapping.'.freeze
|
12
|
+
|
13
|
+
def_node_matcher :set_texture_projection?, <<-PATTERN
|
14
|
+
(send _ :set_texture_projection ...)
|
15
|
+
PATTERN
|
16
|
+
|
17
|
+
def on_send(node)
|
18
|
+
return unless set_texture_projection?(node)
|
19
|
+
|
20
|
+
add_offense(node, location: :selector)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupDeprecations
|
6
|
-
# Method is deprecated. Use `SKETCHUP_CONSOLE.show` instead.
|
7
|
-
class ShowRubyPanel < SketchUp::Cop
|
8
|
-
|
9
|
-
MSG = 'Method is deprecated. Use `SKETCHUP_CONSOLE.show` '\
|
10
|
-
'instead.'.freeze
|
11
|
-
|
12
|
-
def_node_matcher :show_ruby_panel?, <<-PATTERN
|
13
|
-
(send nil? :show_ruby_panel)
|
14
|
-
PATTERN
|
15
|
-
|
16
|
-
def on_send(node)
|
17
|
-
return unless show_ruby_panel?(node)
|
18
|
-
|
19
|
-
add_offense(node, location: :expression)
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupDeprecations
|
6
|
+
# Method is deprecated. Use `SKETCHUP_CONSOLE.show` instead.
|
7
|
+
class ShowRubyPanel < SketchUp::Cop
|
8
|
+
|
9
|
+
MSG = 'Method is deprecated. Use `SKETCHUP_CONSOLE.show` '\
|
10
|
+
'instead.'.freeze
|
11
|
+
|
12
|
+
def_node_matcher :show_ruby_panel?, <<-PATTERN
|
13
|
+
(send nil? :show_ruby_panel)
|
14
|
+
PATTERN
|
15
|
+
|
16
|
+
def on_send(node)
|
17
|
+
return unless show_ruby_panel?(node)
|
18
|
+
|
19
|
+
add_offense(node, location: :expression)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
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.
|
13
|
-
class SketchupSet < SketchUp::Cop
|
14
|
-
|
15
|
-
MSG = 'Class is deprecated.'.freeze
|
16
|
-
|
17
|
-
def_node_matcher :sketchup_set?, <<-PATTERN
|
18
|
-
(const (const nil? :Sketchup) :Set)
|
19
|
-
PATTERN
|
20
|
-
|
21
|
-
def on_const(node)
|
22
|
-
return unless sketchup_set?(node)
|
23
|
-
|
24
|
-
add_offense(node, location: :expression)
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
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.
|
13
|
+
class SketchupSet < SketchUp::Cop
|
14
|
+
|
15
|
+
MSG = 'Class is deprecated.'.freeze
|
16
|
+
|
17
|
+
def_node_matcher :sketchup_set?, <<-PATTERN
|
18
|
+
(const (const nil? :Sketchup) :Set)
|
19
|
+
PATTERN
|
20
|
+
|
21
|
+
def on_const(node)
|
22
|
+
return unless sketchup_set?(node)
|
23
|
+
|
24
|
+
add_offense(node, location: :expression)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,41 +1,41 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupPerformance
|
6
|
-
# There are performance issue with the OpenSSL library that Ruby ship. In
|
7
|
-
# a clean SU session, default model there is a small delay observed in the
|
8
|
-
# Windows version of SU.
|
9
|
-
#
|
10
|
-
# But with a larger model loaded, or session that have had larger files
|
11
|
-
# loaded the lag will be minutes.
|
12
|
-
#
|
13
|
-
# `SecureRandom` is also affected by this, as it uses OpenSSL to seed.
|
14
|
-
#
|
15
|
-
# It also affects `Net::HTTP` if making HTTPS connections.
|
16
|
-
class OpenSSL < SketchUp::Cop
|
17
|
-
|
18
|
-
MSG = 'Avoid use of OpenSSL within SketchUp due to severe performance '\
|
19
|
-
'issues.'.freeze
|
20
|
-
|
21
|
-
# http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
22
|
-
# https://rubocop.readthedocs.io/en/latest/node_pattern/
|
23
|
-
def_node_matcher :require, <<-PATTERN
|
24
|
-
(send nil? :require
|
25
|
-
(str $_)
|
26
|
-
)
|
27
|
-
PATTERN
|
28
|
-
|
29
|
-
OPEN_SSL_USAGE = %w[openssl securerandom net/https net/http].freeze
|
30
|
-
|
31
|
-
def on_send(node)
|
32
|
-
filename = require(node)
|
33
|
-
return if filename.nil?
|
34
|
-
return unless OPEN_SSL_USAGE.include?(filename.downcase)
|
35
|
-
|
36
|
-
add_offense(node, location: :expression)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupPerformance
|
6
|
+
# There are performance issue with the OpenSSL library that Ruby ship. In
|
7
|
+
# a clean SU session, default model there is a small delay observed in the
|
8
|
+
# Windows version of SU.
|
9
|
+
#
|
10
|
+
# But with a larger model loaded, or session that have had larger files
|
11
|
+
# loaded the lag will be minutes.
|
12
|
+
#
|
13
|
+
# `SecureRandom` is also affected by this, as it uses OpenSSL to seed.
|
14
|
+
#
|
15
|
+
# It also affects `Net::HTTP` if making HTTPS connections.
|
16
|
+
class OpenSSL < SketchUp::Cop
|
17
|
+
|
18
|
+
MSG = 'Avoid use of OpenSSL within SketchUp due to severe performance '\
|
19
|
+
'issues.'.freeze
|
20
|
+
|
21
|
+
# http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
22
|
+
# https://rubocop.readthedocs.io/en/latest/node_pattern/
|
23
|
+
def_node_matcher :require, <<-PATTERN
|
24
|
+
(send nil? :require
|
25
|
+
(str $_)
|
26
|
+
)
|
27
|
+
PATTERN
|
28
|
+
|
29
|
+
OPEN_SSL_USAGE = %w[openssl securerandom net/https net/http].freeze
|
30
|
+
|
31
|
+
def on_send(node)
|
32
|
+
filename = require(node)
|
33
|
+
return if filename.nil?
|
34
|
+
return unless OPEN_SSL_USAGE.include?(filename.downcase)
|
35
|
+
|
36
|
+
add_offense(node, location: :expression)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,33 +1,33 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module SketchupPerformance
|
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
|
13
|
-
class OperationDisableUI < SketchUp::Cop
|
14
|
-
MSG = 'Operations should disable the UI for performance gain.'.freeze
|
15
|
-
|
16
|
-
def on_send(node)
|
17
|
-
_, method_name, *args = *node
|
18
|
-
return unless method_name == :start_operation
|
19
|
-
|
20
|
-
if args.size < 2
|
21
|
-
add_offense(node, location: :selector)
|
22
|
-
return
|
23
|
-
end
|
24
|
-
argument = args[1]
|
25
|
-
disable_ui = argument.truthy_literal?
|
26
|
-
return if disable_ui
|
27
|
-
|
28
|
-
add_offense(argument, location: :expression)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupPerformance
|
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
|
13
|
+
class OperationDisableUI < SketchUp::Cop
|
14
|
+
MSG = 'Operations should disable the UI for performance gain.'.freeze
|
15
|
+
|
16
|
+
def on_send(node)
|
17
|
+
_, method_name, *args = *node
|
18
|
+
return unless method_name == :start_operation
|
19
|
+
|
20
|
+
if args.size < 2
|
21
|
+
add_offense(node, location: :selector)
|
22
|
+
return
|
23
|
+
end
|
24
|
+
argument = args[1]
|
25
|
+
disable_ui = argument.truthy_literal?
|
26
|
+
return if disable_ui
|
27
|
+
|
28
|
+
add_offense(argument, location: :expression)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|