ruby-lint 0.0.1a → 0.0.1a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.yardopts +1 -1
  2. data/MANIFEST +65 -62
  3. data/README.md +114 -13
  4. data/bin/ruby-lint +6 -0
  5. data/lib/ruby-lint.rb +36 -0
  6. data/lib/{rlint → ruby-lint}/analyze/coding_style.rb +32 -32
  7. data/lib/{rlint → ruby-lint}/analyze/definitions.rb +13 -13
  8. data/lib/{rlint → ruby-lint}/analyze/method_validation.rb +5 -5
  9. data/lib/{rlint → ruby-lint}/analyze/shadowing_variables.rb +5 -5
  10. data/lib/{rlint → ruby-lint}/analyze/undefined_variables.rb +7 -7
  11. data/lib/{rlint → ruby-lint}/analyze/unused_variables.rb +6 -6
  12. data/lib/{rlint → ruby-lint}/callback.rb +11 -11
  13. data/lib/{rlint → ruby-lint}/cli.rb +17 -17
  14. data/lib/{rlint → ruby-lint}/constant_importer.rb +18 -8
  15. data/lib/{rlint → ruby-lint}/definition.rb +10 -10
  16. data/lib/{rlint → ruby-lint}/formatter/text.rb +6 -6
  17. data/lib/{rlint → ruby-lint}/helper/definition_resolver.rb +11 -11
  18. data/lib/{rlint → ruby-lint}/helper/scoping.rb +14 -14
  19. data/lib/{rlint → ruby-lint}/iterator.rb +22 -22
  20. data/lib/{rlint → ruby-lint}/options.rb +9 -9
  21. data/lib/{rlint → ruby-lint}/parser.rb +111 -111
  22. data/lib/{rlint → ruby-lint}/parser_error.rb +3 -3
  23. data/lib/{rlint → ruby-lint}/report.rb +8 -8
  24. data/lib/{rlint → ruby-lint}/token/assignment_token.rb +4 -4
  25. data/lib/{rlint → ruby-lint}/token/begin_rescue_token.rb +7 -7
  26. data/lib/{rlint → ruby-lint}/token/block_token.rb +12 -3
  27. data/lib/{rlint → ruby-lint}/token/case_token.rb +5 -5
  28. data/lib/{rlint → ruby-lint}/token/class_token.rb +3 -3
  29. data/lib/{rlint → ruby-lint}/token/method_definition_token.rb +8 -8
  30. data/lib/{rlint → ruby-lint}/token/method_token.rb +9 -7
  31. data/lib/{rlint → ruby-lint}/token/parameters_token.rb +6 -6
  32. data/lib/{rlint → ruby-lint}/token/regexp_token.rb +2 -2
  33. data/lib/{rlint → ruby-lint}/token/statement_token.rb +6 -6
  34. data/lib/{rlint → ruby-lint}/token/token.rb +8 -6
  35. data/lib/{rlint → ruby-lint}/token/variable_token.rb +3 -3
  36. data/lib/ruby-lint/version.rb +3 -0
  37. data/ruby-lint.gemspec +5 -5
  38. data/spec/benchmarks/memory.rb +7 -7
  39. data/spec/benchmarks/parse_parser.rb +5 -5
  40. data/spec/fixtures/stdlib/un.rb +348 -0
  41. data/spec/helper.rb +3 -1
  42. data/spec/{rlint → ruby-lint}/analyze/coding_style.rb +30 -30
  43. data/spec/ruby-lint/analyze/complex/un.rb +29 -0
  44. data/spec/{rlint → ruby-lint}/analyze/definitions/classes.rb +25 -25
  45. data/spec/{rlint → ruby-lint}/analyze/definitions/methods.rb +22 -22
  46. data/spec/{rlint → ruby-lint}/analyze/definitions/modules.rb +42 -42
  47. data/spec/{rlint → ruby-lint}/analyze/definitions/variables.rb +27 -27
  48. data/spec/{rlint → ruby-lint}/analyze/method_validation.rb +31 -31
  49. data/spec/{rlint → ruby-lint}/analyze/shadowing_variables.rb +6 -6
  50. data/spec/{rlint → ruby-lint}/analyze/undefined_variables.rb +37 -37
  51. data/spec/{rlint → ruby-lint}/analyze/unused_variables.rb +21 -21
  52. data/spec/{rlint → ruby-lint}/callback.rb +7 -7
  53. data/spec/{rlint → ruby-lint}/constant_importer.rb +6 -6
  54. data/spec/{rlint → ruby-lint}/definition.rb +25 -25
  55. data/spec/{rlint → ruby-lint}/formatter/text.rb +4 -4
  56. data/spec/{rlint → ruby-lint}/iterator.rb +38 -38
  57. data/spec/{rlint → ruby-lint}/parser/arrays.rb +28 -28
  58. data/spec/{rlint → ruby-lint}/parser/classes.rb +23 -23
  59. data/spec/{rlint → ruby-lint}/parser/errors.rb +4 -4
  60. data/spec/{rlint → ruby-lint}/parser/hashes.rb +24 -24
  61. data/spec/{rlint → ruby-lint}/parser/methods.rb +50 -50
  62. data/spec/{rlint → ruby-lint}/parser/modules.rb +8 -8
  63. data/spec/{rlint → ruby-lint}/parser/objects.rb +8 -8
  64. data/spec/{rlint → ruby-lint}/parser/operators.rb +14 -14
  65. data/spec/{rlint → ruby-lint}/parser/procs.rb +26 -26
  66. data/spec/{rlint → ruby-lint}/parser/ranges.rb +9 -9
  67. data/spec/{rlint → ruby-lint}/parser/regexp.rb +5 -5
  68. data/spec/{rlint → ruby-lint}/parser/scalars.rb +17 -17
  69. data/spec/{rlint → ruby-lint}/parser/statements.rb +94 -94
  70. data/spec/{rlint → ruby-lint}/parser/variables.rb +37 -37
  71. data/spec/{rlint → ruby-lint}/report.rb +4 -4
  72. data/task/manifest.rake +8 -0
  73. data/task/test.rake +1 -1
  74. metadata +69 -66
  75. data/bin/rlint +0 -6
  76. data/lib/rlint.rb +0 -36
  77. data/lib/rlint/version.rb +0 -3
