Readability added.

This commit is contained in:
Elf M. Sternberg 2016-09-30 12:10:52 -07:00
parent 08537128bb
commit dd4aeb1cad
7 changed files with 73 additions and 58 deletions

View File

@ -63,3 +63,9 @@ match = .json
print = False print = False
condition = error condition = error
[readability]
output = Running Text Style Check
match = .rst
command = git-lint-style
print = False
condition = error

View File

@ -46,6 +46,10 @@ def main(*args):
print(error) print(error)
return returncode return returncode
kincaid = re.search(r'Kincaid:\s*([\d\.]+)', values, re.MULTILINE) kincaid = re.search(r'Kincaid:\s*([\d\.]+)', values, re.MULTILINE)
# Assumes an uncheckable issue, like an empty RST. Not unusual.
if not kincaid:
return 0
val = float(kincaid.group(1)) val = float(kincaid.group(1))
msg = "" msg = ""

View File

@ -31,7 +31,7 @@ project_root = os.path.dirname(cwd)
# version is used. # version is used.
sys.path.insert(0, project_root) sys.path.insert(0, project_root)
import git_lint import git_lint # noqa
# -- General configuration --------------------------------------------- # -- General configuration ---------------------------------------------

View File

@ -146,10 +146,6 @@ git_head = get_git_head()
# \___/ \__|_|_|_|\__|_\___/__/ # \___/ \__|_|_|_|\__|_\___/__/
# #
def base_file_cleaner(files):
return [file.replace(git_base + '/', '', 1) for file in files]
class MatchFilter: class MatchFilter:
def __init__(self, config): def __init__(self, config):

View File

@ -65,9 +65,11 @@ def cleanup_options(options, commandline):
if key not in excluded} if key not in excluded}
return (cleaned, excluded) return (cleaned, excluded)
def shortoptstogo(i): return i[0] + ((i[2] and ':') or '') def shortoptstogo(i):
return i[0] + ((i[2] and ':') or '')
def longoptstogo(i): return i[1] + ((i[2] and '=') or '') def longoptstogo(i):
return i[1] + ((i[2] and '=') or '')
optstringsshort = ''.join([shortoptstogo(opt) for opt in options]) optstringsshort = ''.join([shortoptstogo(opt) for opt in options])
optstringslong = [longoptstogo(opt) for opt in options] optstringslong = [longoptstogo(opt) for opt in options]

View File

@ -1,8 +1,13 @@
from __future__ import print_function from __future__ import print_function
from .git_lint import load_config, run_linters, git_base
import gettext import gettext
_ = gettext.gettext _ = gettext.gettext
def base_file_cleaner(files):
return [file.replace(git_base + '/', '', 1) for file in files]
# ICK. Mutation, references, and hidden assignment. # ICK. Mutation, references, and hidden assignment.
def group_by(iterable, field_id): def group_by(iterable, field_id):
results = [] results = []
@ -28,7 +33,7 @@ def print_report(results, unlintable_filenames, cant_lint_filenames,
for group in grouped_results: for group in grouped_results:
print(grouping.format(group[0])) print(grouping.format(group[0]))
for (filename, lintername, returncode, text) in group[1]: for (filename, lintername, returncode, text) in group[1]:
print('\n'.join(text)) print('\n'.join(base_file_cleaner(text)))
print('') print('')
if len(broken_linter_names): if len(broken_linter_names):
print(_('These linters could not be run:'), ','.join(broken_linter_names)) print(_('These linters could not be run:'), ','.join(broken_linter_names))

View File

@ -4,6 +4,7 @@ import sys
import argparse import argparse
import os.path import os.path
def _resolve_prefix(prefix, type): def _resolve_prefix(prefix, type):
osx_system_prefix = r'^/System/Library/Frameworks/Python.framework/Versions' osx_system_prefix = r'^/System/Library/Frameworks/Python.framework/Versions'
matches = {'man': [(r'^/usr$', '/usr/share'), matches = {'man': [(r'^/usr$', '/usr/share'),
@ -66,6 +67,7 @@ setup(
install_requires=requirements, install_requires=requirements,
license="MIT", license="MIT",
zip_safe=False, zip_safe=False,
scripts=['bin/git-lint-style'],
keywords='git lint style syntaxt development', keywords='git lint style syntaxt development',
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [