Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit f4a7f4e

Browse files
authored
Merge pull request #52 from codacy/improve-readme
Improve Readme
2 parents a06709f + fec8fa6 commit f4a7f4e

File tree

2 files changed

+120
-53
lines changed

2 files changed

+120
-53
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ node_modules
3333

3434
# Mac
3535
.DS_Store
36+
37+
.vscode

README.md

Lines changed: 118 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,190 @@
11
# Node Codacy Coverage
2+
23
Credits to [David](https://github.com/DavidTPate) for creating this!
34
[Codacy](https://codacy.com/) support for Node.js. Get coverage reporting and code analysis for Node.js from Codacy.
45

5-
6+
[![Codacy](https://api.codacy.com/project/badge/grade/3c7f5de6ce734762981d3e689de7b941)](https://www.codacy.com/app/codacy/node-codacy-coverage)
7+
[![Codacy](https://api.codacy.com/project/badge/coverage/3c7f5de6ce734762981d3e689de7b941)](https://www.codacy.com/app/codacy/node-codacy-coverage)
68
[![Build Status](https://circleci.com/gh/codacy/node-codacy-coverage.png?style=shield&circle-token=:circle-token)](https://circleci.com/gh/codacy/node-codacy-coverage)
79
[![npm](https://img.shields.io/npm/v/codacy-coverage.svg)](https://www.npmjs.com/package/codacy-coverage)
810
[![npm](https://img.shields.io/npm/dm/codacy-coverage.svg)](https://www.npmjs.com/package/codacy-coverage)
9-
[![Codacy](https://api.codacy.com/project/badge/grade/3c7f5de6ce734762981d3e689de7b941)](https://www.codacy.com/app/codacy/node-codacy-coverage)
10-
[![Codacy](https://api.codacy.com/project/badge/coverage/3c7f5de6ce734762981d3e689de7b941)](https://www.codacy.com/app/codacy/node-codacy-coverage)
1111
[![David](https://img.shields.io/david/codacy/node-codacy-coverage.svg)](https://david-dm.org/codacy/node-codacy-coverage)
1212
[![David](https://img.shields.io/david/dev/codacy/node-codacy-coverage.svg)](https://david-dm.org/codacy/node-codacy-coverage)
1313
[![David](https://img.shields.io/david/peer/codacy/node-codacy-coverage.svg)](https://david-dm.org/codacy/node-codacy-coverage)
1414

15-
## Installation:
15+
## Installation
16+
1617
Add the latest version of `codacy-coverage` to your package.json:
17-
```
18+
19+
```sh
1820
npm install codacy-coverage --save
1921
```
2022

2123
If you're using mocha, add `mocha-lcov-reporter` to your package.json:
22-
```
24+
25+
```sh
2326
npm install mocha-lcov-reporter --save
2427
```
2528

26-
## Usage:
29+
## Enterprise
2730

28-
This script ( `bin/codacy-coverage.js` ) can take standard input from any tool that emits the lcov data format (including [mocha](http://mochajs.org)'s [LCov reporter](https://npmjs.org/package/mocha-lcov-reporter)) and send it to Codacy to report your code coverage there.
31+
To send coverage in the enterprise version you should specify your Codacy installation URL:
32+
33+
```sh
34+
codacy-coverage -e <YOUR-CODACY-ENTERPRISE-URL>:16006
35+
```
2936

30-
Once your app is instrumented for coverage, and building, you need to pipe the lcov output to `./node_modules/.bin/codacy-coverage`.
37+
## Usage
38+
39+
This cli can take standard input from any tool that emits the lcov data format (including [mocha](http://mochajs.org)'s [LCov reporter](https://npmjs.org/package/mocha-lcov-reporter)) and send it to Codacy to report your code coverage there.
40+
41+
Once your app is instrumented for coverage, and building, you need to pipe the lcov output to `codacy-coverage`.
3142

3243
You'll need to provide the Report token from Codacy via an environment variable:
44+
3345
* CODACY_PROJECT_TOKEN (the secret repo token from Codacy.com)
3446

3547
> Note: You should keep your API token well **protected**, as it grants owner permissions to your projects.
3648
37-
**Enterprise**
49+
### [Mocha](http://mochajs.org) + [Blanket.js](https://github.com/alex-seville/blanket)
3850

39-
To send coverage in the enterprise version you should specify your Codacy installation URL:
40-
```
41-
codacy-coverage -e <YOUR-URL>:16006
51+
* Install [blanket.js](http://blanketjs.org/)
52+
* Configure blanket according to [docs](https://github.com/alex-seville/blanket/blob/master/docs/getting_started_node.md).
53+
* Add test with coverage step to your package.json:
54+
55+
```json
56+
"scripts": {
57+
"test-with-coverage": "NODE_ENV=test YOURPACKAGE_COVERAGE=1 mocha --require blanket --reporter mocha-lcov-reporter | codacy-coverage"
58+
}
4259
```
4360

44-
### [Mocha](http://mochajs.org) + [Blanket.js](https://github.com/alex-seville/blanket)
45-
- Install [blanket.js](http://blanketjs.org/)
46-
- Configure blanket according to [docs](https://github.com/alex-seville/blanket/blob/master/docs/getting_started_node.md).
47-
- Run your tests with a command like this:
61+
* Run your tests with:
4862

4963
```sh
50-
NODE_ENV=test YOURPACKAGE_COVERAGE=1 ./node_modules/.bin/mocha \
51-
--require blanket \
52-
--reporter mocha-lcov-reporter | ./node_modules/.bin/codacy-coverage
64+
npm run test-with-coverage
5365
```
66+
5467
### [Mocha](http://mochajs.org) + [JSCoverage](https://github.com/fishbar/jscoverage)
5568

5669
Instrumenting your app for coverage is probably harder than it needs to be (read [here](http://www.seejohncode.com/2012/03/13/setting-up-mocha-jscoverage/)), but that's also a necessary step.
5770

58-
In mocha, if you've got your code instrumented for coverage, the command for a travis build would look something like this:
71+
* Add test with coverage step to your package.json:
72+
73+
```json
74+
"scripts": {
75+
"test-with-coverage": "YOURPACKAGE_COVERAGE=1 mocha test -R mocha-lcov-reporter | codacy-coverage"
76+
}
77+
```
78+
79+
* Run your tests with:
80+
5981
```sh
60-
YOURPACKAGE_COVERAGE=1 ./node_modules/.bin/mocha test -R mocha-lcov-reporter | ./node_modules/.bin/codacy-coverage
82+
npm run test-with-coverage
6183
```
84+
6285
### [Istanbul](https://github.com/gotwarlost/istanbul)
6386

64-
**With Mocha:**
87+
#### With Mocha
6588

66-
```sh
67-
istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage && rm -rf ./coverage
89+
* Add test with coverage step to your package.json:
90+
91+
```json
92+
"scripts": {
93+
"test-with-coverage": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | codacy-coverage && rm -rf ./coverage"
94+
}
6895
```
6996

70-
**With Jasmine:**
97+
* Run your tests with:
7198

7299
```sh
73-
istanbul cover jasmine-node --captureExceptions spec/ && cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage && rm -rf ./coverage
100+
npm run test-with-coverage
74101
```
75102

76-
### [Grunt](http://gruntjs.com/)
77-
- Install & Configure [grunt-codacy](https://www.npmjs.com/package/grunt-codacy)
103+
#### With Jasmine
104+
105+
* Add test with coverage step to your package.json:
106+
107+
```json
108+
"scripts": {
109+
"test-with-coverage": "istanbul cover jasmine-node --captureExceptions spec/ && cat ./coverage/lcov.info | codacy-coverage && rm -rf ./coverage"
110+
}
111+
```
112+
113+
* Run your tests with:
114+
115+
```sh
116+
npm run test-with-coverage
117+
```
78118

79119
### [Poncho](https://github.com/deepsweet/poncho)
120+
80121
Client-side JS code coverage using [PhantomJS](https://github.com/ariya/phantomjs), [Mocha](http://mochajs.org) and [Blanket](https://github.com/alex-seville/blanket):
81-
- [Configure](http://mochajs.org#browser-support) Mocha for browser
82-
- [Mark](https://github.com/deepsweet/poncho#usage) target script(s) with `data-cover` html-attribute
83-
- Run your tests with a command like this:
122+
123+
* [Configure](http://mochajs.org#browser-support) Mocha for browser
124+
* [Mark](https://github.com/deepsweet/poncho#usage) target script(s) with `data-cover` html-attribute
125+
* Add test with coverage step to your package.json:
126+
127+
```json
128+
"scripts": {
129+
"test-with-coverage": "poncho -R lcov test/test.html | codacy-coverage"
130+
}
131+
```
132+
133+
* Run your tests with:
84134

85135
```sh
86-
./node_modules/.bin/poncho -R lcov test/test.html | ./node_modules/.bin/codacy-coverage
136+
npm run test-with-coverage
87137
```
88138

89-
### [gulp](http://gulpjs.com/)
90-
- Install & Configure [gulp-codacy](https://www.npmjs.com/package/gulp-codacy)
139+
## Extras
91140

92-
### Custom Language (Typescript, Coffeescript)
141+
### Force custom language (e.g. Typescript, Coffeescript, C, ...)
93142

94-
- Pass an extra parameter to the codacy-coverage reporter `--language typescript` or `--language coffeescript`.
95-
- If you have multiple language you need to invoke the reporter once for each of them.
143+
* Pass an extra parameter to the codacy-coverage reporter `--language typescript` or `--language coffeescript`.
144+
* If you have multiple languages you need to invoke the reporter for each of them.
96145

97-
### Troubleshooting
146+
## Troubleshooting
98147

99-
The paths in your coverage file should be relative, if you are having problems with absolute paths, you can run our plugin with `-p .` to strip the current path from the paths in your coverage file:
100-
```
101-
cat ./coverage/lcov.info | node_modules/.bin/codacy-coverage -p .
102-
```
148+
### Path Problems
149+
150+
The paths in your coverage file should be relative,
151+
if you are having problems with absolute paths,
152+
you can run our plugin with `-p .` to strip the current path from the paths in your coverage file:
103153

104-
To send coverage in the <strong>enterprise</strong> version you should specify your Codacy installation URL followed by the port 16006 using the -e option, example:
154+
```json
155+
"scripts": {
156+
"test-with-coverage": "cat ./coverage/lcov.info | codacy-coverage -p ."
157+
}
105158
```
106-
cat ./coverage/lcov.info | node_modules/.bin/codacy-coverage -e <YOUR-URL>:16006
159+
160+
### Enterprise Coverage
161+
162+
To send coverage in the **enterprise** version you should specify your Codacy installation URL followed by the port 16006 using the -e option, example:
163+
164+
```json
165+
"scripts": {
166+
"test-with-coverage": "cat ./coverage/lcov.info | codacy-coverage -e <YOUR-CODACY-ENTERPRISE-URL>:16006"
167+
}
107168
```
108169

109170
## License
171+
110172
[MIT](LICENSE)
111173

112-
## What is Codacy?
174+
## What is Codacy
113175

114-
[Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.
176+
[Codacy](https://www.codacy.com/) is an Automated Code Review Tool that monitors your technical debt,
177+
helps you improve your code quality,
178+
teaches best practices to your developers,
179+
and helps you save time in Code Reviews.
115180

116-
### Among Codacy’s features:
181+
### Among Codacy’s features
117182

118-
- Identify new Static Analysis issues
119-
- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
120-
- Auto-comments on Commits and Pull Requests
121-
- Integrations with Slack, HipChat, Jira, YouTrack
122-
- Track issues Code Style, Security, Error Proneness, Performance, Unused Code and other categories
183+
* Identify new Static Analysis issues
184+
* Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
185+
* Auto-comments on Commits and Pull Requests
186+
* Integrations with Slack, HipChat, Jira, YouTrack
187+
* Track issues Code Style, Security, Error Proneness, Performance, Unused Code and other categories
123188

124189
Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.
125190

0 commit comments

Comments
 (0)