@@ -1,6 +1,6 @@
1
- module Rlint
1
+ module RubyLint
2
2
  ##
3
- # Exception class that's raised when the parser {Rlint::Parser} detects
3
+ # Exception class that's raised when the parser {RubyLint::Parser} detects
4
4
  # syntax errors.
5
5
  #
6
6
  class ParserError < SyntaxError
@@ -39,4 +39,4 @@ module Rlint
39
39
  super(message)
40
40
  end
41
41
  end # ParserError
42
- end # Rlint
42
+ end # RubyLint
@@ -1,7 +1,7 @@
1
- module Rlint
1
+ module RubyLint
2
2
  ##
3
- # {Rlint::Report} is a class used for storing error messages, warnings and
4
- # informational messages about code processed by {Rlint::Iterator} and
3
+ # {RubyLint::Report} is a class used for storing error messages, warnings and
4
+ # informational messages about code processed by {RubyLint::Iterator} and
5
5
  # individual callback classes.
6
6
  #
7
7
  # The process of adding data to a report involves two steps:
@@ -11,19 +11,19 @@ module Rlint
11
11
  #
12
12
  # The first step is done by creating a new instance of this class and
13
13
  # defining a list of level names in the constructor's second parameter. The
14
- # following levels are used by Rlint itself:
14
+ # following levels are used by RubyLint itself:
15
15
  #
16
16
  # * `:error`
17
17
  # * `:warning`
18
18
  # * `:info`
19
19
  #
20
- # The second step is done by calling {Rlint::Report#add}. This method is used
20
+ # The second step is done by calling {RubyLint::Report#add}. This method is used
21
21
  # to add data for a specific level. If this level is disabled the data is not
22
22
  # added to the report.
23
23
  #
24
24
  # A basic example of this is the following:
25
25
  #
26
- # report = Rlint::Report.new('test_file.rb', [:error])
26
+ # report = RubyLint::Report.new('test_file.rb', [:error])
27
27
  #
