Skip to content

Commit afd104b

Browse files
Initial Setup (#1)
* Install latest PMD bins * Simplify Docker image and shrink its size * Remove unecessary files * Add instructions * Add basic building rules * Add customization instructions * Edit maintainer * fix pmd bin path * Ensure path standards * CircleCI setup * Tune Dockerfile * Accept broader config * Language can be auto detected * The specified language version was just wrong. It was inheriting a version previously set for `apex`, not `java`.
1 parent 3acbb0d commit afd104b

26 files changed

+116
-410
lines changed

Dockerfile

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
FROM java:8-jre
1+
FROM groovy:jre8-alpine
22

3-
MAINTAINER Sivakumar Kailasam
3+
MAINTAINER "Code Climate <[email protected]>"
44

5-
RUN cd /tmp && \
6-
wget http://dl.bintray.com/groovy/maven/apache-groovy-binary-2.4.6.zip && \
7-
unzip apache-groovy-binary-2.4.6.zip && \
8-
mv groovy-2.4.6 /groovy && \
9-
rm apache-groovy-binary-2.4.6.zip
5+
USER root
106

11-
ENV GROOVY_HOME /groovy
12-
ENV PATH $GROOVY_HOME/bin/:$PATH
7+
RUN apk update && \
8+
apk add ca-certificates wget curl jq && \
9+
update-ca-certificates
1310

14-
RUN groupadd app -g 9000 && useradd -g 9000 -u 9000 -r -s /bin/false app
11+
RUN adduser -u 9000 -D app
12+
13+
COPY ./bin /usr/src/app/bin
14+
RUN /usr/src/app/bin/install-pmd.sh
1515

1616
VOLUME /code
1717
WORKDIR /code
1818
COPY . /usr/src/app
19+
RUN chown -R app:app /usr/src/app
1920

2021
USER app
2122

22-
CMD ["/usr/src/app/pmd.groovy", "--codeFolder=/code","--configFile=/config.json"]
23+
CMD ["/usr/src/app/pmd.groovy", "--codeFolder=/code", "--configFile=/config.json"]

Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.PHONY: image test
2+
3+
IMAGE_NAME ?= codeclimate/codeclimate-pmd
4+
5+
image:
6+
docker build --rm -t $(IMAGE_NAME) .
7+
8+
test: image
9+
docker run --rm $(IMAGE_NAME) sh -c "echo Nothing to do yet!"
10+

README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
## codeclimate-pmd
1+
# Code Climate PMD Engine
2+
3+
`codeclimate-pmd` is a Code Climate engine that wraps the [PMD](https://pmd.github.io) static analysis tool. You can run it on your command line using the Code Climate CLI, or on our hosted analysis platform.
4+
5+
### Installation
6+
7+
1. If you haven't already, [install the Code Climate CLI](https://github.com/codeclimate/codeclimate).
8+
2. Run `codeclimate engines:enable pmd`. This command both installs the engine and enables it in your `.codeclimate.yml` file.
9+
3. You're ready to analyze! Browse into your project's folder and run `codeclimate analyze`.
10+
4. To add you custom PMD rules, open `.codeclimate.yml` and add a `config` entry pointing to your `ruleset.xml` file:
11+
```yml
12+
engines:
13+
pmd:
14+
enabled: true
15+
config: ruleset.xml
16+
```
17+
18+
### Need help?
19+
20+
For help with PMD, [check out their documentation](https://pmd.github.io/).
21+
22+
If you're running into a Code Climate issue, first check out [our PMD engine docs][cc-docs-pmd] and look over this project's [GitHub Issues](https://github.com/codeclimate/codeclimate-rubocop/issues),
23+
as your question may have already been covered. If not, [go ahead and open a support ticket with us](https://codeclimate.com/help).
24+
25+
[cc-docs-pmd]: https://docs.codeclimate.com/docs/pmd

bin/install-pmd.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
LIB_DIR=/usr/src/app/lib
5+
6+
download_latest_pmd() {
7+
curl -s https://api.github.com/repos/pmd/pmd/releases/latest | \
8+
jq -c '.assets[] | select(.name | contains("bin")) | .browser_download_url' | \
9+
xargs wget -O pmd.zip
10+
}
11+
12+
install_pmd() {
13+
download_latest_pmd
14+
unzip pmd.zip
15+
mv ${LIB_DIR}/pmd-bin*/* ${LIB_DIR}/pmd
16+
}
17+
18+
cleanup() {
19+
rmdir ${LIB_DIR}/pmd-bin*
20+
rm pmd.zip
21+
}
22+
23+
mkdir -p ${LIB_DIR}/pmd
24+
cd ${LIB_DIR}
25+
26+
install_pmd
27+
cleanup

circle.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
machine:
2+
services:
3+
- docker
4+
5+
dependencies:
6+
override:
7+
- >
8+
docker run
9+
--env CIRCLE_BRANCH
10+
--env CIRCLE_PROJECT_REPONAME
11+
--env CIRCLE_TOKEN
12+
--env GCR_JSON_KEY
13+
--volume /var/run/docker.sock:/var/run/docker.sock
14+
codeclimate/patrick pull || true
15+
- make image
16+
17+
test:
18+
override:
19+
- make test
20+
21+
deployment:
22+
registry:
23+
branch: /master|channel\/[\w-]+/
24+
owner: codeclimate
25+
commands:
26+
- >
27+
docker run
28+
--env CIRCLE_BUILD_NUM
29+
--env CIRCLE_PROJECT_REPONAME
30+
--env GCR_JSON_KEY
31+
--volume /var/run/docker.sock:/var/run/docker.sock
32+
codeclimate/patrick push gcr
33+
34+
notify:
35+
webhooks:
36+
- url: https://cc-slack-proxy.herokuapp.com/circle

engine.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "codeclimate-pmd",
33
"description": "Static code analysis tool for Java",
4-
"maintainer": {
5-
"name": "sivakumar-kailasam",
6-
"email": "sivakumar.ur.friend@gmail.com "
7-
},
4+
"maintainer": {
5+
"name": "Code Climate",
6+
"email": "hello@codeclimate.com"
7+
},
88
"languages": [
99
"Java"
1010
],

lib/pmd/LICENSE

-237
This file was deleted.

lib/pmd/bin/bgastviewer.bat

-6
This file was deleted.

0 commit comments

Comments
 (0)