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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +20 -19
  3. data/assets/output.html.erb +301 -301
  4. data/config/default.yml +379 -355
  5. data/lib/rubocop-sketchup.rb +49 -48
  6. data/lib/rubocop/sketchup.rb +12 -12
  7. data/lib/rubocop/sketchup/config.rb +63 -63
  8. data/lib/rubocop/sketchup/cop.rb +111 -111
  9. data/lib/rubocop/sketchup/cop/bugs/material_name.rb +108 -0
  10. data/lib/rubocop/sketchup/cop/bugs/render_mode.rb +72 -0
  11. data/lib/rubocop/sketchup/cop/bugs/uniform_scaling.rb +36 -0
  12. data/lib/rubocop/sketchup/cop/deprecations/add_separator_to_menu.rb +25 -25
  13. data/lib/rubocop/sketchup/cop/deprecations/operation_next_transparent.rb +30 -30
  14. data/lib/rubocop/sketchup/cop/deprecations/require_all.rb +27 -27
  15. data/lib/rubocop/sketchup/cop/deprecations/set_texture_projection.rb +26 -26
  16. data/lib/rubocop/sketchup/cop/deprecations/show_ruby_panel.rb +25 -25
  17. data/lib/rubocop/sketchup/cop/deprecations/sketchup_set.rb +30 -30
  18. data/lib/rubocop/sketchup/cop/performance/openssl.rb +41 -41
  19. data/lib/rubocop/sketchup/cop/performance/operation_disable_ui.rb +33 -33
  20. data/lib/rubocop/sketchup/cop/performance/selection_bulk.rb +79 -79
  21. data/lib/rubocop/sketchup/cop/performance/type_check.rb +63 -63
  22. data/lib/rubocop/sketchup/cop/performance/typename.rb +24 -24
  23. data/lib/rubocop/sketchup/cop/requirements/api_namespace.rb +30 -30
  24. data/lib/rubocop/sketchup/cop/requirements/exit.rb +32 -32
  25. data/lib/rubocop/sketchup/cop/requirements/extension_namespace.rb +108 -108
  26. data/lib/rubocop/sketchup/cop/requirements/file_structure.rb +97 -97
  27. data/lib/rubocop/sketchup/cop/requirements/gem_install.rb +45 -45
  28. data/lib/rubocop/sketchup/cop/requirements/get_extension_license.rb +95 -95
  29. data/lib/rubocop/sketchup/cop/requirements/global_constants.rb +38 -38
  30. data/lib/rubocop/sketchup/cop/requirements/global_include.rb +42 -42
  31. data/lib/rubocop/sketchup/cop/requirements/global_methods.rb +65 -65
  32. data/lib/rubocop/sketchup/cop/requirements/global_variables.rb +95 -95
  33. data/lib/rubocop/sketchup/cop/requirements/language_handler_globals.rb +46 -46
  34. data/lib/rubocop/sketchup/cop/requirements/load_path.rb +83 -83
  35. data/lib/rubocop/sketchup/cop/requirements/minimal_registration.rb +73 -73
  36. data/lib/rubocop/sketchup/cop/requirements/observers_start_operation.rb +161 -161
  37. data/lib/rubocop/sketchup/cop/requirements/register_extension.rb +45 -45
  38. data/lib/rubocop/sketchup/cop/requirements/ruby_core_namespace.rb +291 -291
  39. data/lib/rubocop/sketchup/cop/requirements/ruby_stdlib_namespace.rb +634 -634
  40. data/lib/rubocop/sketchup/cop/requirements/shipped_extensions_namespace.rb +61 -61
  41. data/lib/rubocop/sketchup/cop/requirements/sketchup_extension.rb +119 -119
  42. data/lib/rubocop/sketchup/cop/requirements/sketchup_require.rb +163 -163
  43. data/lib/rubocop/sketchup/cop/suggestions/add_group.rb +49 -49
  44. data/lib/rubocop/sketchup/cop/suggestions/compatibility.rb +121 -117
  45. data/lib/rubocop/sketchup/cop/suggestions/dc_internals.rb +34 -34
  46. data/lib/rubocop/sketchup/cop/suggestions/file_encoding.rb +78 -78
  47. data/lib/rubocop/sketchup/cop/suggestions/model_entities.rb +58 -58
  48. data/lib/rubocop/sketchup/cop/suggestions/monkey_patched_api.rb +45 -45
  49. data/lib/rubocop/sketchup/cop/suggestions/operation_name.rb +137 -103
  50. data/lib/rubocop/sketchup/cop/suggestions/sketchup_find_support_file.rb +39 -39
  51. data/lib/rubocop/sketchup/cop/suggestions/tool_drawing_bounds.rb +44 -44
  52. data/lib/rubocop/sketchup/cop/suggestions/tool_invalidate.rb +66 -66
  53. data/lib/rubocop/sketchup/cop/suggestions/tool_user_input.rb +41 -41
  54. data/lib/rubocop/sketchup/cop/suggestions/toolbar_timer.rb +65 -65
  55. data/lib/rubocop/sketchup/dc_globals.rb +24 -24
  56. data/lib/rubocop/sketchup/dc_methods.rb +130 -130
  57. data/lib/rubocop/sketchup/extension_project.rb +65 -65
  58. data/lib/rubocop/sketchup/features.rb +738 -738
  59. data/lib/rubocop/sketchup/formatter/extension_review.rb +269 -259
  60. data/lib/rubocop/sketchup/inject.rb +19 -19
  61. data/lib/rubocop/sketchup/namespace.rb +47 -47
  62. data/lib/rubocop/sketchup/namespace_checker.rb +46 -46
  63. data/lib/rubocop/sketchup/no_comment_disable.rb +17 -17
  64. data/lib/rubocop/sketchup/range_help.rb +52 -52
  65. data/lib/rubocop/sketchup/sketchup_target_range.rb +75 -0
  66. data/lib/rubocop/sketchup/sketchup_version.rb +117 -87
  67. data/lib/rubocop/sketchup/tool_checker.rb +43 -43
  68. data/lib/rubocop/sketchup/version.rb +5 -5
  69. data/rubocop-sketchup.gemspec +27 -27
  70. metadata +8 -4
