rubocop-sketchup 0.0.1
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 +7 -0
- data/Gemfile +8 -0
- data/lib/rubocop-sketchup.rb +12 -0
- data/lib/rubocop/sketchup/deprecations/operation_next_transparent.rb +21 -0
- data/lib/rubocop/sketchup/namespace.rb +47 -0
- data/lib/rubocop/sketchup/namespace_checker.rb +43 -0
- data/lib/rubocop/sketchup/no_comment_disable.rb +17 -0
- data/lib/rubocop/sketchup/performance/operation_disable_ui.rb +25 -0
- data/lib/rubocop/sketchup/performance/typename.rb +19 -0
- data/lib/rubocop/sketchup/requirements/api_namespace.rb +24 -0
- data/lib/rubocop/sketchup/requirements/extension_namespace.rb +64 -0
- data/lib/rubocop/sketchup/requirements/global_constants.rb +22 -0
- data/lib/rubocop/sketchup/requirements/global_methods.rb +53 -0
- data/lib/rubocop/sketchup/requirements/global_variables.rb +67 -0
- data/lib/rubocop/sketchup/requirements/load_path.rb +80 -0
- data/lib/rubocop/sketchup/requirements/ruby_core_namespace.rb +285 -0
- data/lib/rubocop/sketchup/requirements/ruby_stdlib_namespace.rb +628 -0
- data/lib/rubocop/sketchup/suggestions/model_entities.rb +33 -0
- data/lib/rubocop/sketchup/suggestions/operation_name.rb +32 -0
- data/lib/rubocop/sketchup/version.rb +5 -0
- data/rubocop-sketchup.gemspec +27 -0
- metadata +91 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupSuggestions
|
6
|
+
class ModelEntities < Cop
|
7
|
+
MSG = 'Typically one should use model.active_entities instead of model.entities.'.freeze
|
8
|
+
|
9
|
+
# Reference: http://www.rubydoc.info/gems/rubocop/RuboCop/NodePattern
|
10
|
+
#
|
11
|
+
# {} will match any of the patterns inside the brackets.
|
12
|
+
#
|
13
|
+
# Testing for; Sketchup.active_model
|
14
|
+
# (send (const nil :Sketchup) :active_model)
|
15
|
+
#
|
16
|
+
# Testing for; model.entities or mod.entities
|
17
|
+
# (lvar {:model :mod})
|
18
|
+
def_node_matcher :model_entities?, <<-PATTERN
|
19
|
+
(send
|
20
|
+
{
|
21
|
+
(send (const nil :Sketchup) :active_model)
|
22
|
+
(lvar {:model :mod})
|
23
|
+
}
|
24
|
+
:entities)
|
25
|
+
PATTERN
|
26
|
+
|
27
|
+
def on_send(node)
|
28
|
+
add_offense(node, :expression) if model_entities?(node)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module SketchupSuggestions
|
6
|
+
class OperationName < Cop
|
7
|
+
MSG = 'Operation name should be a short capitalized description.'.freeze
|
8
|
+
|
9
|
+
def on_send(node)
|
10
|
+
_, method_name, *args = *node
|
11
|
+
return unless method_name == :start_operation
|
12
|
+
operation_name = args.first.children.first
|
13
|
+
return if acceptable_operation_name?(operation_name)
|
14
|
+
add_offense(args.first, :expression)
|
15
|
+
end
|
16
|
+
|
17
|
+
def acceptable_operation_name?(name)
|
18
|
+
# Capitalization, no programmer name, no punctuation
|
19
|
+
return false if name.size > 25 # TODO: Separate Cop?
|
20
|
+
return false if name.end_with?('.')
|
21
|
+
return false if titleize(name) != name
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO(thomthom): Might need to ignore words like 'and/or'
|
26
|
+
def titleize(string)
|
27
|
+
string.split.map(&:capitalize).join(' ')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
4
|
+
require 'rubocop/sketchup/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'rubocop-sketchup'
|
8
|
+
spec.summary = 'RuboCop rules for SketchUp extensions.'
|
9
|
+
spec.description = 'RuboCop rules for SketchUp extensions.'
|
10
|
+
spec.homepage = 'http://github.com/sketchup/rubocop-sketchup'
|
11
|
+
spec.authors = ['Trimble Inc, SketchUp Team']
|
12
|
+
spec.licenses = ['MIT']
|
13
|
+
|
14
|
+
spec.version = RuboCop::SketchUp::VERSION
|
15
|
+
spec.platform = Gem::Platform::RUBY
|
16
|
+
spec.required_ruby_version = '>= 2.0.0'
|
17
|
+
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
spec.files = Dir[
|
20
|
+
'lib/**/*',
|
21
|
+
'*.gemspec',
|
22
|
+
'Gemfile'
|
23
|
+
]
|
24
|
+
|
25
|
+
spec.add_dependency 'rubocop', '~> 0.47'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop-sketchup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Trimble Inc, SketchUp Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.47'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.47'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.13'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.13'
|
41
|
+
description: RuboCop rules for SketchUp extensions.
|
42
|
+
email:
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- Gemfile
|
48
|
+
- lib/rubocop-sketchup.rb
|
49
|
+
- lib/rubocop/sketchup/deprecations/operation_next_transparent.rb
|
50
|
+
- lib/rubocop/sketchup/namespace.rb
|
51
|
+
- lib/rubocop/sketchup/namespace_checker.rb
|
52
|
+
- lib/rubocop/sketchup/no_comment_disable.rb
|
53
|
+
- lib/rubocop/sketchup/performance/operation_disable_ui.rb
|
54
|
+
- lib/rubocop/sketchup/performance/typename.rb
|
55
|
+
- lib/rubocop/sketchup/requirements/api_namespace.rb
|
56
|
+
- lib/rubocop/sketchup/requirements/extension_namespace.rb
|
57
|
+
- lib/rubocop/sketchup/requirements/global_constants.rb
|
58
|
+
- lib/rubocop/sketchup/requirements/global_methods.rb
|
59
|
+
- lib/rubocop/sketchup/requirements/global_variables.rb
|
60
|
+
- lib/rubocop/sketchup/requirements/load_path.rb
|
61
|
+
- lib/rubocop/sketchup/requirements/ruby_core_namespace.rb
|
62
|
+
- lib/rubocop/sketchup/requirements/ruby_stdlib_namespace.rb
|
63
|
+
- lib/rubocop/sketchup/suggestions/model_entities.rb
|
64
|
+
- lib/rubocop/sketchup/suggestions/operation_name.rb
|
65
|
+
- lib/rubocop/sketchup/version.rb
|
66
|
+
- rubocop-sketchup.gemspec
|
67
|
+
homepage: http://github.com/sketchup/rubocop-sketchup
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.0.0
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.5.2
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: RuboCop rules for SketchUp extensions.
|
91
|
+
test_files: []
|