- Python 3.5
git clone https://github.com/CheckiePy/CheckiePyCore.git
cd CheckiePyCore
python3 -m venv venv
source venv/bin/activate
Get metrics for a file or a directory:
python3 countercli.py <path to file or directory>
Get inspections for a file or a directory:
python3 analyzecli.py <path to file for analyze> <path to file with metrics>
- Look at analyzercli.py and countercli.py for guidance.
python3 test.py
- FileLength
- FunctionNameCase
- NestingLoops
- ClassNameCase
- IndentType
- QuotesType
- SpacesNearRoundBrackets
- SpacesNearBraces
- SpacesNearSquareBrackets
- ImportOrder
- BlankBeforeFunction
- BlankBeforeClass
- BlankBeforeMethod
{
"metric_name1":
{
"metric_value1": number_of_occurences,
"metric_value2": ...,
...
},
"metric_name2":
{
...
},
...
}
Metrics should be implemented as class with three methods:
class MetricName:
""" Metric's meaning. """
def count(self, file, verbose=False):
"""
The method to count the metric from the 'file'.
The 'verbose' flag is specified when you need to get line numbers where the metric occurs.
"""
pass
def discretize(self, values):
"""
Some metrics can have a very wide range (continuous).
For instance, it can be a file length in lines.
Metric's values like that should be discretized
up to 10 different values.
"""
pass
def inspect(self, discrete, values):
"""
This method compares counted metrics for a file
(values param) with discrete values for this
metric (discrete param) and returns inspection
messages with line numbers of code style violations.
Values should be passed to this method in verbose
format.
"""
pass
-
Metric's class should be placed in a separate file under the metric directory.
-
A class name of implemented metric should be registered in IMPLEMENTED_METRICS dictionary in metrics.py.
- The 'count' method should return an output in the next format (non verbose):
{
"metric_value1": number_of_occurences,
"metric_value2": ...,
...
}
and in the verbose format:
{
"metric_value1":
{
"count": number,
"lines": [list_with_line_numbers],
},
"metric_value2": ...,
...
}
{
"metric_value1": percent_in_a_float_format,
"metric_value2": ...,
...
}
For example, 10% is 0.1 in the float format.
{
"inspection_name1":
{
"message": "Inspection message.",
"lines": [numbers_of_lines],
},
"inspection_name2": ...,
...
}
If inspection isn't applicable to some line then 'lines' property should be omitted.