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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
docker:
- image: ruby:2.4
environment:
CC_TEST_REPORTER_ID: "490eb0f55f0afad6ec34f6c4857c5e1a70553b3457db0f5fd81e1ddb62074fc4"
CC_TEST_REPORTER_ID: a3914592c687e9f5c458c0a835f1dc85bfdc6eed522ef045864cecaeaedc5800
steps:
- checkout
- type: cache-restore
Expand Down
61 changes: 23 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,46 @@ Example files: https://gist.github.com/dblandin/589e70345774298e1622850349c31876
## 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
2. [Fork](https://github.com/davehenton/example-foobar) this project to your own GitHub user.
3. Import your new fork of the repo to Quality, using the `Open Source` section of the Quality UI.
4. Update the included CircleCI config file with the Test Reporter ID found in your Repo Settings in Quality.
5. Create a CircleCI user, and add your repo to CircleCI.
6. Head back to the Quality UI, and install the GitHub PR Integration for your repo.


<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

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
1. In the GitHub UI, modify `foo_bar.rb` with [this content](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-foo_bar-rb) from gist
2. When committing the changes, create a new branch titled `demo-branch` for the commit and open a pull request.

```
git add foo_bar.rb
git commit -m "Add FooBar"
git push origin master
hub pull-request # or using the GitHub UI
```
You should now see a Cognitive Complexity issue reported by Quality as a PR status
and via the browser extension on the diff. Test coverage reporting should also show
uncovered lines via the browser extension and a drop in coverage via the `diff-coverage` and `total-coverage` statuses.

You should now see complexity issues reported by Code Climate as a commit status
and via the browser extension. Test coverage reporting should also show
uncovered lines via the browser extension and a drop in coverage via a commit
status.
![Screenshot 2023-01-25 at 7 45 55 PM](https://user-images.githubusercontent.com/18341459/214743756-2335f16e-794c-4456-9483-3fc45900e6c6.png)

<img src="https://raw.githubusercontent.com/codeclimate-demo/example-foobar/master/screenshots/2017-05-23-053352_1542x769_scrot.png" align="center" width="600" />
![uncovered2](https://user-images.githubusercontent.com/18341459/214745680-0439f858-6cfc-4976-879e-3370d64ac1e3.jpg)

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

## Add some test coverage

1. Modify `spec/foo_bar_spec.rb` with [this content](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-foo_bar_spec-rb) from gist

1. Commit and push to your fork PR branch
## Add some test coverage

```
git add spec/foo_bar_spec.rb
git commit -m "Add FooBar specs"
git push origin master
```
1. On your existing `demo-branch` branch, modify `spec/foo_bar_spec.rb` with [this content](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-foo_bar_spec-rb) from gist
2. Commit the update to `demo-branch`.

You should now see green annotations which mean those lines are now covered by
Your pull request should now show a smaller decrease in `total-coverage`, and a passing `diff-coverage` status.

<img src="https://raw.githubusercontent.com/codeclimate-demo/example-foobar/master/screenshots/2017-05-23-053507_2560x1415_scrot.png" align="center" width="600" />
<img src="https://raw.githubusercontent.com/codeclimate-demo/example-foobar/master/screenshots/2017-05-23-053532_1802x1070_scrot.png" align="center" width="600" />
![Screenshot 2023-01-25 at 8 01 06 PM](https://user-images.githubusercontent.com/18341459/214744436-02029cbe-4e09-484a-867b-7bfded32282b.png)

## Introduce some duplication
The browser extension will also highlight the newly covered lines in `foo_bar.rb`.
![Screenshot 2023-01-25 at 8 29 32 PM](https://user-images.githubusercontent.com/18341459/214745367-1630cd55-37c7-4b4a-888b-64b1bae5e079.png)

1. Modify `duplication.rb` and `duplication_2.rb` with [these](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-duplication-rb) [files](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-duplication_2-rb)

1. Commit and push to your fork PR branch
## Introduce some duplication

```
git add duplication.rb duplication_2.rb
git commit -m "Add duplication"
git push origin master
```
1. On your existing `demo-branch` branch, modify `duplication.rb` and `duplication_2.rb` with [these](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-duplication-rb) [files](https://gist.github.com/dblandin/589e70345774298e1622850349c31876#file-duplication_2-rb)

You should now see duplication issues reported by Code Climate.
2. Commit to `demo-branch`. 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" />

24 changes: 23 additions & 1 deletion foo_bar.rb
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# 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