Skip to content
Open
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
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
#frozen_string_literal: true
source "https://rubygems.org"

gem "codeclimate-test-reporter"
Expand Down
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ Code Climate Lunch & Learn Example


Example files: https://gist.github.com/dblandin/589e70345774298e1622850349c31876

## Setup

## Setup

1. Install the Code Climate [browser extension](https://codeclimate.com/browser-extension)
1. [Fork](https://github.com/codeclimate-demo/example-foobar#fork-destination-box) this project

<img src="https://raw.githubusercontent.com/codeclimate-demo/example-foobar/master/screenshots/2017-05-23-052427_978x491_scrot.png" align="center" width="600" />

## Introduce some complexity
## Introduce some complexity

1. Modify `foo_bar.rb` with [this content](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-foo_bar-rb) from gist
1. Push to fork and open PR against master
Expand Down Expand Up @@ -62,6 +63,3 @@ You should now see green annotations which mean those lines are now covered by
```

You should now see duplication issues reported by Code Climate.

<img src="https://raw.githubusercontent.com/codeclimate-demo/example-foobar/master/screenshots/2017-05-23-053732_1798x983_scrot.png" align="center" width="600" />

31 changes: 30 additions & 1 deletion duplication_2.rb
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# TODO: Add duplication_2.rb content
require "securerandom"

module DuplicationExample
def identical(message, header: true)
body = []
body << "-- HEADER --" if header
body << "-- MESSAGE --"
body << message
body << "-- FOOTER --"
message = body.join("\n")

if message.length > 100
message[0, 100]
else
message
end
end

def similar
hex = SecureRandom.hex(20)
hex.reverse
hex += "-suffix"

if hex.start_with?("z")
hex += "something-else"
end

hex
end
end
23 changes: 22 additions & 1 deletion foo_bar.rb
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
# TODO: Add FooBar content
class FooBar
def run(items = gets.chomp.to_i)
if items > 0
list = []
(1..items).each do |n|
if n % 3 == 0 && n % 5 == 0
list << "FOOBAR"
elsif n % 3 == 0
list << "FOO"
elsif n % 5 == 0
list << "BAR"
else
list << n
end
end
else
puts "Please enter a positive number "
end

list
end
end
127 changes: 127 additions & 0 deletions nestfolder1/nestfolder2/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,131 @@
test
test
test
testtest
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test

test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
test
testtest
test
test
test
test
test
test
test
testtest
test
test
test
test
test
test
test
testtest
test
test
test
test
test
test
test
testtest
test
test


28 changes: 27 additions & 1 deletion spec/foo_bar_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
require "spec_helper"
require_relative "../foo_bar"

# TODO: Add FooBar specs
require "spec_helper"
require_relative "../foo_bar"

describe "FooBar" do
it "returns correct list of items" do
result = FooBar.new.run(15)

expect(result.length).to eq(15)
expect(result).to eq([
1,
2,
"FOO",
4,
"BAR",
"FOO",
7,
8,
"FOO",
"BAR",
11,
"FOO",
13,
14,
"FOOBAR",
])
end
end