Add Python linting in coala 66/4066/1
authorThanh Ha <thanh.ha@linuxfoundation.org>
Sun, 5 Mar 2017 02:36:58 +0000 (21:36 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Sun, 5 Mar 2017 02:44:54 +0000 (21:44 -0500)
- Add Git Commit Bear to validate commit message
- Make tox automatically download nltk data for GitCommitBear
- Add Python Bears to validate Python code

Change-Id: Ib50fa4ecaf282a751de38f149bf1e2992463a5f2
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
.coafile
lftools/__init__.py
lftools/cli.py
tox.ini

index a22d3ff..48dbdab 100644 (file)
--- a/.coafile
+++ b/.coafile
@@ -1,11 +1,15 @@
 [default]
-bears = SpaceConsistencyBear
+bears = SpaceConsistencyBear,GitCommitBear
 files = shell/*
 allow_trailing_whitespace = False
 enforce_newline_at_EOF = True
 indent_size = 4
 use_spaces = yeah
 
+[Python]
+bears = BanditBear,PyCommentedCodeBear,PyDocStyleBear,PyFlakesBear,PyImportSortBear
+files = lftools/**/*.py
+
 [ShellCheck]
 bears = ShellCheckBear
 files = shell/*
index e69de29..ded0c11 100644 (file)
@@ -0,0 +1,13 @@
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#   Thanh Ha - Initial implementation
+##############################################################################
+"""lftools package."""
index ff1ac7f..c380a5e 100644 (file)
@@ -1,12 +1,29 @@
-import click
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#   Thanh Ha - Initial implementation
+##############################################################################
+"""CLI main for lftools."""
 import subprocess
 
+import click
+
+
 @click.group()
 @click.pass_context
 @click.version_option()
 def cli(ctx):
+    """CLI entry point for lftools."""
     pass
 
+
 ###############################################################################
 # Shell
 ###############################################################################
@@ -16,7 +33,7 @@ def cli(ctx):
 @click.argument('release-tag')
 @click.pass_context
 def version(ctx, command, release_tag):
-    """Version bump script for Maven based projects
+    """Version bump script for Maven based projects.
 
     Uses *release-tag* to bump versions for Maven projects.
 
@@ -56,6 +73,7 @@ def version(ctx, command, release_tag):
     """
     subprocess.call(['version', command, release_tag])
 
+
 cli.add_command(version)
 
 if __name__ == '__main__':
diff --git a/tox.ini b/tox.ini
index 18e4aa9..974a81a 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -11,6 +11,7 @@ deps =
     coala
     coala-bears
 commands =
+    python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger
     coala --non-interactive
 
 [testenv:docs]