ruby-lint 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +43 -29
- data/LICENSE +1 -1
- data/README.md +0 -1
- data/bin/ruby-lint +91 -3
- data/checksum/ruby-lint-1.1.0.gem.sha512 +1 -0
- data/doc/changelog.md +30 -0
- data/doc/code_analysis.md +13 -0
- data/doc/configuration.md +5 -24
- data/lib/ruby-lint.rb +7 -10
- data/lib/ruby-lint/analysis/argument_amount.rb +2 -0
- data/lib/ruby-lint/analysis/base.rb +12 -0
- data/lib/ruby-lint/analysis/pedantics.rb +2 -0
- data/lib/ruby-lint/analysis/shadowing_variables.rb +2 -0
- data/lib/ruby-lint/analysis/undefined_methods.rb +5 -2
- data/lib/ruby-lint/analysis/undefined_variables.rb +2 -0
- data/lib/ruby-lint/analysis/unused_variables.rb +2 -0
- data/lib/ruby-lint/analysis/useless_equality_checks.rb +2 -0
- data/lib/ruby-lint/ast/node.rb +0 -15
- data/lib/ruby-lint/command.rb +100 -0
- data/lib/ruby-lint/configuration.rb +35 -66
- data/lib/ruby-lint/constant_path.rb +7 -2
- data/lib/ruby-lint/definition/ruby_object.rb +20 -6
- data/lib/ruby-lint/definitions/core/argf.rb +3 -3
- data/lib/ruby-lint/definitions/gems/minitest.rb +792 -0
- data/lib/ruby-lint/file_list.rb +1 -1
- data/lib/ruby-lint/file_loader.rb +2 -20
- data/lib/ruby-lint/file_scanner.rb +11 -2
- data/lib/ruby-lint/method_evaluation.rb +21 -0
- data/lib/ruby-lint/presenter/base.rb +18 -0
- data/lib/ruby-lint/presenter/json.rb +3 -1
- data/lib/ruby-lint/presenter/syntastic.rb +3 -1
- data/lib/ruby-lint/presenter/text.rb +3 -1
- data/lib/ruby-lint/runner.rb +6 -63
- data/lib/ruby-lint/variable_predicates.rb +3 -3
- data/lib/ruby-lint/version.rb +1 -1
- data/lib/ruby-lint/virtual_machine.rb +4 -1
- data/ruby-lint.gemspec +13 -4
- metadata +12 -187
- data/.editorconfig +0 -15
- data/.gitignore +0 -6
- data/.ruby-version +0 -1
- data/.travis.yml +0 -19
- data/Gemfile +0 -15
- data/MANIFEST +0 -469
- data/Rakefile +0 -25
- data/benchmark/bootup.rb +0 -13
- data/benchmark/virtual_machine.rb +0 -17
- data/checksum/.gitkeep +0 -0
- data/doc/.gitkeep +0 -0
- data/doc/css/.gitkeep +0 -0
- data/doc/images/.gitkeep +0 -0
- data/gen/rails/constants.txt +0 -12
- data/gen/rails/requires.rb +0 -2
- data/gen/stdlib/constants.rb +0 -30
- data/gen/stdlib/constants.txt +0 -214
- data/gen/stdlib/requires.rb +0 -64
- data/lib/ruby-lint/benchmark/average.rb +0 -115
- data/lib/ruby-lint/cache.rb +0 -121
- data/lib/ruby-lint/cache_entry.rb +0 -44
- data/lib/ruby-lint/cli.rb +0 -4
- data/lib/ruby-lint/cli/analyze.rb +0 -209
- data/lib/ruby-lint/cli/base.rb +0 -103
- data/lib/ruby-lint/cli/cache.rb +0 -60
- data/lib/ruby-lint/default_names.rb +0 -19
- data/lib/ruby-lint/definitions/gems/.gitkeep +0 -0
- data/lib/ruby-lint/node_hash.rb +0 -105
- data/misc/stdlib.rb +0 -66
- data/profiling/virtual_machine.rb +0 -20
- data/ruby-lint.yml +0 -7
- data/spec/fixtures/associating.rb +0 -7
- data/spec/fixtures/complex/rails/basic_controller.rb +0 -9
- data/spec/fixtures/complex/rcap.rb +0 -67
- data/spec/fixtures/complex/slop.rb +0 -701
- data/spec/fixtures/config.yml +0 -8
- data/spec/fixtures/deeply/nested/file.rb +0 -1
- data/spec/fixtures/file_scanner/lib/example/recursive/source.rb +0 -6
- data/spec/fixtures/file_scanner/lib/example/recursive/target.rb +0 -8
- data/spec/fixtures/file_scanner/lib/example/user.rb +0 -6
- data/spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb +0 -6
- data/spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb +0 -6
- data/spec/fixtures/file_scanner/lib/test-dashes/foo.rb +0 -4
- data/spec/fixtures/file_scanner/rails/app/models/example/user.rb +0 -6
- data/spec/fixtures/file_scanner/rails/app/models/user.rb +0 -4
- data/spec/fixtures/invalid.rb +0 -3
- data/spec/fixtures/invalid_2.rb +0 -3
- data/spec/fixtures/syntax_error.rb +0 -1
- data/spec/fixtures/uses_external.rb +0 -1
- data/spec/fixtures/uses_external_invalid.rb +0 -3
- data/spec/fixtures/uses_external_namespace.rb +0 -1
- data/spec/fixtures/valid.rb +0 -3
- data/spec/ruby-lint/analysis/argument_amount_spec.rb +0 -131
- data/spec/ruby-lint/analysis/base_spec.rb +0 -24
- data/spec/ruby-lint/analysis/pedantics_spec.rb +0 -63
- data/spec/ruby-lint/analysis/shadowing_variables_spec.rb +0 -85
- data/spec/ruby-lint/analysis/undefined_methods_spec.rb +0 -337
- data/spec/ruby-lint/analysis/undefined_variables_spec.rb +0 -138
- data/spec/ruby-lint/analysis/unused_variables_spec.rb +0 -270
- data/spec/ruby-lint/analysis/useless_equality_checks_spec.rb +0 -107
- data/spec/ruby-lint/ast/node_spec.rb +0 -39
- data/spec/ruby-lint/cache_entry_spec.rb +0 -25
- data/spec/ruby-lint/cache_spec.rb +0 -53
- data/spec/ruby-lint/cli/analyze_spec.rb +0 -52
- data/spec/ruby-lint/configuration_spec.rb +0 -126
- data/spec/ruby-lint/constant_loader_spec.rb +0 -79
- data/spec/ruby-lint/constant_path.rb +0 -63
- data/spec/ruby-lint/definition/constant_proxy_spec.rb +0 -85
- data/spec/ruby-lint/definition/dsl_spec.rb +0 -135
- data/spec/ruby-lint/definition/registry_spec.rb +0 -106
- data/spec/ruby-lint/definition/ruby_method_spec.rb +0 -106
- data/spec/ruby-lint/definition/ruby_object_spec.rb +0 -264
- data/spec/ruby-lint/definition_builder/primitive_spec.rb +0 -62
- data/spec/ruby-lint/definition_builder/ruby_class_spec.rb +0 -107
- data/spec/ruby-lint/definition_builder/ruby_method_spec.rb +0 -53
- data/spec/ruby-lint/definition_builder/ruby_module_spec.rb +0 -52
- data/spec/ruby-lint/definitions/argv_spec.rb +0 -18
- data/spec/ruby-lint/definitions/env_spec.rb +0 -13
- data/spec/ruby-lint/definitions/file_spec.rb +0 -17
- data/spec/ruby-lint/definitions/fixnum_spec.rb +0 -18
- data/spec/ruby-lint/definitions/io_spec.rb +0 -15
- data/spec/ruby-lint/definitions/kernel_spec.rb +0 -18
- data/spec/ruby-lint/definitions/range_spec.rb +0 -21
- data/spec/ruby-lint/definitions/string_spec.rb +0 -20
- data/spec/ruby-lint/docstring/mapping.rb +0 -27
- data/spec/ruby-lint/docstring/parser_spec.rb +0 -88
- data/spec/ruby-lint/extensions/string_spec.rb +0 -7
- data/spec/ruby-lint/file_list_spec.rb +0 -25
- data/spec/ruby-lint/file_loader_spec.rb +0 -69
- data/spec/ruby-lint/file_scanner_spec.rb +0 -84
- data/spec/ruby-lint/inspector_spec.rb +0 -224
- data/spec/ruby-lint/iterator_spec.rb +0 -151
- data/spec/ruby-lint/method_call/.gitkeep +0 -0
- data/spec/ruby-lint/nested_stack_spec.rb +0 -23
- data/spec/ruby-lint/node_hash_spec.rb +0 -56
- data/spec/ruby-lint/parser_spec.rb +0 -38
- data/spec/ruby-lint/presenter/json_spec.rb +0 -58
- data/spec/ruby-lint/presenter/syntastic_spec.rb +0 -49
- data/spec/ruby-lint/presenter/text_spec.rb +0 -49
- data/spec/ruby-lint/report/entry_spec.rb +0 -58
- data/spec/ruby-lint/report_spec.rb +0 -39
- data/spec/ruby-lint/runner_spec.rb +0 -74
- data/spec/ruby-lint/variable_predicates_spec.rb +0 -30
- data/spec/ruby-lint/virtual_machine/alias_spec.rb +0 -55
- data/spec/ruby-lint/virtual_machine/assignments/arrays_spec.rb +0 -87
- data/spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb +0 -14
- data/spec/ruby-lint/virtual_machine/assignments/constants_spec.rb +0 -23
- data/spec/ruby-lint/virtual_machine/assignments/hashes_spec.rb +0 -52
- data/spec/ruby-lint/virtual_machine/assignments/optional_spec.rb +0 -41
- data/spec/ruby-lint/virtual_machine/assignments/range_spec.rb +0 -28
- data/spec/ruby-lint/virtual_machine/assignments/return_values_spec.rb +0 -78
- data/spec/ruby-lint/virtual_machine/assignments/variables_spec.rb +0 -130
- data/spec/ruby-lint/virtual_machine/associate_nodes_spec.rb +0 -61
- data/spec/ruby-lint/virtual_machine/autoloading_spec.rb +0 -18
- data/spec/ruby-lint/virtual_machine/blocks_spec.rb +0 -90
- data/spec/ruby-lint/virtual_machine/classes/class_methods_spec.rb +0 -21
- data/spec/ruby-lint/virtual_machine/classes/extending_spec.rb +0 -109
- data/spec/ruby-lint/virtual_machine/classes/redefining_spec.rb +0 -51
- data/spec/ruby-lint/virtual_machine/classes/sclass_spec.rb +0 -96
- data/spec/ruby-lint/virtual_machine/classes/scoping_spec.rb +0 -60
- data/spec/ruby-lint/virtual_machine/complex/rails_spec.rb +0 -21
- data/spec/ruby-lint/virtual_machine/complex/rcap_spec.rb +0 -15
- data/spec/ruby-lint/virtual_machine/complex/slop_spec.rb +0 -16
- data/spec/ruby-lint/virtual_machine/constants_spec.rb +0 -31
- data/spec/ruby-lint/virtual_machine/for_spec.rb +0 -16
- data/spec/ruby-lint/virtual_machine/freeze_spec.rb +0 -13
- data/spec/ruby-lint/virtual_machine/global_variables_spec.rb +0 -15
- data/spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb +0 -15
- data/spec/ruby-lint/virtual_machine/interpolation_spec.rb +0 -12
- data/spec/ruby-lint/virtual_machine/location_spec.rb +0 -64
- data/spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb +0 -57
- data/spec/ruby-lint/virtual_machine/methods/attr_spec.rb +0 -182
- data/spec/ruby-lint/virtual_machine/methods/calls_spec.rb +0 -25
- data/spec/ruby-lint/virtual_machine/methods/define_method_spec.rb +0 -41
- data/spec/ruby-lint/virtual_machine/methods/defining_spec.rb +0 -40
- data/spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb +0 -80
- data/spec/ruby-lint/virtual_machine/methods/exporting_spec.rb +0 -19
- data/spec/ruby-lint/virtual_machine/methods/kernel_spec.rb +0 -25
- data/spec/ruby-lint/virtual_machine/methods/parameters_spec.rb +0 -89
- data/spec/ruby-lint/virtual_machine/methods/patching_spec.rb +0 -20
- data/spec/ruby-lint/virtual_machine/methods/scoping_spec.rb +0 -63
- data/spec/ruby-lint/virtual_machine/methods/square_bracket_spec.rb +0 -32
- data/spec/ruby-lint/virtual_machine/methods/visibility_spec.rb +0 -64
- data/spec/ruby-lint/virtual_machine/modules_spec.rb +0 -205
- data/spec/ruby-lint/virtual_machine/reference_amount_spec.rb +0 -81
- data/spec/ruby-lint/virtual_machine/self_spec.rb +0 -37
- data/spec/ruby-lint/virtual_machine/unused_spec.rb +0 -17
- data/spec/spec_helper.rb +0 -28
- data/spec/support/building.rb +0 -50
- data/spec/support/coveralls.rb +0 -5
- data/spec/support/definitions.rb +0 -39
- data/spec/support/fixtures.rb +0 -20
- data/spec/support/parsing.rb +0 -30
- data/spec/support/simplecov.rb +0 -18
- data/spec/support/versions.rb +0 -9
- data/task/build.rake +0 -4
- data/task/checksum.rake +0 -13
- data/task/coverage.rake +0 -6
- data/task/doc.rake +0 -16
- data/task/generate.rake +0 -77
- data/task/graphviz.rake +0 -12
- data/task/manifest.rake +0 -8
- data/task/tag.rake +0 -6
- data/task/test.rake +0 -4
- data/task/todo.rake +0 -6
- data/task/travis.rake +0 -8
data/lib/ruby-lint/file_list.rb
CHANGED
@@ -20,14 +20,11 @@ module RubyLint
|
|
20
20
|
# @return [Array] A list of extra nodes (and their comments) a VM instance
|
21
21
|
# should process before processing the file being analyzed.
|
22
22
|
#
|
23
|
-
# @!attribute [r] debug
|
24
|
-
# @return [TrueClass|FalseClass]
|
25
|
-
#
|
26
23
|
# @!attribute [r] paths
|
27
24
|
# @return [Set]
|
28
25
|
#
|
29
26
|
class FileLoader < Iterator
|
30
|
-
attr_reader :file_scanner, :parser, :nodes, :comments, :
|
27
|
+
attr_reader :file_scanner, :parser, :nodes, :comments, :paths
|
31
28
|
|
32
29
|
##
|
33
30
|
# Called after a new instance of this class is created.
|
@@ -55,8 +52,6 @@ module RubyLint
|
|
55
52
|
|
56
53
|
paths << path
|
57
54
|
|
58
|
-
debug_message("Processing extra file: #{path}")
|
59
|
-
|
60
55
|
process_file(last_name, path)
|
61
56
|
end
|
62
57
|
end
|
@@ -70,13 +65,7 @@ module RubyLint
|
|
70
65
|
def process_file(constant_name, path)
|
71
66
|
code = File.read(path)
|
72
67
|
|
73
|
-
unless code.include?(constant_name)
|
74
|
-
debug_message(
|
75
|
-
%Q{ Skipping since "#{constant_name}" was not found in this file}
|
76
|
-
)
|
77
|
-
|
78
|
-
return
|
79
|
-
end
|
68
|
+
return unless code.include?(constant_name)
|
80
69
|
|
81
70
|
ast, comments = parser.parse(code, path)
|
82
71
|
|
@@ -84,12 +73,5 @@ module RubyLint
|
|
84
73
|
|
85
74
|
nodes << [ast, comments]
|
86
75
|
end
|
87
|
-
|
88
|
-
##
|
89
|
-
# @param [String] message
|
90
|
-
#
|
91
|
-
def debug_message(message)
|
92
|
-
STDERR.puts(message) if debug
|
93
|
-
end
|
94
76
|
end # FileLoader
|
95
77
|
end # RubyLint
|
@@ -114,6 +114,11 @@ module RubyLint
|
|
114
114
|
# @return [Array]
|
115
115
|
#
|
116
116
|
def match_globbed_files(segment)
|
117
|
+
# Ensure that we match entire path segments. Just using the segment would
|
118
|
+
# result in partial filename matching (e.g. "foo.rb" matching
|
119
|
+
# "bar_foo.rb"). We don't want that.
|
120
|
+
segment = "/#{segment}"
|
121
|
+
|
117
122
|
return @glob_cache.select { |p| p.include?(segment) }
|
118
123
|
end
|
119
124
|
|
@@ -138,9 +143,13 @@ module RubyLint
|
|
138
143
|
def constant_to_dashed_path(constant)
|
139
144
|
segments = constant.split('::')
|
140
145
|
last = segments[-1]
|
141
|
-
|
146
|
+
prefix = segments[0..-2].join('/').snake_case.gsub('_', '-')
|
147
|
+
|
148
|
+
unless prefix.empty?
|
149
|
+
prefix += '/'
|
150
|
+
end
|
142
151
|
|
143
|
-
return "#{
|
152
|
+
return "#{prefix}#{last.snake_case}.rb"
|
144
153
|
end
|
145
154
|
|
146
155
|
##
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RubyLint
|
2
|
+
##
|
3
|
+
# Mixin that provides helper methods for handling method calls.
|
4
|
+
#
|
5
|
+
module MethodEvaluation
|
6
|
+
##
|
7
|
+
# Given a `(block)` node this method returns the nested `(send)` node. If
|
8
|
+
# the supplied node is not a block it is returned directly.
|
9
|
+
#
|
10
|
+
# This method is mostly useful for dealing with method calls that take a
|
11
|
+
# block. In these cases the AST is in the form of `(block (send))` instead
|
12
|
+
# of `(send (block))`.
|
13
|
+
#
|
14
|
+
# @param [RubyLint::AST::Node] node
|
15
|
+
# @return [RubyLint::AST::Node]
|
16
|
+
#
|
17
|
+
def unpack_block(node)
|
18
|
+
return node && node.block? ? node.children[0] : node
|
19
|
+
end
|
20
|
+
end # MethodEvaluation
|
21
|
+
end # RubyLint
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RubyLint
|
2
|
+
module Presenter
|
3
|
+
##
|
4
|
+
# Base presenter class that provides some commonly used methods.
|
5
|
+
#
|
6
|
+
class Base
|
7
|
+
##
|
8
|
+
# Registers the presenter in
|
9
|
+
# {RubyLint::Configuration.available_presenters}.
|
10
|
+
#
|
11
|
+
# @param [String] name
|
12
|
+
#
|
13
|
+
def self.register(name)
|
14
|
+
Configuration.available_presenters[name] = self
|
15
|
+
end
|
16
|
+
end # Base
|
17
|
+
end # Presenter
|
18
|
+
end # RubyLint
|
@@ -4,7 +4,9 @@ module RubyLint
|
|
4
4
|
# {RubyLint::Presenter::JSON} formats a instance of {RubyLint::Report} into
|
5
5
|
# a JSON formatted string.
|
6
6
|
#
|
7
|
-
class JSON
|
7
|
+
class JSON < Base
|
8
|
+
register 'json'
|
9
|
+
|
8
10
|
##
|
9
11
|
# @param [RubyLint::Report] report The report to present.
|
10
12
|
# @return [String]
|
@@ -4,7 +4,9 @@ module RubyLint
|
|
4
4
|
# {RubyLint::Presenter::Text} formats a instance of {RubyLint::Report} into
|
5
5
|
# a text based, human readable format.
|
6
6
|
#
|
7
|
-
class Text
|
7
|
+
class Text < Base
|
8
|
+
register 'text'
|
9
|
+
|
8
10
|
##
|
9
11
|
# The default format to use when presenting report entries.
|
10
12
|
#
|
data/lib/ruby-lint/runner.rb
CHANGED
@@ -7,20 +7,14 @@ module RubyLint
|
|
7
7
|
# @!attribute [r] configuration
|
8
8
|
# @return [RubyLint::Configuration]
|
9
9
|
#
|
10
|
-
# @!attribute [r] cache
|
11
|
-
# @return [RubyLint::Cache]
|
12
|
-
#
|
13
10
|
class Runner
|
14
|
-
attr_reader :configuration
|
11
|
+
attr_reader :configuration
|
15
12
|
|
16
13
|
##
|
17
14
|
# @param [RubyLint::Configuration] configuration
|
18
15
|
#
|
19
16
|
def initialize(configuration)
|
20
17
|
@configuration = configuration
|
21
|
-
@cache = Cache.new(configuration.cache_directory)
|
22
|
-
|
23
|
-
@cache.create_directory! if configuration.enable_cache
|
24
18
|
end
|
25
19
|
|
26
20
|
##
|
@@ -81,9 +75,7 @@ module RubyLint
|
|
81
75
|
# @return [Array]
|
82
76
|
#
|
83
77
|
def parse_file(parser, file)
|
84
|
-
|
85
|
-
|
86
|
-
return ast, NodeHash.from_hash(comments)
|
78
|
+
return parser.parse(File.read(file), file)
|
87
79
|
end
|
88
80
|
|
89
81
|
##
|
@@ -95,32 +87,22 @@ module RubyLint
|
|
95
87
|
# @return [Array]
|
96
88
|
#
|
97
89
|
def process_external_files(root_ast)
|
98
|
-
if cached_values = get_cache(root_ast)
|
99
|
-
return cached_values
|
100
|
-
end
|
101
|
-
|
102
90
|
loader = FileLoader.new(
|
103
91
|
:directories => configuration.directories,
|
104
|
-
:ignore_paths => configuration.ignore_paths
|
105
|
-
:debug => configuration.debug
|
92
|
+
:ignore_paths => configuration.ignore_paths
|
106
93
|
)
|
107
94
|
|
108
95
|
nodes = []
|
109
|
-
|
110
|
-
comments = NodeHash.new
|
96
|
+
comments = {}
|
111
97
|
|
112
98
|
loader.iterate(root_ast)
|
113
99
|
|
114
100
|
loader.nodes.each do |(ast, comment_associations)|
|
115
101
|
nodes << ast
|
116
102
|
|
117
|
-
|
118
|
-
|
119
|
-
comments.merge_hash!(comment_associations)
|
103
|
+
comments.merge!(comment_associations)
|
120
104
|
end
|
121
105
|
|
122
|
-
set_cache(root_ast, nodes, comments, mtimes)
|
123
|
-
|
124
106
|
return nodes, comments
|
125
107
|
end
|
126
108
|
|
@@ -130,7 +112,7 @@ module RubyLint
|
|
130
112
|
#
|
131
113
|
def report_diagnostic(diagnostic, report)
|
132
114
|
report.add(
|
133
|
-
:level =>
|
115
|
+
:level => diagnostic.level,
|
134
116
|
:message => diagnostic.message,
|
135
117
|
:line => diagnostic.location.line,
|
136
118
|
:column => diagnostic.location.column + 1,
|
@@ -173,44 +155,5 @@ module RubyLint
|
|
173
155
|
instance.iterate(ast)
|
174
156
|
end
|
175
157
|
end
|
176
|
-
|
177
|
-
##
|
178
|
-
# Checks if the AST node has a cache file and if so returns the nodes and
|
179
|
-
# comments that are cached.
|
180
|
-
#
|
181
|
-
# @param [RubyLint::AST::Node] node
|
182
|
-
# @return [Array]
|
183
|
-
#
|
184
|
-
def get_cache(node)
|
185
|
-
return unless configuration.enable_cache
|
186
|
-
|
187
|
-
cache_name = node.sha1
|
188
|
-
|
189
|
-
if cache.exists?(cache_name)
|
190
|
-
entry = cache.get(cache_name)
|
191
|
-
|
192
|
-
if entry.valid?
|
193
|
-
return entry.nodes, entry.comments
|
194
|
-
else
|
195
|
-
cache.delete(cache_name)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
return
|
200
|
-
end
|
201
|
-
|
202
|
-
##
|
203
|
-
# Caches the values for the given node.
|
204
|
-
#
|
205
|
-
# @param [RubyLint::AST::Node] node
|
206
|
-
# @param [Array] nodes
|
207
|
-
# @param [RubyLint::NodeHash] comments
|
208
|
-
# @param [Hash] mtimes
|
209
|
-
#
|
210
|
-
def set_cache(node, nodes, comments, mtimes)
|
211
|
-
return unless configuration.enable_cache
|
212
|
-
|
213
|
-
cache.set(node.sha1, CacheEntry.new(nodes, comments, mtimes))
|
214
|
-
end
|
215
158
|
end # Runner
|
216
159
|
end # RubyLint
|
@@ -41,9 +41,9 @@ module RubyLint
|
|
41
41
|
#
|
42
42
|
VARIABLE_TYPES = [:lvar, :ivar, :cvar, :gvar]
|
43
43
|
|
44
|
-
PREDICATE_METHODS.each do |
|
45
|
-
define_method("#{
|
46
|
-
return
|
44
|
+
PREDICATE_METHODS.each do |method|
|
45
|
+
define_method("#{method}?") do
|
46
|
+
return type == method
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
data/lib/ruby-lint/version.rb
CHANGED
@@ -70,6 +70,8 @@ module RubyLint
|
|
70
70
|
# @return [RubyLint::Docstring::Mapping]
|
71
71
|
#
|
72
72
|
class VirtualMachine < Iterator
|
73
|
+
include MethodEvaluation
|
74
|
+
|
73
75
|
attr_reader :associations,
|
74
76
|
:comments,
|
75
77
|
:definitions,
|
@@ -651,6 +653,7 @@ module RubyLint
|
|
651
653
|
def after_send(node)
|
652
654
|
receiver, name, _ = *node
|
653
655
|
|
656
|
+
receiver = unpack_block(receiver)
|
654
657
|
name = name.to_s
|
655
658
|
args_length = node.children[2..-1].length
|
656
659
|
values = value_stack.pop
|
@@ -670,7 +673,7 @@ Received: #{arguments.length}
|
|
670
673
|
|
671
674
|
# Associate the argument definitions with their nodes.
|
672
675
|
arguments.each_with_index do |obj, index|
|
673
|
-
arg_node = node.children[2 + index]
|
676
|
+
arg_node = unpack_block(node.children[2 + index])
|
674
677
|
|
675
678
|
associate_node(arg_node, obj)
|
676
679
|
end
|
data/ruby-lint.gemspec
CHANGED
@@ -9,13 +9,23 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.summary = 'A linter and static code analysis tool for Ruby.'
|
10
10
|
s.homepage = 'https://github.com/yorickpeterse/ruby-lint/'
|
11
11
|
s.description = s.summary
|
12
|
-
s.executables = ['ruby-lint']
|
13
12
|
s.license = 'MIT'
|
14
13
|
|
15
14
|
s.post_install_message = 'Please report any issues at: ' \
|
16
15
|
'https://github.com/YorickPeterse/ruby-lint/issues/new'
|
17
16
|
|
18
|
-
s.files =
|
17
|
+
s.files = Dir.glob([
|
18
|
+
'checksum/*.*',
|
19
|
+
'doc/**/*.*',
|
20
|
+
'lib/**/*.*',
|
21
|
+
'.yardopts',
|
22
|
+
'CONTRIBUTING.md',
|
23
|
+
'LICENSE',
|
24
|
+
'README.md',
|
25
|
+
'*.gemspec'
|
26
|
+
])
|
27
|
+
|
28
|
+
s.executables = ['ruby-lint']
|
19
29
|
|
20
30
|
s.has_rdoc = 'yard'
|
21
31
|
s.required_ruby_version = '>= 1.9.3'
|
@@ -24,10 +34,9 @@ Gem::Specification.new do |s|
|
|
24
34
|
s.add_dependency 'slop', ['~> 3.4', '>= 3.4.7']
|
25
35
|
|
26
36
|
s.add_development_dependency 'rake'
|
27
|
-
s.add_development_dependency 'rspec',
|
37
|
+
s.add_development_dependency 'rspec', '~> 3.0'
|
28
38
|
s.add_development_dependency 'yard'
|
29
39
|
s.add_development_dependency 'simplecov'
|
30
|
-
s.add_development_dependency 'coveralls'
|
31
40
|
s.add_development_dependency 'json'
|
32
41
|
s.add_development_dependency 'kramdown'
|
33
42
|
s.add_development_dependency 'redcard'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yorick Peterse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -68,16 +68,16 @@ dependencies:
|
|
68
68
|
name: rspec
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- - "
|
71
|
+
- - "~>"
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: '
|
73
|
+
version: '3.0'
|
74
74
|
type: :development
|
75
75
|
prerelease: false
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- - "
|
78
|
+
- - "~>"
|
79
79
|
- !ruby/object:Gem::Version
|
80
|
-
version: '
|
80
|
+
version: '3.0'
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: yard
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,20 +106,6 @@ dependencies:
|
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: coveralls
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
112
|
-
requirements:
|
113
|
-
- - ">="
|
114
|
-
- !ruby/object:Gem::Version
|
115
|
-
version: '0'
|
116
|
-
type: :development
|
117
|
-
prerelease: false
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
119
|
-
requirements:
|
120
|
-
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: '0'
|
123
109
|
- !ruby/object:Gem::Dependency
|
124
110
|
name: json
|
125
111
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,21 +155,11 @@ executables:
|
|
169
155
|
extensions: []
|
170
156
|
extra_rdoc_files: []
|
171
157
|
files:
|
172
|
-
- ".editorconfig"
|
173
|
-
- ".gitignore"
|
174
|
-
- ".ruby-version"
|
175
|
-
- ".travis.yml"
|
176
158
|
- ".yardopts"
|
177
159
|
- CONTRIBUTING.md
|
178
|
-
- Gemfile
|
179
160
|
- LICENSE
|
180
|
-
- MANIFEST
|
181
161
|
- README.md
|
182
|
-
- Rakefile
|
183
|
-
- benchmark/bootup.rb
|
184
|
-
- benchmark/virtual_machine.rb
|
185
162
|
- bin/ruby-lint
|
186
|
-
- checksum/.gitkeep
|
187
163
|
- checksum/ruby-lint-0.0.3.gem.sha512
|
188
164
|
- checksum/ruby-lint-0.0.4.gem.sha512
|
189
165
|
- checksum/ruby-lint-0.0.5.gem.sha512
|
@@ -194,23 +170,16 @@ files:
|
|
194
170
|
- checksum/ruby-lint-1.0.1.gem.sha512
|
195
171
|
- checksum/ruby-lint-1.0.2.gem.sha512
|
196
172
|
- checksum/ruby-lint-1.0.3.gem.sha512
|
197
|
-
-
|
173
|
+
- checksum/ruby-lint-1.1.0.gem.sha512
|
198
174
|
- doc/DCO.md
|
199
175
|
- doc/architecture.md
|
200
176
|
- doc/changelog.md
|
201
177
|
- doc/code_analysis.md
|
202
178
|
- doc/configuration.md
|
203
|
-
- doc/css/.gitkeep
|
204
179
|
- doc/css/common.css
|
205
180
|
- doc/definitions.md
|
206
181
|
- doc/graphviz/flow.dot
|
207
|
-
- doc/images/.gitkeep
|
208
182
|
- doc/images/flow.png
|
209
|
-
- gen/rails/constants.txt
|
210
|
-
- gen/rails/requires.rb
|
211
|
-
- gen/stdlib/constants.rb
|
212
|
-
- gen/stdlib/constants.txt
|
213
|
-
- gen/stdlib/requires.rb
|
214
183
|
- lib/ruby-lint.rb
|
215
184
|
- lib/ruby-lint/analysis/argument_amount.rb
|
216
185
|
- lib/ruby-lint/analysis/base.rb
|
@@ -222,17 +191,10 @@ files:
|
|
222
191
|
- lib/ruby-lint/analysis/useless_equality_checks.rb
|
223
192
|
- lib/ruby-lint/ast/builder.rb
|
224
193
|
- lib/ruby-lint/ast/node.rb
|
225
|
-
- lib/ruby-lint/
|
226
|
-
- lib/ruby-lint/cache.rb
|
227
|
-
- lib/ruby-lint/cache_entry.rb
|
228
|
-
- lib/ruby-lint/cli.rb
|
229
|
-
- lib/ruby-lint/cli/analyze.rb
|
230
|
-
- lib/ruby-lint/cli/base.rb
|
231
|
-
- lib/ruby-lint/cli/cache.rb
|
194
|
+
- lib/ruby-lint/command.rb
|
232
195
|
- lib/ruby-lint/configuration.rb
|
233
196
|
- lib/ruby-lint/constant_loader.rb
|
234
197
|
- lib/ruby-lint/constant_path.rb
|
235
|
-
- lib/ruby-lint/default_names.rb
|
236
198
|
- lib/ruby-lint/definition/constant_proxy.rb
|
237
199
|
- lib/ruby-lint/definition/registry.rb
|
238
200
|
- lib/ruby-lint/definition/ruby_method.rb
|
@@ -450,8 +412,8 @@ files:
|
|
450
412
|
- lib/ruby-lint/definitions/core/yaml.rb
|
451
413
|
- lib/ruby-lint/definitions/core/zero_division_error.rb
|
452
414
|
- lib/ruby-lint/definitions/core/zlib.rb
|
453
|
-
- lib/ruby-lint/definitions/gems/.gitkeep
|
454
415
|
- lib/ruby-lint/definitions/gems/devise.rb
|
416
|
+
- lib/ruby-lint/definitions/gems/minitest.rb
|
455
417
|
- lib/ruby-lint/definitions/gems/nokogiri.rb
|
456
418
|
- lib/ruby-lint/definitions/rails/abstract_controller.rb
|
457
419
|
- lib/ruby-lint/definitions/rails/action_controller.rb
|
@@ -483,9 +445,10 @@ files:
|
|
483
445
|
- lib/ruby-lint/method_call/define_method.rb
|
484
446
|
- lib/ruby-lint/method_call/include.rb
|
485
447
|
- lib/ruby-lint/method_call_info.rb
|
448
|
+
- lib/ruby-lint/method_evaluation.rb
|
486
449
|
- lib/ruby-lint/nested_stack.rb
|
487
|
-
- lib/ruby-lint/node_hash.rb
|
488
450
|
- lib/ruby-lint/parser.rb
|
451
|
+
- lib/ruby-lint/presenter/base.rb
|
489
452
|
- lib/ruby-lint/presenter/json.rb
|
490
453
|
- lib/ruby-lint/presenter/syntastic.rb
|
491
454
|
- lib/ruby-lint/presenter/text.rb
|
@@ -499,145 +462,7 @@ files:
|
|
499
462
|
- lib/ruby-lint/variable_predicates.rb
|
500
463
|
- lib/ruby-lint/version.rb
|
501
464
|
- lib/ruby-lint/virtual_machine.rb
|
502
|
-
- misc/stdlib.rb
|
503
|
-
- profiling/virtual_machine.rb
|
504
465
|
- ruby-lint.gemspec
|
505
|
-
- ruby-lint.yml
|
506
|
-
- spec/fixtures/associating.rb
|
507
|
-
- spec/fixtures/complex/rails/basic_controller.rb
|
508
|
-
- spec/fixtures/complex/rcap.rb
|
509
|
-
- spec/fixtures/complex/slop.rb
|
510
|
-
- spec/fixtures/config.yml
|
511
|
-
- spec/fixtures/deeply/nested/file.rb
|
512
|
-
- spec/fixtures/file_scanner/lib/example/recursive/source.rb
|
513
|
-
- spec/fixtures/file_scanner/lib/example/recursive/target.rb
|
514
|
-
- spec/fixtures/file_scanner/lib/example/user.rb
|
515
|
-
- spec/fixtures/file_scanner/lib/ruby-lint/definition/constant_proxy.rb
|
516
|
-
- spec/fixtures/file_scanner/lib/ruby-lint/global_scope.rb
|
517
|
-
- spec/fixtures/file_scanner/lib/test-dashes/foo.rb
|
518
|
-
- spec/fixtures/file_scanner/rails/app/models/example/user.rb
|
519
|
-
- spec/fixtures/file_scanner/rails/app/models/user.rb
|
520
|
-
- spec/fixtures/invalid.rb
|
521
|
-
- spec/fixtures/invalid_2.rb
|
522
|
-
- spec/fixtures/syntax_error.rb
|
523
|
-
- spec/fixtures/uses_external.rb
|
524
|
-
- spec/fixtures/uses_external_invalid.rb
|
525
|
-
- spec/fixtures/uses_external_namespace.rb
|
526
|
-
- spec/fixtures/valid.rb
|
527
|
-
- spec/ruby-lint/analysis/argument_amount_spec.rb
|
528
|
-
- spec/ruby-lint/analysis/base_spec.rb
|
529
|
-
- spec/ruby-lint/analysis/pedantics_spec.rb
|
530
|
-
- spec/ruby-lint/analysis/shadowing_variables_spec.rb
|
531
|
-
- spec/ruby-lint/analysis/undefined_methods_spec.rb
|
532
|
-
- spec/ruby-lint/analysis/undefined_variables_spec.rb
|
533
|
-
- spec/ruby-lint/analysis/unused_variables_spec.rb
|
534
|
-
- spec/ruby-lint/analysis/useless_equality_checks_spec.rb
|
535
|
-
- spec/ruby-lint/ast/node_spec.rb
|
536
|
-
- spec/ruby-lint/cache_entry_spec.rb
|
537
|
-
- spec/ruby-lint/cache_spec.rb
|
538
|
-
- spec/ruby-lint/cli/analyze_spec.rb
|
539
|
-
- spec/ruby-lint/configuration_spec.rb
|
540
|
-
- spec/ruby-lint/constant_loader_spec.rb
|
541
|
-
- spec/ruby-lint/constant_path.rb
|
542
|
-
- spec/ruby-lint/definition/constant_proxy_spec.rb
|
543
|
-
- spec/ruby-lint/definition/dsl_spec.rb
|
544
|
-
- spec/ruby-lint/definition/registry_spec.rb
|
545
|
-
- spec/ruby-lint/definition/ruby_method_spec.rb
|
546
|
-
- spec/ruby-lint/definition/ruby_object_spec.rb
|
547
|
-
- spec/ruby-lint/definition_builder/primitive_spec.rb
|
548
|
-
- spec/ruby-lint/definition_builder/ruby_class_spec.rb
|
549
|
-
- spec/ruby-lint/definition_builder/ruby_method_spec.rb
|
550
|
-
- spec/ruby-lint/definition_builder/ruby_module_spec.rb
|
551
|
-
- spec/ruby-lint/definitions/argv_spec.rb
|
552
|
-
- spec/ruby-lint/definitions/env_spec.rb
|
553
|
-
- spec/ruby-lint/definitions/file_spec.rb
|
554
|
-
- spec/ruby-lint/definitions/fixnum_spec.rb
|
555
|
-
- spec/ruby-lint/definitions/io_spec.rb
|
556
|
-
- spec/ruby-lint/definitions/kernel_spec.rb
|
557
|
-
- spec/ruby-lint/definitions/range_spec.rb
|
558
|
-
- spec/ruby-lint/definitions/string_spec.rb
|
559
|
-
- spec/ruby-lint/docstring/mapping.rb
|
560
|
-
- spec/ruby-lint/docstring/parser_spec.rb
|
561
|
-
- spec/ruby-lint/extensions/string_spec.rb
|
562
|
-
- spec/ruby-lint/file_list_spec.rb
|
563
|
-
- spec/ruby-lint/file_loader_spec.rb
|
564
|
-
- spec/ruby-lint/file_scanner_spec.rb
|
565
|
-
- spec/ruby-lint/inspector_spec.rb
|
566
|
-
- spec/ruby-lint/iterator_spec.rb
|
567
|
-
- spec/ruby-lint/method_call/.gitkeep
|
568
|
-
- spec/ruby-lint/nested_stack_spec.rb
|
569
|
-
- spec/ruby-lint/node_hash_spec.rb
|
570
|
-
- spec/ruby-lint/parser_spec.rb
|
571
|
-
- spec/ruby-lint/presenter/json_spec.rb
|
572
|
-
- spec/ruby-lint/presenter/syntastic_spec.rb
|
573
|
-
- spec/ruby-lint/presenter/text_spec.rb
|
574
|
-
- spec/ruby-lint/report/entry_spec.rb
|
575
|
-
- spec/ruby-lint/report_spec.rb
|
576
|
-
- spec/ruby-lint/runner_spec.rb
|
577
|
-
- spec/ruby-lint/variable_predicates_spec.rb
|
578
|
-
- spec/ruby-lint/virtual_machine/alias_spec.rb
|
579
|
-
- spec/ruby-lint/virtual_machine/assignments/arrays_spec.rb
|
580
|
-
- spec/ruby-lint/virtual_machine/assignments/assignment_arguments_spec.rb
|
581
|
-
- spec/ruby-lint/virtual_machine/assignments/constants_spec.rb
|
582
|
-
- spec/ruby-lint/virtual_machine/assignments/hashes_spec.rb
|
583
|
-
- spec/ruby-lint/virtual_machine/assignments/optional_spec.rb
|
584
|
-
- spec/ruby-lint/virtual_machine/assignments/range_spec.rb
|
585
|
-
- spec/ruby-lint/virtual_machine/assignments/return_values_spec.rb
|
586
|
-
- spec/ruby-lint/virtual_machine/assignments/variables_spec.rb
|
587
|
-
- spec/ruby-lint/virtual_machine/associate_nodes_spec.rb
|
588
|
-
- spec/ruby-lint/virtual_machine/autoloading_spec.rb
|
589
|
-
- spec/ruby-lint/virtual_machine/blocks_spec.rb
|
590
|
-
- spec/ruby-lint/virtual_machine/classes/class_methods_spec.rb
|
591
|
-
- spec/ruby-lint/virtual_machine/classes/extending_spec.rb
|
592
|
-
- spec/ruby-lint/virtual_machine/classes/redefining_spec.rb
|
593
|
-
- spec/ruby-lint/virtual_machine/classes/sclass_spec.rb
|
594
|
-
- spec/ruby-lint/virtual_machine/classes/scoping_spec.rb
|
595
|
-
- spec/ruby-lint/virtual_machine/complex/rails_spec.rb
|
596
|
-
- spec/ruby-lint/virtual_machine/complex/rcap_spec.rb
|
597
|
-
- spec/ruby-lint/virtual_machine/complex/slop_spec.rb
|
598
|
-
- spec/ruby-lint/virtual_machine/constants_spec.rb
|
599
|
-
- spec/ruby-lint/virtual_machine/for_spec.rb
|
600
|
-
- spec/ruby-lint/virtual_machine/freeze_spec.rb
|
601
|
-
- spec/ruby-lint/virtual_machine/global_variables_spec.rb
|
602
|
-
- spec/ruby-lint/virtual_machine/inherit_kernel_spec.rb
|
603
|
-
- spec/ruby-lint/virtual_machine/interpolation_spec.rb
|
604
|
-
- spec/ruby-lint/virtual_machine/location_spec.rb
|
605
|
-
- spec/ruby-lint/virtual_machine/method_call_tracking_spec.rb
|
606
|
-
- spec/ruby-lint/virtual_machine/methods/attr_spec.rb
|
607
|
-
- spec/ruby-lint/virtual_machine/methods/calls_spec.rb
|
608
|
-
- spec/ruby-lint/virtual_machine/methods/define_method_spec.rb
|
609
|
-
- spec/ruby-lint/virtual_machine/methods/defining_spec.rb
|
610
|
-
- spec/ruby-lint/virtual_machine/methods/docstrings_spec.rb
|
611
|
-
- spec/ruby-lint/virtual_machine/methods/exporting_spec.rb
|
612
|
-
- spec/ruby-lint/virtual_machine/methods/kernel_spec.rb
|
613
|
-
- spec/ruby-lint/virtual_machine/methods/parameters_spec.rb
|
614
|
-
- spec/ruby-lint/virtual_machine/methods/patching_spec.rb
|
615
|
-
- spec/ruby-lint/virtual_machine/methods/scoping_spec.rb
|
616
|
-
- spec/ruby-lint/virtual_machine/methods/square_bracket_spec.rb
|
617
|
-
- spec/ruby-lint/virtual_machine/methods/visibility_spec.rb
|
618
|
-
- spec/ruby-lint/virtual_machine/modules_spec.rb
|
619
|
-
- spec/ruby-lint/virtual_machine/reference_amount_spec.rb
|
620
|
-
- spec/ruby-lint/virtual_machine/self_spec.rb
|
621
|
-
- spec/ruby-lint/virtual_machine/unused_spec.rb
|
622
|
-
- spec/spec_helper.rb
|
623
|
-
- spec/support/building.rb
|
624
|
-
- spec/support/coveralls.rb
|
625
|
-
- spec/support/definitions.rb
|
626
|
-
- spec/support/fixtures.rb
|
627
|
-
- spec/support/parsing.rb
|
628
|
-
- spec/support/simplecov.rb
|
629
|
-
- spec/support/versions.rb
|
630
|
-
- task/build.rake
|
631
|
-
- task/checksum.rake
|
632
|
-
- task/coverage.rake
|
633
|
-
- task/doc.rake
|
634
|
-
- task/generate.rake
|
635
|
-
- task/graphviz.rake
|
636
|
-
- task/manifest.rake
|
637
|
-
- task/tag.rake
|
638
|
-
- task/test.rake
|
639
|
-
- task/todo.rake
|
640
|
-
- task/travis.rake
|
641
466
|
homepage: https://github.com/yorickpeterse/ruby-lint/
|
642
467
|
licenses:
|
643
468
|
- MIT
|
@@ -658,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
658
483
|
version: '0'
|
659
484
|
requirements: []
|
660
485
|
rubyforge_project:
|
661
|
-
rubygems_version: 2.2.
|
486
|
+
rubygems_version: 2.2.2
|
662
487
|
signing_key:
|
663
488
|
specification_version: 4
|
664
489
|
summary: A linter and static code analysis tool for Ruby.
|