Skip to content

Commit

Permalink
Merge pull request #8 from mdiebolt/squashed-additional-metrics
Browse files Browse the repository at this point in the history
Add additional metrics functionLength, cyclomaticComplexity, letterGrade
  • Loading branch information
mdiebolt committed Oct 31, 2015
2 parents 02a9ac3 + 526f3dd commit a72c058
Show file tree
Hide file tree
Showing 33 changed files with 1,974 additions and 299 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,26 @@ Generates a report of churn and complexity for `file1.coffee`, `file2.coffee`, a
## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
1. Create your feature branch (`git checkout -b my-new-feature`)
1. Commit your changes (`git commit -am 'Add some feature'`)
1. Push to the branch (`git push origin my-new-feature`)
1. Create new Pull Request

## TODO

Stub out fs read file to speed up CLI specs

## Known issues

Method length metric can be incorrect if you have comments at the same level as another function.

```coffee
fnOne = ->
doSomething()

# This is what function two does
fnTwo = ->
doSomethingElse()
```

In the above example the comment above `fnTwo` will be added to the method length calculation for `fnOne`.
37 changes: 3 additions & 34 deletions bin/clog
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
#!/usr/bin/env node

var __slice = [].slice

var clog = require("../lib/clog").clog
var cli = require("../lib/cli")
var argv = require("minimist")(process.argv.slice(2))

function command() {
var commands = []
if (arguments.length >= 1)
commands = __slice.call(arguments, 0)

return commands.reduce(function(memo, c) {
if (argv[c]) {
memo = true
}
return memo
}, false)
}

var USAGE = "\nUsage: clog path/to/file1.coffee path/to/directory\n\n-h, --help display this message\n-v, --version display the current version"
var message = USAGE

if (command("h", "help")) {
message = USAGE
} else if (command("v", "version")) {
message = clog.VERSION
} else if (argv._.length) {
if (command("p", "pretty-print")) {
printOptions = { indentSpace: 2 }
} else {
printOptions = {}
}

message = clog.report(argv._, printOptions)
}

console.log(message)
console.log(cli(argv))
process.exit(0)
9 changes: 7 additions & 2 deletions coffeelint.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
}
},
"cyclomatic_complexity": {
"value": 10,
"level": "warn"
"value": 7,
"level": "error"
},
"duplicate_key": {
"level": "error"
Expand Down Expand Up @@ -120,5 +120,10 @@
},
"transform_messes_up_line_numbers": {
"level": "warn"
},
"no_long_functions": {
"module": "coffeelint-no-long-functions",
"level": "error",
"value": 20
}
}
40 changes: 40 additions & 0 deletions lib/cli.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 39 additions & 60 deletions lib/clog.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions lib/metrics/churn.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions lib/metrics/cyclomatic_complexity.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions lib/metrics/function_length.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions lib/metrics/gpa.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a72c058

Please sign in to comment.