28
28
  # report.add(:error, 'This is an error message', 1, 0)
29
29
  #
@@ -67,7 +67,7 @@ module Rlint
67
67
  # to.
68
68
  # @param [Array] levels The message levels to use for this report.
69
69
  #
70
- def initialize(file = '(rlint)', levels = DEFAULT_LEVELS)
70
+ def initialize(file = '(ruby-lint)', levels = DEFAULT_LEVELS)
71
71
  @file = file
72
72
  @levels = levels
73
73
  @messages = {}
@@ -95,4 +95,4 @@ module Rlint
95
95
  }
96
96
  end
97
97
  end # Report
98
- end # Rlint
98
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class that is used whenever a value is assigned to a variable,
@@ -9,7 +9,7 @@ module Rlint
9
9
  # The object receiver, set when a value is assigned to an object
10
10
  # attribute.
11
11
  #
12
- # @return [Rlint::Token::Token]
12
+ # @return [RubyLint::Token::Token]
13
13
  #
14
14
  attr_accessor :receiver
15
15
 
@@ -22,7 +22,7 @@ module Rlint
22
22
  attr_accessor :operator
23
23
 
24
24
  ##
25
- # @see Rlint::Token::Token#initialize
25
+ # @see RubyLint::Token::Token#initialize
26
26
  #
27
27
  def initialize(*args)
28
28
  super
@@ -43,4 +43,4 @@ module Rlint
43
43
  end
44
44
  end # AssignmentToken
45
45
  end # Token
46
- end # Rlint
46
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class used for storing information about begin/rescue/ensure
@@ -7,7 +7,7 @@ module Rlint
7
7
  class BeginRescueToken < Token
8
8
  ##
9
9
  # Array of rescue statements. Each item is an instance of
10
- # {Rlint::Token::StatementToken}.
10
+ # {RubyLint::Token::StatementToken}.
11
11
  #
12
12
  # @return [Array]
13
13
  #
@@ -16,19 +16,19 @@ module Rlint
16
16
  ##
17
17
  # Attribute containing details about the ensure statement.
18
18
  #
19
- # @return [Rlint::Token::StatementToken]
19
+ # @return [RubyLint::Token::StatementToken]
20
20
  #
21
21
  attr_accessor :ensure
22
22
 
23
23
  ##
24
24
  # Attribute containing details about the else statement.
25
25
  #
26
- # @return [Rlint::Token::StatementToken]
26
+ # @return [RubyLint::Token::StatementToken]
27
27
  #
28
28
  attr_accessor :else
29
29
 
30
30
  ##
31
- # @see Rlint::Token#initialize
31
+ # @see RubyLint::Token#initialize
32
32
  #
33
33
  def initialize(*args)
34
34
  @type = :begin_rescue
@@ -37,7 +37,7 @@ module Rlint
37
37
  end
38
38
 
39
39
  ##
40
- # @see Rlint::Token::Token#child_nodes
40
+ # @see RubyLint::Token::Token#child_nodes
41
41
  #
42
42
  def child_nodes
43
43
  nodes = [@rescue]
@@ -54,4 +54,4 @@ module Rlint
54
54
  end
55
55
  end # BeginRescueToken
56
56
  end # Token
57
- end # Rlint
57
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class used for storing information about blocks/procs.
@@ -9,9 +9,18 @@ module Rlint
9
9
  ##
10
10
  # The parameters of the block.
11
11
  #
12
- # @return [Rlint::Token::ParametersToken]
12
+ # @return [RubyLint::Token::ParametersToken]
13
13
  #
14
14
  attr_accessor :parameters
15
+
16
+ ##
17
+ # @see RubyLint::Token::Token#initialize
18
+ #
19
+ def initialize(*args)
20
+ super
21
+
22
+ @parameters = ParametersToken.new unless @parameters
23
+ end
15
24
  end
16
25
  end # Token
17
- end # Rlint
26
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class containing details about a case statement.
@@ -15,12 +15,12 @@ module Rlint
15
15
  ##
16
16
  # Token containing details about the `else` statement.
17
17
  #