@@ -1,48 +1,49 @@
1
- require 'rubocop'
2
- require 'rubocop/sketchup'
3
- require 'rubocop/sketchup/version'
4
- require 'rubocop/sketchup/inject'
5
-
6
- require 'rubocop/sketchup/formatter/extension_review'
7
- require 'rubocop/sketchup/config'
8
- require 'rubocop/sketchup/cop'
9
- require 'rubocop/sketchup/dc_globals'
10
- require 'rubocop/sketchup/dc_methods'
11
- require 'rubocop/sketchup/extension_project'
12
- require 'rubocop/sketchup/features'
13
- require 'rubocop/sketchup/namespace'
14
- require 'rubocop/sketchup/namespace_checker'
15
- require 'rubocop/sketchup/no_comment_disable'
16
- require 'rubocop/sketchup/range_help'
17
- require 'rubocop/sketchup/sketchup_version'
18
- require 'rubocop/sketchup/tool_checker'
19
-
20
- RuboCop::SketchUp::Inject.defaults!
21
-
22
- # Monkey patching the built in formatter list to add a short alias for custom
23
- # formatters. Naughty! Naughty!
24
- class RuboCop::Formatter::FormatterSet
25
- formatters = BUILTIN_FORMATTERS_FOR_KEYS.dup
26
- formatters['extension_review'] =
27
- RuboCop::Formatter::ExtensionReviewFormatter
28
- verbose = $VERBOSE
29
- begin
30
- $VERBOSE = nil
31
- BUILTIN_FORMATTERS_FOR_KEYS = formatters.freeze
32
- ensure
33
- $VERBOSE = verbose
34
- end
35
- end
36
-
37
- # Make it easier to explore available methods on a method.
38
- class Object
39
- def methods!
40
- methods.sort - Object.class.instance_methods
41
- end
42
- end
43
-
44
- # Load all custom cops.
45
- pattern = File.join(__dir__, 'rubocop', 'sketchup', 'cop', '**/*rb')
46
- Dir.glob(pattern) { |file|
47
- require file
48
- }
1
+ require 'rubocop'
2
+ require 'rubocop/sketchup'
3
+ require 'rubocop/sketchup/version'
4
+ require 'rubocop/sketchup/inject'
5
+
6
+ require 'rubocop/sketchup/formatter/extension_review'
7
+ require 'rubocop/sketchup/config'
8
+ require 'rubocop/sketchup/cop'
9
+ require 'rubocop/sketchup/dc_globals'
10
+ require 'rubocop/sketchup/dc_methods'
11
+ require 'rubocop/sketchup/extension_project'
12
+ require 'rubocop/sketchup/features'
13
+ require 'rubocop/sketchup/namespace'
14
+ require 'rubocop/sketchup/namespace_checker'
15
+ require 'rubocop/sketchup/no_comment_disable'
16
+ require 'rubocop/sketchup/range_help'
17
+ require 'rubocop/sketchup/sketchup_target_range'
18
+ require 'rubocop/sketchup/sketchup_version'
19
+ require 'rubocop/sketchup/tool_checker'
20
+
21
+ RuboCop::SketchUp::Inject.defaults!
22
+
23
+ # Monkey patching the built in formatter list to add a short alias for custom
24
+ # formatters. Naughty! Naughty!
25
+ class RuboCop::Formatter::FormatterSet
26
+ formatters = BUILTIN_FORMATTERS_FOR_KEYS.dup
27
+ formatters['extension_review'] =
28
+ RuboCop::Formatter::ExtensionReviewFormatter
29
+ verbose = $VERBOSE
30
+ begin
31
+ $VERBOSE = nil
32
+ BUILTIN_FORMATTERS_FOR_KEYS = formatters.freeze
33
+ ensure
34
+ $VERBOSE = verbose
35
+ end
36
+ end
37
+
38
+ # Make it easier to explore available methods on a method.
39
+ class Object
40
+ def methods!
41
+ methods.sort - Object.class.instance_methods
42
+ end
43
+ end
44
+
45
+ # Load all custom cops.
46
+ pattern = File.join(__dir__, 'rubocop', 'sketchup', 'cop', '**/*rb')
47
+ Dir.glob(pattern) { |file|
48
+ require file
49
+ }
@@ -1,12 +1,12 @@
1
- require 'pathname'
2
-
3
- module RuboCop
4
- # RuboCop SketchUp project namespace
5
- module SketchUp
6
- PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
7
- CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
8
- CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
9
-
10
- private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
11
- end
12
- end
1
+ require 'pathname'
2
+
3
+ module RuboCop
4
+ # RuboCop SketchUp project namespace
5
+ module SketchUp
6
+ PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
7
+ CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
8
+ CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
9
+
10
+ private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
11
+ end
12
+ end
@@ -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,111 +1,111 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module SketchUp
5
-
6
- WorkaroundCop = RuboCop::Cop::Cop.dup
7
-
8
- # Clone of the the normal RuboCop::Cop::Cop class so we can rewrite
9
- # the inherited method without breaking functionality
10
- class WorkaroundCop
11
- # Remove the Cop.inherited method to be a noop. Our SketchUp::Cop
12
- # class will invoke the inherited hook instead
13
- class << self
14
- undef inherited
15
- def inherited(*) end
16
- end
17
-
18
- # Special case `Module#<` so that the rspec support rubocop exports
19
- # is compatible with our subclass
20
- def self.<(other)
21
- other.equal?(RuboCop::Cop::Cop) || super
22
- end
23
- end
24
- private_constant(:WorkaroundCop)
25
-
26
- # @abstract parent class to SketchUp cops
27
- #
28
- # The criteria for whether rubocop-sketchup analyzes a certain ruby file
29
- # is configured via `AllCops/SketchUp`. For example, if you want to
30
- # customize your project to scan all files within a `test/` directory
31
- # then you could add this to your configuration:
32
- #
33
- # @example configuring analyzed paths
34
- #
35
- # AllCops:
36
- # SketchUp:
37
- # SketchupDeprecations:
38
- # Exclude:
39
- # - '_test.rb$'
40
- # - '(?:^|/)test/'
41
- class Cop < WorkaroundCop
42
-
43
- include SketchUp::Config
44
-
45
- # Invoke the original inherited hook so our cops are recognized
46
- def self.inherited(subclass)
47
- RuboCop::Cop::Cop.inherited(subclass)
48
- end
49
-
50
- def relevant_file?(file)
51
- relevant_rubocop_sketchup_file?(file) && super
52
- end
53
-
54
- private
55
-
56
- def default_severity
57
- sketchup_severity || super
58
- end
59
-
60
- def sketchup_severity
61
- case self.class.department
62
- when :SketchupRequirements
63
- :error
64
- when :SketchupDeprecations
65
- :warning
66
- when :SketchupPerformance
67
- :warning
68
- when :SketchupSuggestions
69
- :convention
70
- end
71
- end
72
-
73
- def department_name
74
- self.class.department.to_s
75
- end
76
-
77
- def relevant_rubocop_sketchup_file?(file)
78
- !sketchup_excluded?(file)
79
- end
80
-
81
- def sketchup_excluded?(file)
82
- matches_file?(file, sketchup_exclude_pattern) ||
83
- matches_file?(file, sketchup_department_exclude_pattern)
84
- end
85
-
86
- def matches_file?(file, patterns)
87
- path = nil
88
- patterns.any? do |pattern|
89
- # Try to match the absolute path, as Exclude properties are absolute.
90
- next true if match_path?(pattern, file)
91
-
92
- # Try with relative path.
93
- path ||= config.path_relative_to_config(file)
94
- match_path?(pattern, path)
95
- end
96
- end
97
-
98
- def sketchup_department_exclude_pattern
99
- sketchup_cops_config
100
- .fetch(department_name, {})
101
- .fetch('Exclude', [])
102
- end
103
-
104
- def sketchup_exclude_pattern
105
- sketchup_cops_config
106
- .fetch('Exclude', [])
107
- end
108
-
109
- end
110
- end
111
- end
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module SketchUp
5
+
6
+ WorkaroundCop = RuboCop::Cop::Cop.dup
7
+
8
+ # Clone of the the normal RuboCop::Cop::Cop class so we can rewrite
9
+ # the inherited method without breaking functionality
10
+ class WorkaroundCop
11
+ # Remove the Cop.inherited method to be a noop. Our SketchUp::Cop
12
+ # class will invoke the inherited hook instead
13
+ class << self
14
+ undef inherited
15
+ def inherited(*) end
16
+ end
17
+
18
+ # Special case `Module#<` so that the rspec support rubocop exports
19
+ # is compatible with our subclass
20
+ def self.<(other)
21
+ other.equal?(RuboCop::Cop::Cop) || super
22
+ end
23
+ end
24
+ private_constant(:WorkaroundCop)
25
+
26
+ # @abstract parent class to SketchUp cops
27
+ #
28
+ # The criteria for whether rubocop-sketchup analyzes a certain ruby file
29
+ # is configured via `AllCops/SketchUp`. For example, if you want to
30
+ # customize your project to scan all files within a `test/` directory
31
+ # then you could add this to your configuration:
32
+ #
33
+ # @example configuring analyzed paths
34
+ #
35
+ # AllCops:
36
+ # SketchUp:
37
+ # SketchupDeprecations:
38
+ # Exclude:
39
+ # - '_test.rb$'
40
+ # - '(?:^|/)test/'
41
+ class Cop < WorkaroundCop
42
+
43
+ include SketchUp::Config
44
+
45
+ # Invoke the original inherited hook so our cops are recognized
46
+ def self.inherited(subclass)
47
+ RuboCop::Cop::Cop.inherited(subclass)
48
+ end
49
+
50
+ def relevant_file?(file)
51
+ relevant_rubocop_sketchup_file?(file) && super
52
+ end
53
+
54
+ private
55
+
56
+ def default_severity
57
+ sketchup_severity || super
58
+ end
59
+
60
+ def sketchup_severity
61
+ case self.class.department
62
+ when :SketchupRequirements
63
+ :error
64
+ when :SketchupDeprecations
65
+ :warning
66
+ when :SketchupPerformance
67
+ :warning
68
+ when :SketchupSuggestions
69
+ :convention
70
+ end
71
+ end
72
+
73
+ def department_name
74
+ self.class.department.to_s
75
+ end
76
+
77
+ def relevant_rubocop_sketchup_file?(file)
78
+ !sketchup_excluded?(file)
79
+ end
80
+
81
+ def sketchup_excluded?(file)
82
+ matches_file?(file, sketchup_exclude_pattern) ||
83
+ matches_file?(file, sketchup_department_exclude_pattern)
84
+ end
85
+
86
+ def matches_file?(file, patterns)
87
+ path = nil
88
+ patterns.any? do |pattern|
89
+ # Try to match the absolute path, as Exclude properties are absolute.
90
+ next true if match_path?(pattern, file)
91
+
92
+ # Try with relative path.
93
+ path ||= config.path_relative_to_config(file)
94
+ match_path?(pattern, path)
95
+ end
96
+ end
97
+
98
+ def sketchup_department_exclude_pattern
99
+ sketchup_cops_config
100
+ .fetch(department_name, {})
101
+ .fetch('Exclude', [])
102
+ end
103
+
104
+ def sketchup_exclude_pattern
105
+ sketchup_cops_config
106
+ .fetch('Exclude', [])
107
+ end
108
+
109
+ end
110
+ end
111
+ end