Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated node_instance_methods method #1518

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions features/samples.feature
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Feature: Basic smell detection
RepeatedConditional: Inline::C tests '@@type_map.has_key? type' at least 3 times
TooManyConstants: Inline has 6 constants
TooManyInstanceVariables: Inline::C has at least 13 instance variables
TooManyMethods: Inline::C has at least 25 methods
TooManyMethods: Inline::C has at least 30 methods
TooManyStatements: File#self.write_with_backup has approx 6 statements
TooManyStatements: Inline#self.rootdir has approx 8 statements
TooManyStatements: Inline::C#build has approx 63 statements
Expand Down Expand Up @@ -144,7 +144,7 @@ Feature: Basic smell detection
TooManyConstants: OptionParser has 16 constants
TooManyInstanceVariables: OptionParser has at least 6 instance variables
TooManyInstanceVariables: OptionParser::Switch has at least 7 instance variables
TooManyMethods: OptionParser has at least 42 methods
TooManyMethods: OptionParser has at least 49 methods
TooManyStatements: OptionParser#complete has approx 6 statements
TooManyStatements: OptionParser#getopts has approx 18 statements
TooManyStatements: OptionParser#load has approx 6 statements
Expand Down Expand Up @@ -247,7 +247,7 @@ Feature: Basic smell detection
RepeatedConditional: RedCloth tests 'title' at least 4 times
SubclassedFromCoreClass: RedCloth inherits from core class 'String'
TooManyConstants: RedCloth has 45 constants
TooManyMethods: RedCloth has at least 44 methods
TooManyMethods: RedCloth has at least 50 methods
TooManyStatements: RedCloth#block_markdown_bq has approx 6 statements
TooManyStatements: RedCloth#block_textile_lists has approx 21 statements
TooManyStatements: RedCloth#block_textile_table has approx 19 statements
Expand Down
8 changes: 8 additions & 0 deletions lib/reek/ast/sexp_extensions/symbols.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@ def name
children.first
end

def ends_with_bang?
name[-1] == '!'
end

def full_name(outer)
"#{outer}##{name}"
end

def arg_names
[]
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/cli/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module CLI
# See {file:docs/Command-Line-Options.md} for details.
#
# @quality :reek:TooManyInstanceVariables { max_instance_variables: 13 }
# @quality :reek:TooManyMethods { max_methods: 18 }
# @quality :reek:TooManyMethods { max_methods: 32 }
# @quality :reek:Attribute { enabled: false }
#
class Options
Expand Down
7 changes: 0 additions & 7 deletions lib/reek/context/module_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ def instance_method_calls
end
end

#
# @deprecated use `defined_instance_methods` instead
#
def node_instance_methods
local_nodes(:def).to_a
end

def descriptively_commented?
CodeComment.new(comment: exp.leading_comment).descriptive?
end
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/context_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module Reek
# counting. Ideally `ContextBuilder` would only build up the context tree and leave the
# statement and reference counting to the contexts.
#
# @quality :reek:TooManyMethods { max_methods: 31 }
# @quality :reek:TooManyMethods { max_methods: 32 }
# @quality :reek:UnusedPrivateMethod { exclude: [ !ruby/regexp /process_/ ] }
# @quality :reek:DataClump
class ContextBuilder
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/smell_detectors/data_clump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def min_clump_size
end

def candidate_methods
@candidate_methods ||= context.node_instance_methods
@candidate_methods ||= context.defined_instance_methods.map(&:exp)
end

def candidate_clumps
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/smell_detectors/instance_variable_assumption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def sniff
private

def method_expressions
@method_expressions ||= context.node_instance_methods
@method_expressions ||= context.defined_instance_methods.map(&:exp)
end

def build_smell_warning(assumption)
Expand Down
4 changes: 2 additions & 2 deletions lib/reek/smell_detectors/missing_safe_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def self.contexts # :nodoc:
# s(:args), nil))
#
def sniff
context.node_instance_methods.select do |method_sexp|
context.defined_instance_methods.map(&:exp).select do |method_sexp|
missing_safe_method?(method_sexp)
end.map do |method_sexp|
name = method_sexp.name
Expand All @@ -69,7 +69,7 @@ def missing_safe_method?(method_sexp)
end

def version_without_bang_exists?(method_sexp)
context.node_instance_methods.find do |sexp_item|
context.defined_instance_methods.find do |sexp_item|
sexp_item.name.to_s == method_sexp.name_without_bang
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/reek/smell_detectors/too_many_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.default_config
#
def sniff
# TODO: Only checks instance methods!
actual = context.node_instance_methods.length
actual = context.defined_instance_methods.length
return [] if actual <= max_allowed_methods

[smell_warning(
Expand Down