From 3e1aa3dbb0201000e13c819b8ea4af25d6cd756e Mon Sep 17 00:00:00 2001 From: Kevin Rutherford Date: Sun, 21 Jun 2009 21:05:18 +0100 Subject: [PATCH] Added cucumber features for all standard code samples --- features/correct_smells.feature | 228 ++++++++++++++++++++++++++++++++ 1 file changed, 228 insertions(+) diff --git a/features/correct_smells.feature b/features/correct_smells.feature index 184e8c5fc..573d7123f 100644 --- a/features/correct_smells.feature +++ b/features/correct_smells.feature @@ -43,3 +43,231 @@ Feature: Basic smell detection Module#inline is controlled by argument options (Control Couple) """ + + Scenario: Correct smells from optparse.rb + When I run reek spec/slow/samples/optparse.rb + Then it should fail with exit status 2 + And it should report: + """ + "spec/slow/samples/optparse.rb" -- 117 warnings: + OptionParser has at least 59 methods (Large Class) + OptionParser#CompletingHash#match/block/block is nested (Nested Iterators) + OptionParser#Completion::complete calls candidates.size multiple times (Duplication) + OptionParser#Completion::complete calls k.id2name multiple times (Duplication) + OptionParser#Completion::complete has approx 22 statements (Long Method) + OptionParser#Completion::complete has the variable name 'k' (Uncommunicative Name) + OptionParser#Completion::complete has the variable name 'v' (Uncommunicative Name) + OptionParser#Completion::complete refers to candidates more than self (Feature Envy) + OptionParser#Completion::complete/block has the variable name 'k' (Uncommunicative Name) + OptionParser#Completion::complete/block has the variable name 'v' (Uncommunicative Name) + OptionParser#List#accept has the variable name 't' (Uncommunicative Name) + OptionParser#List#accept is controlled by argument pat (Control Couple) + OptionParser#List#accept refers to pat more than self (Feature Envy) + OptionParser#List#add_banner refers to opt more than self (Feature Envy) + OptionParser#List#complete has 4 parameters (Long Parameter List) + OptionParser#List#reject has the variable name 't' (Uncommunicative Name) + OptionParser#List#summarize refers to opt more than self (Feature Envy) + OptionParser#List#update has 5 parameters (Long Parameter List) + OptionParser#List#update has approx 6 statements (Long Method) + OptionParser#List#update has the variable name 'o' (Uncommunicative Name) + OptionParser#List#update is controlled by argument lopts (Control Couple) + OptionParser#List#update is controlled by argument sopts (Control Couple) + OptionParser#List#update/block has the variable name 'o' (Uncommunicative Name) + OptionParser#ParseError#set_option is controlled by argument eq (Control Couple) + OptionParser#Switch#NoArgument#parse is controlled by argument arg (Control Couple) + OptionParser#Switch#OptionalArgument#parse is controlled by argument arg (Control Couple) + OptionParser#Switch#PlacedArgument#parse has approx 6 statements (Long Method) + OptionParser#Switch#RequiredArgument#parse is controlled by argument arg (Control Couple) + OptionParser#Switch#add_banner has the variable name 's' (Uncommunicative Name) + OptionParser#Switch#conv_arg calls conv multiple times (Duplication) + OptionParser#Switch#initialize has 7 parameters (Long Parameter List) + OptionParser#Switch#parse_arg calls pattern multiple times (Duplication) + OptionParser#Switch#parse_arg calls s.length multiple times (Duplication) + OptionParser#Switch#parse_arg has approx 11 statements (Long Method) + OptionParser#Switch#parse_arg has the variable name 'm' (Uncommunicative Name) + OptionParser#Switch#parse_arg has the variable name 's' (Uncommunicative Name) + OptionParser#Switch#self.guess has the variable name 't' (Uncommunicative Name) + OptionParser#Switch#self.incompatible_argument_styles has the variable name 't' (Uncommunicative Name) + OptionParser#Switch#summarize calls (indent + l) multiple times (Duplication) + OptionParser#Switch#summarize calls arg multiple times (Duplication) + OptionParser#Switch#summarize calls left.collect multiple times (Duplication) + OptionParser#Switch#summarize calls left.collect { |s| s.length }.max multiple times (Duplication) + OptionParser#Switch#summarize calls left.collect { |s| s.length }.max.to_i multiple times (Duplication) + OptionParser#Switch#summarize calls left.shift multiple times (Duplication) + OptionParser#Switch#summarize calls left[-1] multiple times (Duplication) + OptionParser#Switch#summarize calls s.length multiple times (Duplication) + OptionParser#Switch#summarize has 5 parameters (Long Parameter List) + OptionParser#Switch#summarize has approx 25 statements (Long Method) + OptionParser#Switch#summarize has the variable name 'l' (Uncommunicative Name) + OptionParser#Switch#summarize has the variable name 'r' (Uncommunicative Name) + OptionParser#Switch#summarize has the variable name 's' (Uncommunicative Name) + OptionParser#Switch#summarize refers to left more than self (Feature Envy) + OptionParser#Switch#summarize/block has the variable name 's' (Uncommunicative Name) + OptionParser#Switch#summarize/block/block is nested (Nested Iterators) + OptionParser#block has the variable name 'f' (Uncommunicative Name) + OptionParser#block has the variable name 'k' (Uncommunicative Name) + OptionParser#block has the variable name 'o' (Uncommunicative Name) + OptionParser#block has the variable name 's' (Uncommunicative Name) + OptionParser#block is controlled by argument o (Control Couple) + OptionParser#block is controlled by argument s (Control Couple) + OptionParser#block/block has the variable name 's' (Uncommunicative Name) + OptionParser#block/block has the variable name 'v' (Uncommunicative Name) + OptionParser#block/block is controlled by argument pkg (Control Couple) + OptionParser#block/block is nested (Nested Iterators) + OptionParser#complete has 4 parameters (Long Parameter List) + OptionParser#complete/block/block is nested (Nested Iterators) + OptionParser#getopts calls result[opt] = false multiple times (Duplication) + OptionParser#getopts has approx 17 statements (Long Method) + OptionParser#getopts/block is controlled by argument val (Control Couple) + OptionParser#load/block has the variable name 's' (Uncommunicative Name) + OptionParser#make_switch calls (long << o = q.downcase) multiple times (Duplication) + OptionParser#make_switch calls (sdesc << "-#{q}") multiple times (Duplication) + OptionParser#make_switch calls default_style.guess(arg = a) multiple times (Duplication) + OptionParser#make_switch calls notwice(NilClass, klass, "type") multiple times (Duplication) + OptionParser#make_switch calls notwice(a ? (Object) : (TrueClass), klass, "type") multiple times (Duplication) + OptionParser#make_switch calls pattern.method(:convert) multiple times (Duplication) + OptionParser#make_switch calls pattern.method(:convert).to_proc multiple times (Duplication) + OptionParser#make_switch calls pattern.respond_to?(:convert) multiple times (Duplication) + OptionParser#make_switch calls q.downcase multiple times (Duplication) + OptionParser#make_switch calls search(:atype, FalseClass) multiple times (Duplication) + OptionParser#make_switch calls search(:atype, o) multiple times (Duplication) + OptionParser#make_switch has approx 68 statements (Long Method) + OptionParser#make_switch has the variable name 'a' (Uncommunicative Name) + OptionParser#make_switch has the variable name 'n' (Uncommunicative Name) + OptionParser#make_switch has the variable name 'o' (Uncommunicative Name) + OptionParser#make_switch has the variable name 'q' (Uncommunicative Name) + OptionParser#make_switch has the variable name 's' (Uncommunicative Name) + OptionParser#make_switch/block has the variable name 'a' (Uncommunicative Name) + OptionParser#make_switch/block has the variable name 'o' (Uncommunicative Name) + OptionParser#make_switch/block has the variable name 'q' (Uncommunicative Name) + OptionParser#make_switch/block/block has the variable name 'c' (Uncommunicative Name) + OptionParser#make_switch/block/block has the variable name 'o' (Uncommunicative Name) + OptionParser#make_switch/block/block has the variable name 'v' (Uncommunicative Name) + OptionParser#make_switch/block/block is nested (Nested Iterators) + OptionParser#make_switch/block/block/block is nested (Nested Iterators) + OptionParser#order calls argv[0] multiple times (Duplication) + OptionParser#order refers to argv more than self (Feature Envy) + OptionParser#parse calls argv[0] multiple times (Duplication) + OptionParser#parse refers to argv more than self (Feature Envy) + OptionParser#parse_in_order calls $!.set_option(arg, true) multiple times (Duplication) + OptionParser#parse_in_order calls cb.call(val) multiple times (Duplication) + OptionParser#parse_in_order calls raise($!.set_option(arg, true)) multiple times (Duplication) + OptionParser#parse_in_order calls raise(*exc) multiple times (Duplication) + OptionParser#parse_in_order calls setter.call(sw.switch_name, val) multiple times (Duplication) + OptionParser#parse_in_order calls sw.block multiple times (Duplication) + OptionParser#parse_in_order calls sw.switch_name multiple times (Duplication) + OptionParser#parse_in_order has approx 28 statements (Long Method) + OptionParser#parse_in_order/block is controlled by argument setter (Control Couple) + OptionParser#parse_in_order/block/block is nested (Nested Iterators) + OptionParser#parse_in_order/block/block/block is nested (Nested Iterators) + OptionParser#permute calls argv[0] multiple times (Duplication) + OptionParser#permute refers to argv more than self (Feature Envy) + OptionParser#search/block has the variable name 'k' (Uncommunicative Name) + OptionParser#summarize has 4 parameters (Long Parameter List) + OptionParser#summarize/block has the variable name 'l' (Uncommunicative Name) + OptionParser#ver has the variable name 'v' (Uncommunicative Name) + block has the variable name 'q' (Uncommunicative Name) + + """ + + Scenario: Correct smells from redcloth.rb + When I run reek spec/slow/samples/redcloth.rb + Then it should fail with exit status 2 + And it should report: + """ + "spec/slow/samples/redcloth.rb" -- 93 warnings: + RedCloth has at least 44 methods (Large Class) + RedCloth#block has the variable name 'a' (Uncommunicative Name) + RedCloth#block has the variable name 'b' (Uncommunicative Name) + RedCloth#block_markdown_atx refers to text more than self (Feature Envy) + RedCloth#block_markdown_bq has approx 6 statements (Long Method) + RedCloth#block_markdown_rule doesn't depend on instance state (Utility Function) + RedCloth#block_markdown_rule refers to text more than self (Feature Envy) + RedCloth#block_markdown_setext refers to text more than self (Feature Envy) + RedCloth#block_textile_lists calls (line_id - 1) multiple times (Duplication) + RedCloth#block_textile_lists calls depth.last multiple times (Duplication) + RedCloth#block_textile_lists calls depth.last.length multiple times (Duplication) + RedCloth#block_textile_lists calls depth[i] multiple times (Duplication) + RedCloth#block_textile_lists calls lines[(line_id - 1)] multiple times (Duplication) + RedCloth#block_textile_lists calls tl.length multiple times (Duplication) + RedCloth#block_textile_lists has approx 20 statements (Long Method) + RedCloth#block_textile_lists refers to depth more than self (Feature Envy) + RedCloth#block_textile_lists/block/block is nested (Nested Iterators) + RedCloth#block_textile_lists/block/block/block has the variable name 'i' (Uncommunicative Name) + RedCloth#block_textile_lists/block/block/block has the variable name 'v' (Uncommunicative Name) + RedCloth#block_textile_lists/block/block/block is nested (Nested Iterators) + RedCloth#block_textile_table has approx 18 statements (Long Method) + RedCloth#block_textile_table/block/block has the variable name 'x' (Uncommunicative Name) + RedCloth#block_textile_table/block/block is nested (Nested Iterators) + RedCloth#block_textile_table/block/block/block is nested (Nested Iterators) + RedCloth#blocks has approx 18 statements (Long Method) + RedCloth#blocks/block is controlled by argument deep_code (Control Couple) + RedCloth#blocks/block/block is nested (Nested Iterators) + RedCloth#check_refs is controlled by argument text (Control Couple) + RedCloth#clean_html calls tags[tag] multiple times (Duplication) + RedCloth#clean_html doesn't depend on instance state (Utility Function) + RedCloth#clean_html has approx 14 statements (Long Method) + RedCloth#clean_html refers to raw more than self (Feature Envy) + RedCloth#clean_html refers to tags more than self (Feature Envy) + RedCloth#clean_html/block/block is nested (Nested Iterators) + RedCloth#clean_html/block/block/block has the variable name 'q' (Uncommunicative Name) + RedCloth#clean_html/block/block/block has the variable name 'q2' (Uncommunicative Name) + RedCloth#clean_html/block/block/block is nested (Nested Iterators) + RedCloth#clean_white_space has approx 7 statements (Long Method) + RedCloth#clean_white_space refers to text more than self (Feature Envy) + RedCloth#flush_left doesn't depend on instance state (Utility Function) + RedCloth#flush_left refers to indt more than self (Feature Envy) + RedCloth#flush_left refers to text more than self (Feature Envy) + RedCloth#footnote_ref doesn't depend on instance state (Utility Function) + RedCloth#footnote_ref refers to text more than self (Feature Envy) + RedCloth#glyphs_textile has approx 10 statements (Long Method) + RedCloth#h_align doesn't depend on instance state (Utility Function) + RedCloth#htmlesc doesn't depend on instance state (Utility Function) + RedCloth#htmlesc refers to str more than self (Feature Envy) + RedCloth#incoming_entities doesn't depend on instance state (Utility Function) + RedCloth#incoming_entities refers to text more than self (Feature Envy) + RedCloth#initialize/block has the variable name 'r' (Uncommunicative Name) + RedCloth#inline/block/block is nested (Nested Iterators) + RedCloth#inline_markdown_link has approx 6 statements (Long Method) + RedCloth#inline_markdown_link/block has the variable name 'm' (Uncommunicative Name) + RedCloth#inline_markdown_reflink has approx 8 statements (Long Method) + RedCloth#inline_markdown_reflink/block has the variable name 'm' (Uncommunicative Name) + RedCloth#inline_textile_code/block has the variable name 'm' (Uncommunicative Name) + RedCloth#inline_textile_image has approx 17 statements (Long Method) + RedCloth#inline_textile_image/block has the variable name 'm' (Uncommunicative Name) + RedCloth#inline_textile_link has approx 9 statements (Long Method) + RedCloth#inline_textile_link/block has the variable name 'm' (Uncommunicative Name) + RedCloth#inline_textile_span has approx 8 statements (Long Method) + RedCloth#inline_textile_span/block/block has the variable name 'm' (Uncommunicative Name) + RedCloth#inline_textile_span/block/block is nested (Nested Iterators) + RedCloth#no_textile doesn't depend on instance state (Utility Function) + RedCloth#no_textile refers to text more than self (Feature Envy) + RedCloth#pba calls $1.length multiple times (Duplication) + RedCloth#pba has approx 21 statements (Long Method) + RedCloth#pba is controlled by argument text_in (Control Couple) + RedCloth#pba refers to style more than self (Feature Envy) + RedCloth#pba refers to text more than self (Feature Envy) + RedCloth#refs_markdown/block has the variable name 'm' (Uncommunicative Name) + RedCloth#refs_textile/block has the variable name 'm' (Uncommunicative Name) + RedCloth#retrieve/block has the variable name 'i' (Uncommunicative Name) + RedCloth#retrieve/block has the variable name 'r' (Uncommunicative Name) + RedCloth#rip_offtags calls ((codepre - used_offtags.length) > 0) multiple times (Duplication) + RedCloth#rip_offtags calls (@pre_list.last << line) multiple times (Duplication) + RedCloth#rip_offtags calls (codepre - used_offtags.length) multiple times (Duplication) + RedCloth#rip_offtags calls @pre_list.last multiple times (Duplication) + RedCloth#rip_offtags calls codepre.zero? multiple times (Duplication) + RedCloth#rip_offtags calls htmlesc(line, :NoQuotes) multiple times (Duplication) + RedCloth#rip_offtags calls used_offtags.length multiple times (Duplication) + RedCloth#rip_offtags calls used_offtags["notextile"] multiple times (Duplication) + RedCloth#rip_offtags has approx 18 statements (Long Method) + RedCloth#textile_bq has 4 parameters (Long Parameter List) + RedCloth#textile_bq is controlled by argument atts (Control Couple) + RedCloth#textile_bq is controlled by argument cite (Control Couple) + RedCloth#textile_fn_ has 5 parameters (Long Parameter List) + RedCloth#textile_fn_ is controlled by argument atts (Control Couple) + RedCloth#textile_p has 4 parameters (Long Parameter List) + RedCloth#textile_p is controlled by argument atts (Control Couple) + RedCloth#to_html has approx 24 statements (Long Method) + RedCloth#v_align doesn't depend on instance state (Utility Function) + + """