require File.dirname(__FILE__) + '/../spec_helper.rb' describe 'sample gem source code' do it "reports the correct smells in redcloth.rb" do ruby = File.new("#{SAMPLES_DIR}/redcloth.rb").to_source ruby.should reek_of(:ControlCouple, /RedCloth#blocks\/block/, /deep_code/) ruby.should reek_of(:ControlCouple, /RedCloth#check_refs/, /text/) ruby.should reek_of(:ControlCouple, /RedCloth#pba/, /text_in/) ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /atts/) ruby.should reek_of(:ControlCouple, /RedCloth#textile_bq/, /cite/) ruby.should reek_of(:ControlCouple, /RedCloth#textile_fn_/, /atts/) ruby.should reek_of(:ControlCouple, /RedCloth#textile_p/, /atts/) ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last/) ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth.last.length/) ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /depth\[i\]/) ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /\(line_id - 1\)/) ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /lines\[\(line_id - 1\)\]/) ruby.should reek_of(:Duplication, /RedCloth#block_textile_lists/, /tl.length/) ruby.should reek_of(:Duplication, /RedCloth#clean_html/, /tags\[tag\]/) ruby.should reek_of(:Duplication, /RedCloth#pba/, /\$1.length/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /@pre_list.last/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(@pre_list.last << line\)/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(codepre - used_offtags.length\)/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /\(\(codepre - used_offtags.length\) > 0\)/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /codepre.zero?/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /htmlesc\(line, :NoQuotes\)/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags.length/) ruby.should reek_of(:Duplication, /RedCloth#rip_offtags/, /used_offtags\["notextile"\]/) ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_atx/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_rule/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#block_markdown_setext/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#block_textile_lists/, /depth/) ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_html/, /raw/) ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_html/, /tags/) ruby.should reek_of(:FeatureEnvy, /RedCloth#clean_white_space/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /indt/) ruby.should reek_of(:FeatureEnvy, /RedCloth#flush_left/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#footnote_ref/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#htmlesc/, /str/) ruby.should reek_of(:FeatureEnvy, /RedCloth#incoming_entities/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#no_textile/, /text/) ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /style/) ruby.should reek_of(:FeatureEnvy, /RedCloth#pba/, /text/) ruby.should reek_of(:LargeClass, /RedCloth/) ruby.should reek_of(:LongMethod, /RedCloth#block_markdown_bq/) ruby.should reek_of(:LongMethod, /RedCloth#block_textile_lists/) ruby.should reek_of(:LongMethod, /RedCloth#block_textile_table/) ruby.should reek_of(:LongMethod, /RedCloth#blocks/) ruby.should reek_of(:LongMethod, /RedCloth#clean_html/) ruby.should reek_of(:LongMethod, /RedCloth#clean_white_space/) ruby.should reek_of(:LongMethod, /RedCloth#glyphs_textile/) ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_link/) ruby.should reek_of(:LongMethod, /RedCloth#inline_markdown_reflink/) ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_image/) ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_link/) ruby.should reek_of(:LongMethod, /RedCloth#inline_textile_span/) ruby.should reek_of(:LongMethod, /RedCloth#pba/) ruby.should reek_of(:LongMethod, /RedCloth#rip_offtags/) ruby.should reek_of(:LongMethod, /RedCloth#to_html/) ruby.should reek_of(:LongParameterList, /RedCloth#textile_bq/) ruby.should reek_of(:LongParameterList, /RedCloth#textile_fn_/) ruby.should reek_of(:LongParameterList, /RedCloth#textile_p/) ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/) ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_lists/) ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/) ruby.should reek_of(:NestedIterators, /RedCloth#block_textile_table/) ruby.should reek_of(:NestedIterators, /RedCloth#blocks/) ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/) ruby.should reek_of(:NestedIterators, /RedCloth#clean_html/) ruby.should reek_of(:NestedIterators, /RedCloth#inline/) ruby.should reek_of(:NestedIterators, /RedCloth#inline_textile_span/) ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'a'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#block/, /'b'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'i'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_lists/, /'v'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#block_textile_table/, /'x'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#clean_html/, /'q2'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#initialize/, /'r'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_link/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_markdown_reflink/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_code/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_image/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_link/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#inline_textile_span/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_markdown/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#refs_textile/, /'m'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'i'/) ruby.should reek_of(:UncommunicativeName, /RedCloth#retrieve/, /'r'/) ruby.should reek_of(:UtilityFunction, /RedCloth#block_markdown_rule/) ruby.should reek_of(:UtilityFunction, /RedCloth#clean_html/) ruby.should reek_of(:UtilityFunction, /RedCloth#flush_left/) ruby.should reek_of(:UtilityFunction, /RedCloth#footnote_ref/) ruby.should reek_of(:UtilityFunction, /RedCloth#h_align/) ruby.should reek_of(:UtilityFunction, /RedCloth#htmlesc/) ruby.should reek_of(:UtilityFunction, /RedCloth#incoming_entities/) ruby.should reek_of(:UtilityFunction, /RedCloth#no_textile/) ruby.should reek_of(:UtilityFunction, /RedCloth#v_align/) ruby.report.should have_at_most(93).smells end end