Skip to content

Commit

Permalink
Added information about methods to get metrics of code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
Romulo Costa Tavares committed Oct 3, 2012
1 parent 0096ae2 commit d7b8948
Showing 1 changed file with 101 additions and 16 deletions.
117 changes: 101 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,126 @@ What is a code_quality_tools?
code_quality_tools is a little API, in python, to collect some data about code quality of your application.


What metrics can I get?
-----------------------

+ Pep8 -> ```get_pep8_errors()```
+ PyFlakes -> ```get_pyflakes_errors()```
+ JSHint -> ```get_jshint_errors()```
+ CSSLint -> ```get_csslint_errors()```
+ CloneDigger -> ```get_clonedigger_errors()```
+ ALL -> ```get_all_errors()```


Usage
-----

- Get Pep8 errors and warnings without save output
'''
Get Pep8, PyFlakes, JSHint or CSSLint errors and warnings without save output:
```
from code_quality_tools import CodeQualityCheck
check = CodeQualityCheck()
check.get_pep8_errors(path='application/path/')
'''

- Get Pep8 errors and warnings saving output
'''
check.get_pep8_errors(path='application/path/') # or
check.get_pyflakes_errors(path='application/path/') # or
check.get_jshint_errors(path='application/path/') # or
check.get_csslint_errors(path='application/path/')
```

Get Pep8, PyFlakes, JSHint or CSSLint errors and warnings saving output:
```
from code_quality_tools import CodeQualityCheck
check = CodeQualityCheck()
check.get_pep8_errors(path='application/path/', output_file='pep8_errors.txt')
'''

- Get Pep8 errors and warnings passing extra options
'''
check.get_pep8_errors(path='application/path/', output_file='pep8_errors.txt') # or
check.get_pyflakes_errors(path='application/path/', output_file='pyflakes_errors.txt') # or
check.get_jshint_errors(path='application/path/', output_file='jshint_errors.txt') # or
check.get_csslint_errors(path='application/path/', output_file='csslint_errors.txt')
```

Get Pep8, PyFlakes, JSHint or CSSLint errors and warnings passing extra options:
```
from code_quality_tools import CodeQualityCheck
check = CodeQualityCheck()
check.get_pep8_errors(path='application/path/', options=['--exclude=fixtures'])
'''
check.get_pep8_errors(path='application/path/', options=['--exclude=some/path/']) # or
check.get_pyflakes_errors(path='application/path/', options=['--exclude=some/path/']) # or
check.get_jshint_errors(path='application/path/', options=['--exclude=some/path/']) # or
check.get_csslint_errors(path='application/path/', options=['--exclude=some/path/'])
```

All examples above returns something as:
'''
```
{
'total_errors': 1,
'list_errors': ['./code_quality_tools.py:60:80: E501 line too long (98 characters)']
}
'''
```

Get CloneDigger percentage or total of code duplicate without save output:
```
from code_quality_tools import CodeQualityCheck
check = CodeQualityCheck()
check.get_clonedigger_errors(path='application/path/')
```

Get CloneDigger percentage or total of code duplicate saving output:
```
from code_quality_tools import CodeQualityCheck
check = CodeQualityCheck()
check.get_clonedigger_errors(path='application/path/', output_file='clonedigger_statistics.html')
```

Get CloneDigger percentage or total of code duplicate passing extra options:
```
from code_quality_tools import CodeQualityCheck
check = CodeQualityCheck()
check.get_clonedigger_errors(path='application/path/', options='--ignore-dir=some/path/')
```

All examples of CloneDigger returns something as:
```
{
'total_clones': 1,
'percentage_clones': 100
}
```

Get all metrics of code quality:
```
from code_quality_tools import CodeQualityCheck
check = CodeQualityCheck()
check.get_all_errors(path='application/path/')
```

This example returns something as:
```
{
'pep8': {
'total_errors': 1,
'list_errors': ['./code_quality_tools.py:75:80: E501 line too long (98 characters)']
},
'clonedigger': {
'percentage_clones': 26,
'total_clones': 7
},
'csslint': {
'total_errors': 1,
'list_errors': ["./tests/fixtures/csslint.css: line 1, col 1, Warning - Don't use IDs in selectors."]
},
'jshint': {
'total_errors': 1,
'list_errors': ['tests/fixtures/jshint.js: line 1, col 11, Missing semicolon.']
},
'pyflakes': {
'total_errors': 1,
'list_errors': ["./tests/fixtures/pyflakes.py:1: 're' imported but unused"]
}
}
```

Dependencies
------------
Expand Down

0 comments on commit d7b8948

Please sign in to comment.