Skip to content
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

adds specific file coala #3

Merged
merged 1 commit into from May 17, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

adds specific file coala

  • Loading branch information...
RohanVB committed May 17, 2019
commit 80233a51281d9aecd6e82c32ea6aa51ed736fe29
@@ -0,0 +1,47 @@
[Default]
files = *.py, coala_langserver/*.py, tests/**/*.py

max_line_length = 79
use_spaces = True

[python]
# Patches may conflict with autopep8 so putting them in own section so they
# will be executed sequentially; also we need the LineLengthBear to double
# check the line length because PEP8Bear sometimes isn't able to correct the
# linelength.
bears = SpaceConsistencyBear, QuotesBear
language = python
preferred_quotation = '

[autopep8]
bears = PEP8Bear, PycodestyleBear, PyDocStyleBear
pydocstyle_ignore = D100, D101, D102, D103, D104, D107,
D200, D203, D205, D209, D212, D213, D400

[linelength] # Sometimes autopep8 makes too long lines, need to check after!
bears = LineLengthBear
ignore_length_regex = ^.*https?://

[commit]
bears = GitCommitBear
shortlog_trailing_period = False
shortlog_regex = ([^:]*|[^:]+[^ ]: [A-Z0-9*].*)

[LineCounting]
enabled = False
bears = LineCountBear
max_lines_per_file = 1000

[TODOS]
enabled = False
bears = KeywordBear
language = python3

# Note that the ci_keywords and cs_keywords are only used here because coala
# 0.8.x (current stable release) needs them.
ci_keywords, keywords = \#TODO, \# TODO, \#FIXME, \# FIXME
cs_keywords =

[yml]
bears = YAMLLintBear
files = *.yml
@@ -0,0 +1,38 @@
"""
Run coala on specific files only
Authored by: https://github.com/li-boxuan and https://github.com/gaocegege
# todo: add proper references
"""

import sys
import os
import io
from contextlib import redirect_stdout

from coalib import coala

class use_coala(object):

def log(*args, **kwargs):
return print(*args, file=sys.stderr, **kwargs), sys.stderr.flush()

def specific_file(working_dir, file):
sys.argv = ['', '--json', '--find-config', '--limit-files', file]
if working_dir is None:
working_dir = '.'
os.chdir(working_dir)
f = io.StringIO()
with redirect_stdout(f):
retval = coala.main()
output = None
if retval == 1:
output = f.getvalue()
if output:
use_coala.log('Output =', output)
else:
use_coala.log('No results for the file')
elif retval == 0:
use_coala.log('No issues found')
else:
use_coala.log('Exited with:', retval)
return output
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.