ruby-lint 0.0.3 → 0.0.4
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.
- data.tar.gz.asc +14 -14
- data/.gitignore +1 -2
- data/.rubocop.yml +59 -0
- data/.travis.yml +3 -7
- data/.yardopts +2 -2
- data/Gemfile +4 -0
- data/MANIFEST +103 -67
- data/README.md +13 -31
- data/Rakefile +1 -6
- data/checksum/ruby-lint-0.0.3.gem.sha512 +1 -0
- data/debug/memory_usage.rb +14 -0
- data/debug/profile.rb +18 -0
- data/doc/architecture.md +14 -18
- data/doc/changelog.md +29 -0
- data/doc/code_analysis.md +12 -12
- data/doc/configuration.md +21 -50
- data/doc/graphviz/flow.dot +1 -1
- data/doc/images/flow.png +0 -0
- data/lib/ruby-lint.rb +33 -19
- data/lib/ruby-lint/analysis/argument_amount.rb +84 -0
- data/lib/ruby-lint/analysis/base.rb +132 -0
- data/lib/ruby-lint/analysis/confusing_variables.rb +26 -0
- data/lib/ruby-lint/analysis/pedantics.rb +36 -0
- data/lib/ruby-lint/analysis/shadowing_variables.rb +47 -0
- data/lib/ruby-lint/analysis/undefined_methods.rb +91 -0
- data/lib/ruby-lint/analysis/undefined_variables.rb +46 -0
- data/lib/ruby-lint/analysis/unused_variables.rb +49 -0
- data/lib/ruby-lint/ast/builder.rb +17 -0
- data/lib/ruby-lint/ast/node.rb +39 -0
- data/lib/ruby-lint/cli.rb +0 -19
- data/lib/ruby-lint/cli/analyze.rb +54 -28
- data/lib/ruby-lint/cli/ast.rb +21 -6
- data/lib/ruby-lint/cli/base.rb +0 -23
- data/lib/ruby-lint/configuration.rb +112 -42
- data/lib/ruby-lint/constant_loader.rb +10 -28
- data/lib/ruby-lint/default_names.rb +19 -0
- data/lib/ruby-lint/definition/constant_proxy.rb +56 -0
- data/lib/ruby-lint/definition/ruby_method.rb +21 -143
- data/lib/ruby-lint/definition/ruby_object.rb +142 -246
- data/lib/ruby-lint/definition_builder/base.rb +43 -0
- data/lib/ruby-lint/definition_builder/primitive.rb +39 -0
- data/lib/ruby-lint/definition_builder/ruby_array.rb +77 -0
- data/lib/ruby-lint/definition_builder/ruby_block.rb +34 -0
- data/lib/ruby-lint/definition_builder/ruby_class.rb +24 -0
- data/lib/ruby-lint/definition_builder/ruby_hash.rb +37 -0
- data/lib/ruby-lint/definition_builder/ruby_method.rb +84 -0
- data/lib/ruby-lint/definition_builder/ruby_module.rb +68 -0
- data/lib/ruby-lint/definition_generator.rb +41 -15
- data/lib/ruby-lint/definitions/core/arg0.rb +1 -1
- data/lib/ruby-lint/definitions/core/argf.rb +1 -1
- data/lib/ruby-lint/definitions/core/argument_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/argv.rb +1 -1
- data/lib/ruby-lint/definitions/core/array.rb +6 -6
- data/lib/ruby-lint/definitions/core/autoload.rb +2 -2
- data/lib/ruby-lint/definitions/core/basic_object.rb +3 -3
- data/lib/ruby-lint/definitions/core/bignum.rb +2 -2
- data/lib/ruby-lint/definitions/core/binding.rb +2 -2
- data/lib/ruby-lint/definitions/core/class.rb +2 -2
- data/lib/ruby-lint/definitions/core/comparable.rb +1 -1
- data/lib/ruby-lint/definitions/core/complex.rb +4 -4
- data/lib/ruby-lint/definitions/core/condition_variable.rb +2 -2
- data/lib/ruby-lint/definitions/core/continuation.rb +2 -2
- data/lib/ruby-lint/definitions/core/data.rb +2 -2
- data/lib/ruby-lint/definitions/core/date.rb +34 -34
- data/lib/ruby-lint/definitions/core/date_time.rb +26 -26
- data/lib/ruby-lint/definitions/core/default_record_separator.rb +1 -1
- data/lib/ruby-lint/definitions/core/digest.rb +14 -14
- data/lib/ruby-lint/definitions/core/dir.rb +34 -34
- data/lib/ruby-lint/definitions/core/encoding.rb +237 -237
- data/lib/ruby-lint/definitions/core/encoding_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/enumerable.rb +15 -15
- data/lib/ruby-lint/definitions/core/enumerator.rb +2 -2
- data/lib/ruby-lint/definitions/core/env.rb +1 -1
- data/lib/ruby-lint/definitions/core/eoferror.rb +2 -2
- data/lib/ruby-lint/definitions/core/erb.rb +22 -22
- data/lib/ruby-lint/definitions/core/errno.rb +525 -525
- data/lib/ruby-lint/definitions/core/etc.rb +6 -6
- data/lib/ruby-lint/definitions/core/exception.rb +2 -2
- data/lib/ruby-lint/definitions/core/false.rb +1 -1
- data/lib/ruby-lint/definitions/core/false_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/fatal_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/fiber.rb +2 -2
- data/lib/ruby-lint/definitions/core/fiber_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/file.rb +68 -68
- data/lib/ruby-lint/definitions/core/file_list.rb +2 -2
- data/lib/ruby-lint/definitions/core/file_test.rb +1 -1
- data/lib/ruby-lint/definitions/core/file_utils.rb +16 -16
- data/lib/ruby-lint/definitions/core/fixnum.rb +4 -4
- data/lib/ruby-lint/definitions/core/float.rb +16 -16
- data/lib/ruby-lint/definitions/core/float_domain_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/gc.rb +2 -2
- data/lib/ruby-lint/definitions/core/gem.rb +119 -119
- data/lib/ruby-lint/definitions/core/hash.rb +14 -14
- data/lib/ruby-lint/definitions/core/immediate_value.rb +1 -1
- data/lib/ruby-lint/definitions/core/index_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/integer.rb +2 -2
- data/lib/ruby-lint/definitions/core/interrupt.rb +2 -2
- data/lib/ruby-lint/definitions/core/io.rb +38 -38
- data/lib/ruby-lint/definitions/core/ioerror.rb +2 -2
- data/lib/ruby-lint/definitions/core/kernel.rb +3 -3
- data/lib/ruby-lint/definitions/core/key_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/load_error.rb +6 -6
- data/lib/ruby-lint/definitions/core/local_jump_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/main.rb +1 -1
- data/lib/ruby-lint/definitions/core/marshal.rb +35 -35
- data/lib/ruby-lint/definitions/core/match_data.rb +2 -2
- data/lib/ruby-lint/definitions/core/math.rb +7 -7
- data/lib/ruby-lint/definitions/core/memory_segmention_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/method.rb +2 -2
- data/lib/ruby-lint/definitions/core/module.rb +1 -1
- data/lib/ruby-lint/definitions/core/monitor.rb +4 -4
- data/lib/ruby-lint/definitions/core/monitor_mixin.rb +5 -5
- data/lib/ruby-lint/definitions/core/mutex.rb +2 -2
- data/lib/ruby-lint/definitions/core/name_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/nil.rb +1 -1
- data/lib/ruby-lint/definitions/core/nil_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/no_memory_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/no_method_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/not_implemented_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/numeric.rb +2 -2
- data/lib/ruby-lint/definitions/core/object.rb +2 -2
- data/lib/ruby-lint/definitions/core/object_space.rb +1 -1
- data/lib/ruby-lint/definitions/core/open_struct.rb +3 -3
- data/lib/ruby-lint/definitions/core/option_parser.rb +83 -83
- data/lib/ruby-lint/definitions/core/precision.rb +1 -1
- data/lib/ruby-lint/definitions/core/primitive_failure.rb +2 -2
- data/lib/ruby-lint/definitions/core/proc.rb +2 -2
- data/lib/ruby-lint/definitions/core/process.rb +29 -29
- data/lib/ruby-lint/definitions/core/psych.rb +149 -149
- data/lib/ruby-lint/definitions/core/queue.rb +2 -2
- data/lib/ruby-lint/definitions/core/rake.rb +117 -117
- data/lib/ruby-lint/definitions/core/rake_file_utils.rb +1 -1
- data/lib/ruby-lint/definitions/core/rakeversion.rb +1 -1
- data/lib/ruby-lint/definitions/core/random.rb +2 -2
- data/lib/ruby-lint/definitions/core/range.rb +4 -4
- data/lib/ruby-lint/definitions/core/range_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/rational.rb +2 -2
- data/lib/ruby-lint/definitions/core/rb_config.rb +3 -3
- data/lib/ruby-lint/definitions/core/regexp.rb +28 -28
- data/lib/ruby-lint/definitions/core/regexp_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/rubinius.rb +1057 -1057
- data/lib/ruby-lint/definitions/core/ruby_copyright.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_description.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_engine.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_lint.rb +9 -9
- data/lib/ruby-lint/definitions/core/ruby_patchlevel.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_platform.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_release_date.rb +1 -1
- data/lib/ruby-lint/definitions/core/ruby_version.rb +1 -1
- data/lib/ruby-lint/definitions/core/runtime_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/scan_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/script_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/security_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/shellwords.rb +1 -1
- data/lib/ruby-lint/definitions/core/signal.rb +3 -3
- data/lib/ruby-lint/definitions/core/signal_exception.rb +2 -2
- data/lib/ruby-lint/definitions/core/singleton.rb +2 -2
- data/lib/ruby-lint/definitions/core/sized_queue.rb +2 -2
- data/lib/ruby-lint/definitions/core/standard_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/stderr.rb +1 -1
- data/lib/ruby-lint/definitions/core/stdin.rb +1 -1
- data/lib/ruby-lint/definitions/core/stdout.rb +1 -1
- data/lib/ruby-lint/definitions/core/stop_iteration.rb +2 -2
- data/lib/ruby-lint/definitions/core/string.rb +21 -21
- data/lib/ruby-lint/definitions/core/string_io.rb +7 -7
- data/lib/ruby-lint/definitions/core/string_scanner.rb +4 -4
- data/lib/ruby-lint/definitions/core/struct.rb +20 -20
- data/lib/ruby-lint/definitions/core/syck.rb +4 -4
- data/lib/ruby-lint/definitions/core/symbol.rb +2 -2
- data/lib/ruby-lint/definitions/core/syntax_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_call_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_exit.rb +2 -2
- data/lib/ruby-lint/definitions/core/system_stack_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/thread.rb +6 -6
- data/lib/ruby-lint/definitions/core/thread_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/thread_group.rb +2 -2
- data/lib/ruby-lint/definitions/core/time.rb +3 -3
- data/lib/ruby-lint/definitions/core/toplevel_binding.rb +1 -1
- data/lib/ruby-lint/definitions/core/true.rb +1 -1
- data/lib/ruby-lint/definitions/core/true_class.rb +2 -2
- data/lib/ruby-lint/definitions/core/type_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/unbound_method.rb +2 -2
- data/lib/ruby-lint/definitions/core/unmarshalable.rb +1 -1
- data/lib/ruby-lint/definitions/core/unsupported_library_error.rb +2 -2
- data/lib/ruby-lint/definitions/core/weak_ref.rb +4 -4
- data/lib/ruby-lint/definitions/core/zero_division_error.rb +2 -2
- data/lib/ruby-lint/definitions/rails.rb +12 -0
- data/lib/ruby-lint/definitions/rails/abstract_controller.rb +335 -0
- data/lib/ruby-lint/definitions/rails/action_controller.rb +1244 -0
- data/lib/ruby-lint/definitions/rails/action_dispatch.rb +741 -0
- data/lib/ruby-lint/definitions/rails/action_mailer.rb +502 -0
- data/lib/ruby-lint/definitions/rails/action_pack.rb +16 -0
- data/lib/ruby-lint/definitions/rails/action_view.rb +898 -0
- data/lib/ruby-lint/definitions/rails/active_model.rb +437 -0
- data/lib/ruby-lint/definitions/rails/active_record.rb +2901 -0
- data/lib/ruby-lint/definitions/rails/active_support.rb +1963 -0
- data/lib/ruby-lint/definitions/rails/arel.rb +665 -0
- data/lib/ruby-lint/definitions/rails/rails.rb +452 -0
- data/lib/ruby-lint/definitions/rails/sprockets.rb +968 -0
- data/lib/ruby-lint/generated_constant.rb +33 -0
- data/lib/ruby-lint/helper/constant_paths.rb +30 -21
- data/lib/ruby-lint/inspector.rb +20 -2
- data/lib/ruby-lint/iterator.rb +11 -171
- data/lib/ruby-lint/nested_stack.rb +46 -0
- data/lib/ruby-lint/parser.rb +24 -806
- data/lib/ruby-lint/report.rb +2 -30
- data/lib/ruby-lint/report/entry.rb +2 -2
- data/lib/ruby-lint/runner.rb +81 -0
- data/lib/ruby-lint/template/definition.erb +12 -8
- data/lib/ruby-lint/variable_predicates.rb +16 -58
- data/lib/ruby-lint/version.rb +1 -1
- data/lib/ruby-lint/virtual_machine.rb +1044 -0
- data/ruby-lint.gemspec +17 -7
- data/spec/fixtures/complex/rails/basic_controller.rb +9 -0
- data/spec/fixtures/complex/rcap.rb +38 -0
- data/spec/fixtures/complex/slop.rb +680 -0
- data/spec/fixtures/config.yml +8 -0
- data/spec/fixtures/invalid.rb +3 -0
- data/spec/fixtures/invalid_2.rb +3 -0
- data/spec/fixtures/syntax_error.rb +1 -0
- data/spec/fixtures/valid.rb +3 -0
- data/spec/helper.rb +6 -0
- data/spec/ruby-lint/{analyze → analysis}/argument_amount.rb +7 -7
- data/spec/ruby-lint/analysis/confusing_variables.rb +46 -0
- data/spec/ruby-lint/analysis/pedantics.rb +43 -0
- data/spec/ruby-lint/{analyze → analysis}/shadowing_variables.rb +5 -5
- data/spec/ruby-lint/{analyze → analysis}/undefined_methods.rb +18 -18
- data/spec/ruby-lint/{analyze → analysis}/undefined_variables.rb +19 -25
- data/spec/ruby-lint/{analyze → analysis}/unused_variables.rb +29 -16
- data/spec/ruby-lint/ast/node.rb +33 -0
- data/spec/ruby-lint/cli/analyze.rb +31 -0
- data/spec/ruby-lint/cli/ast.rb +23 -0
- data/spec/ruby-lint/configuration.rb +45 -6
- data/spec/ruby-lint/definition/constant_proxy.rb +31 -0
- data/spec/ruby-lint/definition/dsl.rb +13 -20
- data/spec/ruby-lint/definition/ruby_method.rb +65 -148
- data/spec/ruby-lint/definition/ruby_object.rb +60 -96
- data/spec/ruby-lint/definition_builder/primitive.rb +62 -0
- data/spec/ruby-lint/definition_builder/ruby_class.rb +108 -0
- data/spec/ruby-lint/definition_builder/ruby_method.rb +53 -0
- data/spec/ruby-lint/definition_builder/ruby_module.rb +50 -0
- data/spec/ruby-lint/iterator.rb +40 -16
- data/spec/ruby-lint/nested_stack.rb +23 -0
- data/spec/ruby-lint/parser.rb +14 -0
- data/spec/ruby-lint/report.rb +0 -10
- data/spec/ruby-lint/report/entry.rb +8 -4
- data/spec/ruby-lint/runner.rb +32 -0
- data/spec/ruby-lint/virtual_machine/assignments/arrays.rb +87 -0
- data/spec/ruby-lint/virtual_machine/assignments/hashes.rb +52 -0
- data/spec/ruby-lint/virtual_machine/assignments/optional.rb +41 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/assignments/return_values.rb +11 -11
- data/spec/ruby-lint/virtual_machine/assignments/variables.rb +85 -0
- data/spec/ruby-lint/virtual_machine/associate_nodes.rb +17 -0
- data/spec/ruby-lint/virtual_machine/autoloading.rb +31 -0
- data/spec/ruby-lint/virtual_machine/blocks.rb +64 -0
- data/spec/ruby-lint/virtual_machine/classes/class_methods.rb +21 -0
- data/spec/ruby-lint/virtual_machine/classes/extending.rb +104 -0
- data/spec/ruby-lint/virtual_machine/classes/redefining.rb +24 -0
- data/spec/ruby-lint/virtual_machine/classes/sclass.rb +94 -0
- data/spec/ruby-lint/virtual_machine/classes/scoping.rb +60 -0
- data/spec/ruby-lint/virtual_machine/complex/rails.rb +18 -0
- data/spec/ruby-lint/virtual_machine/complex/rcap.rb +15 -0
- data/spec/ruby-lint/virtual_machine/complex/slop.rb +16 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/for.rb +2 -2
- data/spec/ruby-lint/virtual_machine/freeze.rb +13 -0
- data/spec/ruby-lint/virtual_machine/interpolation.rb +12 -0
- data/spec/ruby-lint/virtual_machine/methods/defining.rb +40 -0
- data/spec/ruby-lint/virtual_machine/methods/exporting.rb +19 -0
- data/spec/ruby-lint/virtual_machine/methods/parameters.rb +77 -0
- data/spec/ruby-lint/virtual_machine/methods/patching.rb +26 -0
- data/spec/ruby-lint/virtual_machine/methods/scoping.rb +63 -0
- data/spec/ruby-lint/virtual_machine/methods/visibility.rb +64 -0
- data/spec/ruby-lint/{definitions_builder → virtual_machine}/modules.rb +16 -16
- data/spec/ruby-lint/virtual_machine/reference_amount.rb +33 -0
- data/spec/ruby-lint/virtual_machine/unused.rb +17 -0
- data/spec/support/bacon.rb +13 -13
- data/spec/support/building.rb +23 -16
- data/spec/support/coveralls.rb +5 -0
- data/spec/support/fixtures.rb +20 -0
- data/spec/support/parsing.rb +3 -5
- data/spec/support/simplecov.rb +5 -3
- data/task/build.rake +1 -1
- data/task/cop.rake +11 -0
- data/task/generate.rake +40 -2
- data/task/profile.rake +27 -0
- data/task/todo.rake +6 -0
- data/task/travis.rake +7 -0
- metadata +160 -75
- metadata.gz.asc +14 -14
- data/doc/build/.gitkeep +0 -0
- data/lib/ruby-lint/analyze/argument_amount.rb +0 -73
- data/lib/ruby-lint/analyze/shadowing_variables.rb +0 -32
- data/lib/ruby-lint/analyze/undefined_methods.rb +0 -68
- data/lib/ruby-lint/analyze/undefined_variables.rb +0 -72
- data/lib/ruby-lint/analyze/unused_variables.rb +0 -48
- data/lib/ruby-lint/base.rb +0 -85
- data/lib/ruby-lint/definitions_builder.rb +0 -692
- data/lib/ruby-lint/helper/conversion.rb +0 -33
- data/lib/ruby-lint/helper/current_scope.rb +0 -98
- data/lib/ruby-lint/helper/methods.rb +0 -91
- data/lib/ruby-lint/node.rb +0 -107
- data/lib/ruby-lint/parser_error.rb +0 -30
- data/spec/ruby-lint/constant_loader.rb +0 -32
- data/spec/ruby-lint/definition/method_calls.rb +0 -26
- data/spec/ruby-lint/definitions_builder/assignments/arrays.rb +0 -71
- data/spec/ruby-lint/definitions_builder/assignments/hashes.rb +0 -65
- data/spec/ruby-lint/definitions_builder/assignments/objects.rb +0 -23
- data/spec/ruby-lint/definitions_builder/assignments/optional.rb +0 -22
- data/spec/ruby-lint/definitions_builder/assignments/variables.rb +0 -71
- data/spec/ruby-lint/definitions_builder/associate_nodes.rb +0 -17
- data/spec/ruby-lint/definitions_builder/blocks.rb +0 -40
- data/spec/ruby-lint/definitions_builder/classes.rb +0 -230
- data/spec/ruby-lint/definitions_builder/methods.rb +0 -147
- data/spec/ruby-lint/definitions_builder/reference_amount.rb +0 -31
- data/spec/ruby-lint/definitions_builder/unused.rb +0 -15
- data/spec/ruby-lint/node.rb +0 -38
- data/spec/ruby-lint/parser/assignments.rb +0 -225
- data/spec/ruby-lint/parser/classes.rb +0 -110
- data/spec/ruby-lint/parser/errors.rb +0 -12
- data/spec/ruby-lint/parser/metadata.rb +0 -17
- data/spec/ruby-lint/parser/method_definitions.rb +0 -111
- data/spec/ruby-lint/parser/methods.rb +0 -217
- data/spec/ruby-lint/parser/modules.rb +0 -70
- data/spec/ruby-lint/parser/operators.rb +0 -40
- data/spec/ruby-lint/parser/statements/begin.rb +0 -55
- data/spec/ruby-lint/parser/statements/case.rb +0 -34
- data/spec/ruby-lint/parser/statements/defined.rb +0 -11
- data/spec/ruby-lint/parser/statements/for.rb +0 -34
- data/spec/ruby-lint/parser/statements/if.rb +0 -46
- data/spec/ruby-lint/parser/statements/return.rb +0 -14
- data/spec/ruby-lint/parser/statements/super.rb +0 -49
- data/spec/ruby-lint/parser/statements/unless.rb +0 -42
- data/spec/ruby-lint/parser/statements/until.rb +0 -25
- data/spec/ruby-lint/parser/statements/while.rb +0 -25
- data/spec/ruby-lint/parser/statements/yield.rb +0 -18
- data/spec/ruby-lint/parser/types/arrays.rb +0 -47
- data/spec/ruby-lint/parser/types/booleans.rb +0 -11
- data/spec/ruby-lint/parser/types/constants.rb +0 -32
- data/spec/ruby-lint/parser/types/hashes.rb +0 -55
- data/spec/ruby-lint/parser/types/nil.rb +0 -7
- data/spec/ruby-lint/parser/types/numbers.rb +0 -11
- data/spec/ruby-lint/parser/types/procs.rb +0 -11
- data/spec/ruby-lint/parser/types/ranges.rb +0 -11
- data/spec/ruby-lint/parser/types/regexp.rb +0 -27
- data/spec/ruby-lint/parser/types/strings.rb +0 -44
- data/spec/ruby-lint/parser/types/symbols.rb +0 -15
- data/task/stdlib.rake +0 -23
data/Rakefile
CHANGED
|
@@ -3,7 +3,7 @@ require File.expand_path('../lib/ruby-lint/inspector', __FILE__)
|
|
|
3
3
|
require File.expand_path('../lib/ruby-lint/definition_generator', __FILE__)
|
|
4
4
|
|
|
5
5
|
require 'yaml'
|
|
6
|
-
require '
|
|
6
|
+
require 'bundler/gem_tasks'
|
|
7
7
|
require 'digest/sha2'
|
|
8
8
|
|
|
9
9
|
GEMSPEC = Gem::Specification.load('ruby-lint.gemspec')
|
|
@@ -12,9 +12,4 @@ Dir['./task/*.rake'].each do |task|
|
|
|
12
12
|
import(task)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
Gem::PackageTask.new(GEMSPEC) do |pkg|
|
|
16
|
-
pkg.need_tar = false
|
|
17
|
-
pkg.need_zip = false
|
|
18
|
-
end
|
|
19
|
-
|
|
20
15
|
task :default => :test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0e13075c8e7eae96846a0be8a77890c2f2a5f6748341a582805c5091ed926e828c09baff38327b2edbb8f40b3d16015226342a5a10a366ade668b5247fd47dd7
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'ruby-prof'
|
|
2
|
+
|
|
3
|
+
RubyProf.measure_mode = RubyProf::MEMORY
|
|
4
|
+
|
|
5
|
+
result = RubyProf.profile do
|
|
6
|
+
require_relative '../lib/ruby-lint'
|
|
7
|
+
require_relative '../lib/ruby-lint/definitions/rails'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
total = result.threads[0].total_time
|
|
11
|
+
total_kb = total.round(2)
|
|
12
|
+
total_mb = (total / 1024).round(2)
|
|
13
|
+
|
|
14
|
+
puts "Total memory usage: #{total_mb}MB (#{total_kb}KB)"
|
data/debug/profile.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'ruby-prof'
|
|
2
|
+
|
|
3
|
+
result = RubyProf.profile do
|
|
4
|
+
require_relative '../lib/ruby-lint'
|
|
5
|
+
require_relative '../lib/ruby-lint/definitions/rails'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
result.eliminate_methods!([
|
|
9
|
+
/Kernel#require/,
|
|
10
|
+
/Kernel#gem_original_require/,
|
|
11
|
+
/Module#module_eval/,
|
|
12
|
+
/^Gem/,
|
|
13
|
+
/^Parser/
|
|
14
|
+
])
|
|
15
|
+
|
|
16
|
+
printer = RubyProf::FlatPrinter.new(result)
|
|
17
|
+
|
|
18
|
+
printer.print(STDOUT)
|
data/doc/architecture.md
CHANGED
|
@@ -20,34 +20,28 @@ would look like the following:
|
|
|
20
20
|
|
|
21
21
|
(string "hello")
|
|
22
22
|
|
|
23
|
-
Each node is an instance of {RubyLint::Node}. Each node can contain a
|
|
24
|
-
child nodes. If one were to format the above S expression as an Array
|
|
25
|
-
the following:
|
|
23
|
+
Each node is an instance of {RubyLint::AST::Node}. Each node can contain a
|
|
24
|
+
number of child nodes. If one were to format the above S expression as an Array
|
|
25
|
+
you'd get the following:
|
|
26
26
|
|
|
27
27
|
[:string, ["hello"]]
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
The parser used by ruby-lint is the [parser gem][parser gem] and as such
|
|
30
|
+
ruby-lint can support various Ruby implementations and versions.
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
newer. Because of this ruby-lint will be unable to support Rubinius and Jruby
|
|
34
|
-
for the time being. In the future this parser will be replaced with something
|
|
35
|
-
that runs on all the common Ruby implementations.
|
|
32
|
+
## Virtual Machine
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
created that contains all the Ruby data of a block of Ruby code.
|
|
43
|
-
|
|
44
|
-
One can see the definitions builder as a very basic virtual machine.
|
|
34
|
+
The ruby-lint virtual machine is a stack based virtual machine used for
|
|
35
|
+
partially evaluating Ruby code in order to build definitions of method
|
|
36
|
+
definitions, class definitions, variable assignments and so on. For more
|
|
37
|
+
information on the internals of this class see the documentation of
|
|
38
|
+
{RubyLint::VirtualMachine}.
|
|
45
39
|
|
|
46
40
|
## Analysis
|
|
47
41
|
|
|
48
42
|
This is where the real work start. The analysis step consists out of various
|
|
49
43
|
Ruby classes of which each performs its own type of analysis. For example,
|
|
50
|
-
{RubyLint::
|
|
44
|
+
{RubyLint::Analysis::UndefinedMethods} checks for the use of undefined methods.
|
|
51
45
|
|
|
52
46
|
## Reports
|
|
53
47
|
|
|
@@ -61,3 +55,5 @@ as well as a message (e.g. an error message).
|
|
|
61
55
|
Presenters are classes tasked with the job of presenting a report. Currently
|
|
62
56
|
ruby-lint ships with a presenter that outputs a report in plain text as well as
|
|
63
57
|
one that outputs a report in JSON.
|
|
58
|
+
|
|
59
|
+
[parser gem]: https://github.com/whitequark/parser
|
data/doc/changelog.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @title Changelog
|
|
2
|
+
# Changelog
|
|
3
|
+
|
|
4
|
+
This document contains a short summary of the various releases of ruby-lint.
|
|
5
|
+
For a full list of commits included in each release see the corresponding Git
|
|
6
|
+
tags (named after the versions).
|
|
7
|
+
|
|
8
|
+
## 0.0.4 - 2013-07-14
|
|
9
|
+
|
|
10
|
+
Near total refactor of the entire project. New parser setup based on the
|
|
11
|
+
"parser" Gem instead of using a custom built parser built using Ripper. More
|
|
12
|
+
analysis classes, a more stable mechanism for building definitions, bug fixes
|
|
13
|
+
and a lot more.
|
|
14
|
+
|
|
15
|
+
This release (thanks to "parser") also introduces support for Jruby and
|
|
16
|
+
Rubinius (2.0/Git HEAD, 1.X is not supported).
|
|
17
|
+
|
|
18
|
+
## 0.0.3 - 2013-04-22
|
|
19
|
+
|
|
20
|
+
Lots of internal changes for tasks such as building definitions. Also included
|
|
21
|
+
a large set of bugfixes.
|
|
22
|
+
|
|
23
|
+
## 0.0.2 - 2012-11-15
|
|
24
|
+
|
|
25
|
+
Various changes to the old parser.
|
|
26
|
+
|
|
27
|
+
## 0.0.1 - 2012-11-13
|
|
28
|
+
|
|
29
|
+
First public release of ruby-lint.
|
data/doc/code_analysis.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
# Code Analysis
|
|
3
3
|
|
|
4
4
|
Code analysis in ruby-lint is done using a set of classes that extend
|
|
5
|
-
{RubyLint::
|
|
5
|
+
{RubyLint::Analysis::Base}. This base class provides various methods for easily
|
|
6
6
|
walking over an AST by using callback methods based on the node types. For
|
|
7
7
|
example, the callback method `on_string` is used before a `(string)` node is
|
|
8
8
|
processed. For more low level details see the API documentation of
|
|
9
|
-
{RubyLint::Iterator}.
|
|
9
|
+
{RubyLint::Iterator} and {RubyLint::Analysis::Base} (which extends the former).
|
|
10
10
|
|
|
11
11
|
For this guide we'll be creating an analysis class that checks for local
|
|
12
12
|
variables written in camelCase. Whenever it finds these variables a warning
|
|
@@ -15,7 +15,7 @@ instead.
|
|
|
15
15
|
|
|
16
16
|
At the most basic level this class looks like the following:
|
|
17
17
|
|
|
18
|
-
class CamelCaseVariables < RubyLint::
|
|
18
|
+
class CamelCaseVariables < RubyLint::Analysis::Base
|
|
19
19
|
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -26,7 +26,7 @@ adding errors and the likes.
|
|
|
26
26
|
To use this class you'll have to create an instance of it and call
|
|
27
27
|
{RubyLint::Iterator#iterate} and pass it an AST:
|
|
28
28
|
|
|
29
|
-
ast = RubyLint::Parser.new('exampleNumber = 10')
|
|
29
|
+
ast = RubyLint::Parser.new.parse('exampleNumber = 10')
|
|
30
30
|
iterator = CamelCaseVariables.new
|
|
31
31
|
|
|
32
32
|
iterator.iterate(ast)
|
|
@@ -42,13 +42,13 @@ Here X is the name of the node type. Methods that start with `on_` will be
|
|
|
42
42
|
executed before any child nodes (of the current node) are processed. Methods
|
|
43
43
|
that start with `after_` will be executed after the node and its child nodes
|
|
44
44
|
have been processed. Each callback method takes a single argument: an instance
|
|
45
|
-
of {RubyLint::Node} containing information about the current node.
|
|
45
|
+
of {RubyLint::AST::Node} containing information about the current node.
|
|
46
46
|
|
|
47
47
|
In the above example we only need an `on_` callback:
|
|
48
48
|
|
|
49
|
-
class CamelCaseVariables < RubyLint::
|
|
50
|
-
def
|
|
51
|
-
if node.
|
|
49
|
+
class CamelCaseVariables < RubyLint::Analysis::Base
|
|
50
|
+
def on_lvar(node)
|
|
51
|
+
if node.children[0].to_s =~ /[a-z][A-Z]/
|
|
52
52
|
warning('use snake_case for local variables', node)
|
|
53
53
|
end
|
|
54
54
|
end
|
|
@@ -72,15 +72,15 @@ use:
|
|
|
72
72
|
|
|
73
73
|
The full code of this exercise looks like the following:
|
|
74
74
|
|
|
75
|
-
class CamelCaseVariables < RubyLint::
|
|
76
|
-
def
|
|
77
|
-
if node.
|
|
75
|
+
class CamelCaseVariables < RubyLint::Analysis::Base
|
|
76
|
+
def on_lvar(node)
|
|
77
|
+
if node.children[0].to_s =~ /[a-z][A-Z]/
|
|
78
78
|
warning('use snake_case for local variables', node)
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
ast = RubyLint::Parser.new('exampleNumber = 10')
|
|
83
|
+
ast = RubyLint::Parser.new.parse('exampleNumber = 10')
|
|
84
84
|
report = RubyLint::Report.new
|
|
85
85
|
iterator = CamelCaseVariables.new(:report => report)
|
|
86
86
|
presenter = RubyLint::Presenter::Text.new
|
data/doc/configuration.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
The default configuration of ruby-lint should be suitable for most people.
|
|
5
5
|
However, depending on your code base you may get an usual amount of false
|
|
6
|
-
positives. In particular the class {RubyLint::
|
|
6
|
+
positives. In particular the class {RubyLint::Analysis::UndefinedMethods} can
|
|
7
7
|
produce a lot of false positives.
|
|
8
8
|
|
|
9
9
|
ruby-lint allows developers to customize the various parts of the tool such as
|
|
@@ -22,8 +22,8 @@ changes to stick around you'll want to use a configuration file instead.
|
|
|
22
22
|
When running the CLI ruby-lint will try to load one of the following two
|
|
23
23
|
configuration files:
|
|
24
24
|
|
|
25
|
-
* $PWD/ruby-lint.
|
|
26
|
-
* $HOME/.ruby-lint.
|
|
25
|
+
* $PWD/ruby-lint.yml
|
|
26
|
+
* $HOME/.ruby-lint.yml
|
|
27
27
|
|
|
28
28
|
Here `$PWD` refers to the current working directory and `$HOME` to the user's
|
|
29
29
|
home directory. If ruby-lint finds a configuration file in the current working
|
|
@@ -33,54 +33,25 @@ fallback.
|
|
|
33
33
|
|
|
34
34
|
## Configuring ruby-lint
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
YAML nonsense that gets in your way.
|
|
36
|
+
Configuration is done using simple YAML files with the following structure:
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
* `requires`: an Array of files to require before running ruby-lint
|
|
39
|
+
* `report_levels`: an Array of report levels to enable.
|
|
40
|
+
* `analysis_classes`: an Array of the human friendly names of the analysis
|
|
41
|
+
classes to enable.
|
|
42
|
+
* `presenter`: the human friendly name of the presenter to use.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
A basic example looks lik the following:
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
---
|
|
47
|
+
requires:
|
|
48
|
+
- ruby-lint/definitions/core/string
|
|
49
|
+
report_levels:
|
|
50
|
+
- error
|
|
51
|
+
analysis_classes:
|
|
52
|
+
- undefined_methods
|
|
53
|
+
- undefined_variables
|
|
54
|
+
presenter: json
|
|
47
55
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
To change the presenter to use you'd use the following:
|
|
51
|
-
|
|
52
|
-
RubyLint.configure do |config|
|
|
53
|
-
config.presenter = RubyLint::Presenter::JSON
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
Changing the analysis classes is done as following:
|
|
57
|
-
|
|
58
|
-
RubyLint.configure do |config|
|
|
59
|
-
# Only use the two classes listed below.
|
|
60
|
-
config.analysis = [
|
|
61
|
-
RubyLint::Analysis::UndefinedVariables,
|
|
62
|
-
RubyLint::Analysis::ShadowingVariables
|
|
63
|
-
]
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
And changing the reporting levels:
|
|
67
|
-
|
|
68
|
-
RubyLint.configure do |config|
|
|
69
|
-
config.report_levels = [:error]
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
Combined together this leads to the following configuration:
|
|
73
|
-
|
|
74
|
-
RubyLint.configure do |config|
|
|
75
|
-
config.presenter = RubyLint::Presenter::JSON
|
|
76
|
-
|
|
77
|
-
# Only use the two classes listed below.
|
|
78
|
-
config.analysis = [
|
|
79
|
-
RubyLint::Analysis::UndefinedVariables,
|
|
80
|
-
RubyLint::Analysis::ShadowingVariables
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
config.report_levels = [:error]
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
For more information see the documentation of {RubyLint::Configuration}.
|
|
56
|
+
If no value is given for a certain configuration option the default value(s)
|
|
57
|
+
will be used instead.
|
data/doc/graphviz/flow.dot
CHANGED
data/doc/images/flow.png
CHANGED
|
Binary file
|
data/lib/ruby-lint.rb
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
|
-
require '
|
|
2
|
-
require '
|
|
1
|
+
require 'parser'
|
|
2
|
+
require 'parser/current'
|
|
3
|
+
require 'yaml'
|
|
3
4
|
|
|
4
5
|
require_relative 'ruby-lint/extensions/string'
|
|
5
6
|
|
|
6
7
|
require_relative 'ruby-lint/variable_predicates'
|
|
7
|
-
require_relative 'ruby-lint/node'
|
|
8
|
+
require_relative 'ruby-lint/ast/node'
|
|
9
|
+
require_relative 'ruby-lint/ast/builder'
|
|
8
10
|
require_relative 'ruby-lint/parser'
|
|
9
|
-
require_relative 'ruby-lint/
|
|
11
|
+
require_relative 'ruby-lint/nested_stack'
|
|
12
|
+
|
|
13
|
+
require_relative 'ruby-lint/helper/constant_paths'
|
|
14
|
+
|
|
15
|
+
require_relative 'ruby-lint/definition_builder/base'
|
|
16
|
+
require_relative 'ruby-lint/definition_builder/ruby_module'
|
|
17
|
+
require_relative 'ruby-lint/definition_builder/ruby_class'
|
|
18
|
+
require_relative 'ruby-lint/definition_builder/ruby_method'
|
|
19
|
+
require_relative 'ruby-lint/definition_builder/ruby_array'
|
|
20
|
+
require_relative 'ruby-lint/definition_builder/ruby_hash'
|
|
21
|
+
require_relative 'ruby-lint/definition_builder/ruby_block'
|
|
22
|
+
require_relative 'ruby-lint/definition_builder/primitive'
|
|
23
|
+
|
|
10
24
|
require_relative 'ruby-lint/iterator'
|
|
11
|
-
require_relative 'ruby-lint/
|
|
25
|
+
require_relative 'ruby-lint/virtual_machine'
|
|
12
26
|
require_relative 'ruby-lint/constant_loader'
|
|
13
27
|
|
|
14
|
-
require_relative 'ruby-lint/configuration'
|
|
15
|
-
require_relative 'ruby-lint/version'
|
|
16
|
-
require_relative 'ruby-lint/base'
|
|
17
|
-
|
|
18
28
|
require_relative 'ruby-lint/definition/ruby_object'
|
|
19
29
|
require_relative 'ruby-lint/definition/ruby_method'
|
|
30
|
+
require_relative 'ruby-lint/definition/constant_proxy'
|
|
20
31
|
require_relative 'ruby-lint/definitions/core'
|
|
21
32
|
|
|
22
|
-
require_relative 'ruby-lint/
|
|
23
|
-
require_relative 'ruby-lint/
|
|
24
|
-
require_relative 'ruby-lint/
|
|
25
|
-
require_relative 'ruby-lint/
|
|
26
|
-
|
|
27
|
-
require_relative 'ruby-lint/
|
|
28
|
-
require_relative 'ruby-lint/
|
|
29
|
-
require_relative 'ruby-lint/
|
|
30
|
-
require_relative 'ruby-lint/analyze/undefined_methods'
|
|
31
|
-
require_relative 'ruby-lint/analyze/argument_amount'
|
|
33
|
+
require_relative 'ruby-lint/analysis/base'
|
|
34
|
+
require_relative 'ruby-lint/analysis/unused_variables'
|
|
35
|
+
require_relative 'ruby-lint/analysis/shadowing_variables'
|
|
36
|
+
require_relative 'ruby-lint/analysis/undefined_variables'
|
|
37
|
+
require_relative 'ruby-lint/analysis/undefined_methods'
|
|
38
|
+
require_relative 'ruby-lint/analysis/argument_amount'
|
|
39
|
+
require_relative 'ruby-lint/analysis/confusing_variables'
|
|
40
|
+
require_relative 'ruby-lint/analysis/pedantics'
|
|
32
41
|
|
|
33
42
|
require_relative 'ruby-lint/report'
|
|
34
43
|
require_relative 'ruby-lint/report/entry'
|
|
35
44
|
|
|
36
45
|
require_relative 'ruby-lint/presenter/text'
|
|
37
46
|
require_relative 'ruby-lint/presenter/json'
|
|
47
|
+
|
|
48
|
+
require_relative 'ruby-lint/configuration'
|
|
49
|
+
require_relative 'ruby-lint/default_names'
|
|
50
|
+
require_relative 'ruby-lint/runner'
|
|
51
|
+
require_relative 'ruby-lint/version'
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
module RubyLint
|
|
2
|
+
module Analysis
|
|
3
|
+
##
|
|
4
|
+
# The ArgumentAmount class is an analysis class that verifies the amount of
|
|
5
|
+
# arguments given with each method call and adds errors whenever an invalid
|
|
6
|
+
# amount was given.
|
|
7
|
+
#
|
|
8
|
+
class ArgumentAmount < Base
|
|
9
|
+
##
|
|
10
|
+
# @param [RubyLint::Node] node
|
|
11
|
+
#
|
|
12
|
+
def on_send(node)
|
|
13
|
+
receiver, name, args = *node
|
|
14
|
+
|
|
15
|
+
name = name.to_s
|
|
16
|
+
scope = current_scope
|
|
17
|
+
|
|
18
|
+
if receiver and vm.associations.key?(receiver)
|
|
19
|
+
scope = vm.associations[receiver]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
method = scope.lookup(scope.method_call_type, name)
|
|
23
|
+
|
|
24
|
+
return unless method
|
|
25
|
+
|
|
26
|
+
given = args ? args.children.length : 0
|
|
27
|
+
min, max = argument_range(method)
|
|
28
|
+
|
|
29
|
+
unless correct_argument_amount(min, max, given)
|
|
30
|
+
text = argument_text(method, given)
|
|
31
|
+
|
|
32
|
+
error(
|
|
33
|
+
"wrong number of arguments (expected #{text} but got #{given})",
|
|
34
|
+
node
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
##
|
|
42
|
+
# @param [Numeric] min
|
|
43
|
+
# @param [Numeric] max
|
|
44
|
+
# @param [Numeric] given
|
|
45
|
+
# @return [TrueClass|FalseClass]
|
|
46
|
+
#
|
|
47
|
+
def correct_argument_amount(min, max, given)
|
|
48
|
+
return given >= min && given <= max
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
##
|
|
52
|
+
# Returns a String that indicates the amount of required arguments.
|
|
53
|
+
#
|
|
54
|
+
# @param [RubyLint::Definition::RubyMethod] method
|
|
55
|
+
# @param [Numeric] given
|
|
56
|
+
# @return [String]
|
|
57
|
+
#
|
|
58
|
+
def argument_text(method, given)
|
|
59
|
+
min = method.amount(:arg)
|
|
60
|
+
opt = method.amount(:optarg)
|
|
61
|
+
|
|
62
|
+
return opt > 0 ? "#{min}..#{min + opt}" : min.to_s
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
##
|
|
66
|
+
# Returns the minimum and maximum amount of arguments for a method call.
|
|
67
|
+
#
|
|
68
|
+
# @param [RubyLint::Definition::RubyMethod] method
|
|
69
|
+
# @return [Array]
|
|
70
|
+
#
|
|
71
|
+
def argument_range(method)
|
|
72
|
+
min = method.amount(:arg)
|
|
73
|
+
|
|
74
|
+
if method.amount(:restarg) > 0
|
|
75
|
+
max = Float::INFINITY
|
|
76
|
+
else
|
|
77
|
+
max = min + method.amount(:optarg) + method.amount(:restarg)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
return min, max
|
|
81
|
+
end
|
|
82
|
+
end # ArgumentAmount
|
|
83
|
+
end # Analysis
|
|
84
|
+
end # RubyLint
|