18
- # @return [Rlint::Token::StatementToken]
18
+ # @return [RubyLint::Token::StatementToken]
19
19
  #
20
20
  attr_accessor :else
21
21
 
22
22
  ##
23
- # @see Rlint::Token#initialize
23
+ # @see RubyLint::Token#initialize
24
24
  #
25
25
  def initialize(*args)
26
26
  @when = []
@@ -30,7 +30,7 @@ module Rlint
30
30
  end
31
31
 
32
32
  ##
33
- # @see Rlint::Token::Token#child_nodes
33
+ # @see RubyLint::Token::Token#child_nodes
34
34
  #
35
35
  def child_nodes
36
36
  nodes = super
@@ -41,4 +41,4 @@ module Rlint
41
41
  end
42
42
  end # CaseToken
43
43
  end # Token
44
- end # Rlint
44
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class used for storing data about classes.
@@ -12,7 +12,7 @@ module Rlint
12
12
  attr_accessor :parent
13
13
 
14
14
  ##
15
- # @see Rlint::Token::Token#initialize
15
+ # @see RubyLint::Token::Token#initialize
16
16
  #
17
17
  def initialize(*args)
18
18
  super
@@ -21,4 +21,4 @@ module Rlint
21
21
  end
22
22
  end # ClassToken
23
23
  end # Token
24
- end # Rlint
24
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class used for storing data about a newly defined method.
@@ -10,21 +10,21 @@ module Rlint
10
10
  # The object the method is defined on, only set when this is explicitly
11
11
  # stated.
12
12
  #
13
- # @return [Rlint::Token::Token]
13
+ # @return [RubyLint::Token::Token]
14
14
  #
15
15
  attr_accessor :receiver
16
16
 
17
17
  ##
18
18
  # The operator that was used to separate the receiver and method name.
19
19
  #
20
- # @return [Rlint::Token::Token]
20
+ # @return [RubyLint::Token::Token]
21
21
  #
22
22
  attr_accessor :operator
23
23
 
24
24
  ##
25
25
  # The parameters of the method.
26
26
  #
27
- # @return [Rlint::Token::ParametersToken]
27
+ # @return [RubyLint::Token::ParametersToken]
28
28
  #
29
29
  attr_accessor :parameters
30
30
 
@@ -37,7 +37,7 @@ module Rlint
37
37
  attr_accessor :visibility
38
38
 
39
39
  ##
40
- # @see Rlint::Token::Token#initialize
40
+ # @see RubyLint::Token::Token#initialize
41
41
  #
42
42
  def initialize(*args)
43
43
  @parameters = []
@@ -47,18 +47,18 @@ module Rlint
47
47
  super
48
48
 
49
49
  # Ensure that the parameters attribute always contains an instance of
50
- # `Rlint::Token::ParametersToken`.
50
+ # `RubyLint::Token::ParametersToken`.
51
51
  unless @parameters.class == ParametersToken
52
52
  @parameters = ParametersToken.new
53
53
  end
54
54
  end
55
55
 
56
56
  ##
57
- # @see Rlint::Token::Token#child_nodes
57
+ # @see RubyLint::Token::Token#child_nodes
58
58
  #
59
59
  def child_nodes
60
60
  return @parameters.child_nodes + super
61
61
  end
62
62
  end # MethodDefinitionToken
63
63
  end # Token
64
- end # Rlint
64
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class used for storing methods, their parameters, body, etc.
@@ -10,7 +10,7 @@ module Rlint
10
10
  # The receiver of the method call, if any.
11
11
  #
12
12
  # @since 2012-08-05
13
- # @return [Rlint::Token::Token]
13
+ # @return [RubyLint::Token::Token]
14
14
  #
15
15
  attr_accessor :receiver
16
16
 
@@ -26,7 +26,7 @@ module Rlint
26
26
  # Array of tokens for the method parameters.
27
27
  #
28
28
  # @since 2012-07-29
29
- # @return [Rlint::Token::Parameters]
29
+ # @return [RubyLint::Token::Parameters]
30
30
  #
31
31
  attr_accessor :parameters
32
32
 
@@ -34,25 +34,27 @@ module Rlint
34
34
  # Token containing details about the block passed to the method.
