New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add codeclimate formatter (json) #1308
Add codeclimate formatter (json) #1308
Conversation
src/ansiblelint/cli.py
Outdated
parser.add_argument('--parseable-codeclimate', dest='parseable_codeclimate', | ||
default=False, | ||
action='store_true', | ||
help="parseable output in the format of codeclimate json report") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parseable severity was a historical mistake and I do not want to clutter the CLI options with very specific cases.
Instead you could add a new formatter and extend -f {rich,plain,rst}
to add codeclimate to the list of allowed options, without adding new command line options.
test/TestCodeclimateJSONFormatter.py
Outdated
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# pylint: disable=preferred-module # FIXME: remove once migrated per GH-725 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the notice is not needed for new files.
test/TestCodeclimateJSONFormatter.py
Outdated
from ansiblelint.rules import AnsibleLintRule | ||
|
||
|
||
class TestCodeclimateJSONFormatter(unittest.TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing the most important test: explicit test of output produced by an file. Feel free to reuse one of the examples and add a check that validates that the JSON output is exactly the one we expect and know to
be accepted by codeclimate. Without this we risk of breaking this feature in the future.
Pick one small but relevant example for that, just enough to validate the output.
Do not forget to rebase on master as I just merged a code formatting change that will cause some problems. If you can address my comments I will include your patch in v5.0 release, which I plan to make tomorrow. |
Thanks for the review. I will implement your suggestions today. |
…eJSONFormatter unit test. Fix ansible lint issues.
0eaa241
to
3f038b6
Compare
Hi, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it looks good now. I hope to see more pull-requests from you. If you could help me fix one of the open bugs it would be awesome.
I would try to avoid feature requests as we would never run of ideas, still bugs affect our users more than missing features.
I have introduced a new parameter called
--parseable-codeclimate
. This flag will indicate ansible-lint to use the new formatter CodeclimateJSONFormatter. It will export the matcherror results in JSON following the Codeclimate spec. To test this formatter I have created few additional unit test cases. The formatter expects a list of MatchError objects instead of a single MatchError Object.Example output with the existing formatter ParseableSeverityFormatter
Example output with the new formatter CodeclimateJSONFormatter.