Skip to content

Commit 4fffb29

Browse files
committed
Initial implementation
This is an extracted combination of mrb/foodcritic (the code_climate_support branch) and chef/codeclimate-foodcritic and is meant to obviate both of those in a codeclimate-community-maintained version. It has the following notable differences from those projects: - Invokes foodcritic as-is (does not rely on bugfixes in the mrb fork) - Expands and filters include_paths into .rb files as necessary - Supports config.tags - Supports config.cookbook_paths (means ignoring include_paths) - Hides issues on non-existent files (CC does not support this)
1 parent 1490b3a commit 4fffb29

12 files changed

+2295
-0
lines changed

Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ruby:2.3-slim
2+
3+
WORKDIR /usr/src/app
4+
COPY Gemfile /usr/src/app/
5+
COPY Gemfile.lock /usr/src/app/
6+
7+
RUN apt-get update && apt-get install -y \
8+
build-essential && \
9+
bundle install && \
10+
rm -rf /var/lib/apt/lists/* && \
11+
apt-get remove -y build-essential && \
12+
apt-get autoremove -y
13+
14+
RUN adduser \
15+
--uid 9000 \
16+
--home /home/app \
17+
--disabled-password \
18+
--gecos "" app
19+
20+
COPY doc/rules.yml /rules.yml
21+
22+
COPY bin /usr/src/app/bin
23+
COPY lib /usr/src/app/lib
24+
RUN chown -R app:app /usr/src/app
25+
26+
USER app
27+
VOLUME /code
28+
WORKDIR /code
29+
30+
CMD ["/usr/src/app/bin/codeclimate-foodcritic"]

Gemfile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source "https://rubygems.org"
2+
3+
gem "foodcritic", "~> 6.0"
4+
5+
group :test do
6+
gem "rspec"
7+
end

Gemfile.lock

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
GEM
2+
remote: https://rubygems.org/
3+
specs:
4+
diff-lcs (1.2.5)
5+
erubis (2.7.0)
6+
foodcritic (6.0.1)
7+
erubis
8+
gherkin (~> 2.11)
9+
nokogiri (>= 1.5, < 2.0)
10+
rake
11+
rufus-lru (~> 1.0)
12+
treetop (~> 1.4)
13+
yajl-ruby (~> 1.1)
14+
gherkin (2.12.2)
15+
multi_json (~> 1.3)
16+
mini_portile2 (2.0.0)
17+
multi_json (1.11.2)
18+
nokogiri (1.6.7.2)
19+
mini_portile2 (~> 2.0.0.rc2)
20+
polyglot (0.3.5)
21+
rake (10.5.0)
22+
rspec (3.4.0)
23+
rspec-core (~> 3.4.0)
24+
rspec-expectations (~> 3.4.0)
25+
rspec-mocks (~> 3.4.0)
26+
rspec-core (3.4.3)
27+
rspec-support (~> 3.4.0)
28+
rspec-expectations (3.4.0)
29+
diff-lcs (>= 1.2.0, < 2.0)
30+
rspec-support (~> 3.4.0)
31+
rspec-mocks (3.4.1)
32+
diff-lcs (>= 1.2.0, < 2.0)
33+
rspec-support (~> 3.4.0)
34+
rspec-support (3.4.1)
35+
rufus-lru (1.0.5)
36+
treetop (1.6.5)
37+
polyglot (~> 0.3)
38+
yajl-ruby (1.2.1)
39+
40+
PLATFORMS
41+
ruby
42+
43+
DEPENDENCIES
44+
foodcritic (~> 6.0)
45+
rspec
46+
47+
BUNDLED WITH
48+
1.10.6

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.PHONY: image
2+
3+
IMAGE_NAME ?= codeclimate/codeclimate-foodcritic
4+
5+
image:
6+
docker build --tag $(IMAGE_NAME) .
7+
8+
citest:
9+
docker run --rm \
10+
--volume $(PWD)/spec:/usr/src/app/spec \
11+
--workdir /usr/src/app $(IMAGE_NAME) rspec
12+
13+
test: image citest

README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Code Climate Engine to run [Foodcritic][]
2+
3+
[foodcritic]: http://www.foodcritic.io/
4+
5+
## Usage
6+
7+
**.codeclimate.yml**
8+
9+
```yml
10+
engines:
11+
foodcritic:
12+
enabled: true
13+
```
14+
15+
## Configuration
16+
17+
This engine accepts `tags` and `cookbook_paths` in its configuration. Both
18+
values are optional:
19+
20+
```yml
21+
engines:
22+
foodcritic:
23+
enabled: true
24+
config:
25+
tags:
26+
- "~FC011"
27+
- "~FC033"
28+
cookbook_paths:
29+
- libraries/mysql.rb
30+
- libraries/docker.rb
31+
```
32+
33+
**NOTE**: `cookbook_paths`, when defined, are passed directly to Foodcritic and
34+
any computed `include_paths` (which take into account your configured
35+
`exclude_paths`) are ignored.

bin/codeclimate-foodcritic

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env ruby
2+
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "../lib")))
3+
4+
require "cc/engine"
5+
6+
CC::Engine.each_issue do |issue|
7+
if File.exist?(issue.filename)
8+
print "#{issue.to_json}\0"
9+
else
10+
$stderr.puts "Omitting issue for non-existent file: #{issue.filename}"
11+
end
12+
end

circle.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
machine:
2+
services:
3+
- docker
4+
5+
dependencies:
6+
override:
7+
- make image
8+
9+
test:
10+
override:
11+
- make citest

0 commit comments

Comments
 (0)