35
35
  #
36
36
  # @since 2012-08-05
37
- # @return [Rlint::Token::BlockToken]
37
+ # @return [RubyLint::Token::BlockToken]
38
38
  #
39
39
  attr_accessor :block
40
40
 
41
41
  ##
42
- # @see Rlint::Token::Token#initialize
42
+ # @see RubyLint::Token::Token#initialize
43
43
  #
44
44
  def initialize(*args)
45
45
  @type = :method
46
46
 
47
47
  super
48
+
49
+ @parameters = ParametersToken.new unless @parameters
48
50
  end
49
51
 
50
52
  ##
51
- # @see Rlint::Token::Token#child_nodes
53
+ # @see RubyLint::Token::Token#child_nodes
52
54
  #
53
55
  def child_nodes
54
56
  return super << @parameters << [@receiver] << [@block]
55
57
  end
56
58
  end # MethodToken
57
59
  end # Token
58
- end # Rlint
60
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class that contains details about the parameters of a method.
@@ -23,7 +23,7 @@ module Rlint
23
23
  ##
24
24
  # The rest parameter (if any).
25
25
  #
26
- # @return [Rlint::Token::Token]
26
+ # @return [RubyLint::Token::Token]
27
27
  #
28
28
  attr_accessor :rest
29
29
 
@@ -37,12 +37,12 @@ module Rlint
37
37
  ##
38
38
  # The block parameter (if any).
39
39
  #
40
- # @return [Rlint::Token::Token]
40
+ # @return [RubyLint::Token::Token]
41
41
  #
42
42
  attr_accessor :block
43
43
 
44
44
  ##
45
- # @see Rlint::Token::Token#initialize
45
+ # @see RubyLint::Token::Token#initialize
46
46
  #
47
47
  def initialize(*args)
48
48
  @optional = []
@@ -53,7 +53,7 @@ module Rlint
53
53
  end
54
54
 
55
55
  ##
56
- # @see Rlint::Token::Token#child_nodes
56
+ # @see RubyLint::Token::Token#child_nodes
57
57
  #
58
58
  def child_nodes
59
59
  nodes = super
@@ -96,4 +96,4 @@ module Rlint
96
96
  end
97
97
  end # ParametersToken
98
98
  end # Token
99
- end # Rlint
99
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class for storing information about regular expressions.
@@ -12,4 +12,4 @@ module Rlint
12
12
  attr_accessor :modes
13
13
  end # RegexpToken
14
14
  end # Token
15
- end # Rlint
15
+ end # RubyLint
@@ -1,4 +1,4 @@
1
- module Rlint
1
+ module RubyLint
2
2
  module Token
3
3
  ##
4
4
  # Token class for storing information about statements such as `return`
@@ -10,14 +10,14 @@ module Rlint
10
10
  ##
11
11
  # The value of the statement in case of `if` and `elsif` statements.
12
12
  #
13
- # @return [Rlint::Token::Token|Array]
13
+ # @return [RubyLint::Token::Token|Array]
14
14
  #
15
15
  attr_accessor :statement
16
16
 
17
17
  ##
18
18
  # The content of the `else` statement.
19
19
  #
20
- # @return [Rlint::Token::StatementToken]
20
+ # @return [RubyLint::Token::StatementToken]
21
21
  #
22
22
  attr_accessor :else
23
23
 
@@ -29,7 +29,7 @@ module Rlint
29
29
  attr_accessor :elsif
30
30
 
31
31
  ##
32
- # @see Rlint::Token::Token#initialize
32
+ # @see RubyLint::Token::Token#initialize
33
33
  #
34
34
  def initialize(*args)
35
35
  @type = :statement
@@ -39,7 +39,7 @@ module Rlint
39
39
  end
40
40
 
41
41
  ##
42
- # @see Rlint::Token::Token#child_nodes
42
+ # @see RubyLint::Token::Token#child_nodes
43
43
  #
44
44
  def child_nodes
45
45
  nodes = []
@@ -66,4 +66,4 @@ module Rlint
66
66
  end
67
67
  end # StatementToken
68
68
  end # Token
69
- end # Rlint
69
+ end # RubyLint