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

Adding implicit-str-concat-in-sequence check #1655

Merged
merged 2 commits into from
Oct 10, 2018
Merged

Adding implicit-str-concat-in-sequence check #1655

merged 2 commits into from
Oct 10, 2018

Conversation

Lucas-C
Copy link
Contributor

@Lucas-C Lucas-C commented Sep 11, 2017

Fixes / new features

  • Adds a new warning. Example of code that would raise it:
TEST_LIST = ('a', 'b' 'c')

Message:

String literals are implicitly concatenated in a comma-separated list : maybe a comma is missing ?

@rogalski
Copy link
Contributor

Hello,

Thank you for you PR!

Can we have some test case along lines of:

def my_func(arg, arg2, msg):
    pass

my_func("s1", "s2", "really long message that I'd like to "
                    "split across multiple lines")

Case above (IMHO) shouldn't emit a warning but it looks like it would be emitted.

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 12, 2017

Well spotted, thanks
I'm going to add it and fix the checker

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 12, 2017

Ok, so i'm facing a dead-end here :(

First, this problem has a bit of history:

Now, I see 2 approaches in pylint:

  • use astroid AST visitor-pattern. Sadly it is limited by Python builtin compile method (cf. usage in code) which does not allow to detect string concatenation : on this level, for astroid, it's just a single string node

  • analyze tokens generated with tokenize. This time, the problem is that I cannot detect if I'm in a list/tuple context, or if I'm looking at function arguments as in your example

The only idea I've got would be to retrieve from the source the code snippet corresponding to each list/tuple element, to check if there is string concatenation.

Did any checker had to implement such thing already ? I.e retrieving source code from node.lineno / node.col_offset ?

Or does anyone has a better idea ?

@asottile
Copy link
Contributor

I'm not sure if pylint gives you an option to but one way would be to cross reference the ast nodes with the tokenized output -- this is roughly how pyupgrade finds list / tuple nodes.

Otherwise disregard me, just drive by browsing issues (while I wait for pylint to clone) and noticed a familiar name :)

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 14, 2017

Hey, thanks for the advice @asottile !

I contemplated this idea, but it's awesome to see you already implemented it quite concisely:
https://github.com/asottile/pyupgrade/blob/master/pyupgrade.py#L370-L383

Before implementing something like that in pylint though, it'd be great to know:

  • is there already something like that in pylint ? I.e cross-referencing tokens & ast
  • else, in which module would it be best to put this ? pylint/utils.py ?

@PCManticore, @rogalski ?

@rogalski
Copy link
Contributor

@Lucas-C You'll need a checker that inherits from BaseTokenChecker. From what I see in code, processing tokens occurs before processing AST nodes, so potential implementation may look like:

  1. Collect all "suspiciously" joined strings in process_tokens (which is already implemented), store information about them on some class attribute
  2. For each const node visited:
  3. If constant node position (row / col) matches suspicious string found earlier - emit a message

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 17, 2017

Thanks @rogalski !

I updated the PR, I think I nailed it ;)

@@ -0,0 +1,19 @@
#pylint: disable=bad-continuation,invalid-name,missing-docstring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your tests does not pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -541,15 +562,21 @@ class StringConstantChecker(BaseTokenChecker):
# Unicode strings.
UNICODE_ESCAPE_CHARACTERS = 'uUN'

string_tokens = {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this really should be instance attribute, no class attribute.
We also need to be sure that data gets thrown away before switching to new module for analysis (simple reinitialization of dict on the beginning of process tokens should work fine).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it manually, it is thrown away.
I'm going to try to make this an instance attribute, but it's bit annoying that you precisely recommended a class attribute in one of your earlier comment :(

Do you want to add a unit test ?
If so, could you please then point me to an existing test I could use as an example to perform such "reinitialization" ?

# This check relies on the asumption that StringConstantChecker is run beforehand
for elt in iterable_node.elts:
if isinstance(elt, astroid.node_classes.Const) and elt.pytype() == 'builtins.str':
if StringConstantChecker.string_tokens[(elt.lineno, elt.col_offset)] != elt.value:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, checker classes really should be independent, consider doing your process tokens inside StringFormatChecker

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by introducing IAstroidAndTokensChecker interface

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 21, 2017

Tests are failing with Python 2 interpreter.
I'm going to install one on my machine to figure out why (probably either the AST walker or the tokenizer behave differently in regard to string literals concatenation)

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 24, 2017

I fixed this hook for Python 2

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 25, 2017

I don't quite get why the pylint tox environment is failing.
There are many [R]efactor messages but they all seem to have been preexisting

@@ -545,11 +588,11 @@ def process_module(self, module):
self._unicode_literals = 'unicode_literals' in module.future_imports

def process_tokens(self, tokens):
for (tok_type, token, (start_row, _), _, _) in tokens:
for (tok_type, token, start, _, _) in tokens:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is redundant

if tok_type == tokenize.STRING:
# 'token' is the whole un-parsed token; we can look at the start
# of it to see whether it's a raw or unicode string etc.
self.process_string_token(token, start_row)
self.process_string_token(token, start[0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is redundant

@@ -527,7 +570,7 @@ class StringConstantChecker(BaseTokenChecker):
'String constant might be missing an r or u prefix.',
'anomalous-unicode-escape-in-string',
'Used when an escape like \\u is encountered in a byte '
'string where it has no effect.'),
'string where it has no effect.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change is redundant

@@ -79,6 +79,18 @@ class IAstroidChecker(IChecker):
"""


class IAstroidAndTokensChecker(IAstroidChecker):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't BaseTokenChecker exact same thing? From what I see BaseTokenChecker is a checker, which means it can involve walking ASTs and visiting nodes... Or am I missing something?

Copy link
Contributor Author

@Lucas-C Lucas-C Sep 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed

Copy link
Contributor Author

@Lucas-C Lucas-C Sep 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a side effect however:
making StringFormatChecker inherit from BaseTokenChecker and implement ITokenChecker forces to change all the .add_message call sites in this class, because it now requires a line parameter:
https://github.com/PyCQA/pylint/blob/master/pylint/utils.py#L374
https://github.com/PyCQA/pylint/blob/master/pylint/utils.py#L153

pylint/lint.py Outdated
@@ -844,10 +844,12 @@ def _do_check(self, files_or_modules):
and c is not self]
rawcheckers = [c for c in _checkers
if interfaces.implements(c, interfaces.IRawChecker)]
astcheckers = [c for c in _checkers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If previous comment is true, this won't be needed.

pylint/lint.py Outdated
# notify global begin
for checker in _checkers:
checker.open()
if interfaces.implements(checker, interfaces.IAstroidChecker):
if checker in astcheckers:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If previous comment is true, this won't be needed.

pylint/lint.py Outdated
@@ -868,7 +870,7 @@ def _do_check(self, files_or_modules):
# fix the current file (if the source file was not available or
# if it's actually a c extension)
self.current_file = ast_node.file # pylint: disable=maybe-no-member
self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers, astcheckers)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If previous comment is true, this won't be needed.

pylint/lint.py Outdated
@@ -922,7 +924,7 @@ def get_ast(self, filepath, modname):
self.add_message('astroid-error', args=(ex.__class__, ex))

def check_astroid_module(self, ast_node, walker,
rawcheckers, tokencheckers):
rawcheckers, tokencheckers, astcheckers):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If previous comment is true, this won't be needed.

pylint/lint.py Outdated
@@ -946,6 +948,9 @@ def check_astroid_module(self, ast_node, walker,
checker.process_module(ast_node)
for checker in tokencheckers:
checker.process_tokens(tokens)
for checker in astcheckers:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If previous comment is true, this won't be needed.

tox.ini Outdated
@@ -7,7 +7,7 @@ deps =
git+https://github.com/pycqa/astroid@master
isort

commands = pylint -rn --rcfile={toxinidir}/pylintrc --load-plugins=pylint.extensions.docparams, pylint.extensions.mccabe {envsitepackagesdir}/pylint
commands = pylint -rn --rcfile={toxinidir}/pylintrc --load-plugins=pylint.extensions.docparams,pylint.extensions.mccabe {envsitepackagesdir}/pylint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if lack of previous warnings was caused by this bug in tox.ini, please revert it for now. We can tackle this problem in another commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you want

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 27, 2017

3 failing tests remain:

All those failing tests are a consequence of the modified call to add_message I mentioned above.
Should I go on and fix all those tests ?

Copy link
Contributor

@rogalski rogalski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if anything requires further clarification.

pylint/utils.py Outdated
@@ -359,7 +359,7 @@ def add_message(self, msg_descr, line=None, node=None, args=None, confidence=UND

If provided, the message string is expanded using args

AST checkers should must the node argument (but may optionally
AST checkers should provide the node argument (but may optionally
Copy link
Contributor

@rogalski rogalski Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that you modified existing add_message calls due to this documentation entry. From your case it's clear that it may be misleading.

I'd suggest an entry:

All emitted messages shall provide at minimum either line in which violation occurred or AST node in which violation occurred. Passing both values is also accepted.

Feel free to rephrase if you have better idea.

Copy link
Contributor Author

@Lucas-C Lucas-C Sep 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually no, it doesn't work like this :(
If the checker implements IRawChecker or ITokenChecker, a line parameter must be passed in .add_message, else there must be a node passed:
https://github.com/PyCQA/pylint/blob/master/pylint/utils.py#L153
https://github.com/PyCQA/pylint/blob/master/pylint/utils.py#L374

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I did not picked that up when I did review yesterday.

I'm not familiar with this part of the repository, so I cannot give a straightforward answer right now. I'd suggest extracting a new class for your check and wrap everything up so all tests pass (without modifying preexisting test suite). Then we can wait for @PCManticore input on how to tackle this hybrid AST/token checker in terms of emitting messages from them and documenting those checkers in our docs.

@Lucas-C Lucas-C changed the title W1403: Adding str-literals-concatenation-and-comma W1403: Adding implicit-str-concat-in-sequence Sep 29, 2017
@Lucas-C Lucas-C changed the title W1403: Adding implicit-str-concat-in-sequence Adding implicit-str-concat-in-sequence check Sep 29, 2017
@Lucas-C
Copy link
Contributor Author

Lucas-C commented Sep 29, 2017

I think this is ready to be merged

@rogalski rogalski dismissed their stale review September 29, 2017 14:40

Some changes addressed, some changes needs further discussion

@rogalski rogalski added Needs review 🔍 Needs to be reviewed by one or multiple more persons and removed reviewed-waiting-updates labels Sep 29, 2017
Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of things I'm not convinced off. I'd like to see the new message disabled in pylintrc in order to see what exactly we have in our codebase. I do hope that this won't include multiline strings such as those from our message definitions

@@ -166,6 +166,6 @@ A Typical Development Workflow
It is also possible to give tox a `pytest specifier <https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests>`_
to run only your test::

$ tox pylint/test/test_functional.py::test_functional
$ tox -e py36 -- -k 'test_functional[str_literals_concatenation_and_comma]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing this?

@@ -166,6 +166,6 @@ A Typical Development Workflow
It is also possible to give tox a `pytest specifier <https://docs.pytest.org/en/latest/usage.html#specifying-tests-selecting-tests>`_
to run only your test::

$ tox pylint/test/test_functional.py::test_functional
$ tox -e py36 -- -k 'test_functional[implicit_str_concat_in_sequence]'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you modify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To help future contributors by showing more useful CLI flags:

  • the ability to execute the tests in only one tox environment
  • the ability to execute only one functional test

self.process_string_token(token, start_row)
self.process_string_token(token, start[0])
try:
self.string_tokens[start] = ast.literal_eval(token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of literal_evaling these tokens?

Copy link
Contributor Author

@Lucas-C Lucas-C Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To get the string value of a token, which is itself a string variable.
There are some examples of token values:

  • "'a'"
  • "u'b'"
  • "r'b'"
  • "'b \\\n c'"

pylintrc Outdated
@@ -52,7 +52,8 @@ confidence=
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"

disable=invalid-name,protected-access,fixme,too-many-branches,
disable=implicit-str-concat-in-sequence,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where exactly do we have this occurring in our code base? It would be nice to see them before merging, since this usually can reveal false positives and whatnot, things we should account for.

Copy link
Contributor Author

@Lucas-C Lucas-C Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 220 violations :(

And yes, this is because of the way warning message are defined.
For example there is the line where the 1st warning is raised:
https://github.com/PyCQA/pylint/blob/master/pylint/extensions/mccabe.py#L131

Interestingly, it is not consistent, and sometimes the newline is escaped:
https://github.com/PyCQA/pylint/blob/master/pylint/checkers/exceptions.py#L62

What do you advise ?
Replace all string concatenations by escaped newlines ? :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was afraid this is going to happen with this PR, it will emit even for use cases that are valid, such as the ones from pylint's message definition. Given this, I'm finding the new check too nitpicky. If we were to include this in pylint, then we should restrict it to verify just the implicit string concatenation that occurs on the same line, not on multiple lines.


def check_for_concatenated_strings(self, iterable_node, iterable_type):
for elt in iterable_node.elts:
if isinstance(elt, Const) and elt.pytype() in _AST_NODE_STR_TYPES:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably check the type of elt.value instead of using pytype

Copy link
Contributor Author

@Lucas-C Lucas-C Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2nd member of this conditional serves to distinguish between e.g. string constants and integer constants.
Are you suggesting to do something like the following code ?

if isinstance(elt, Const) and isinstance(elt.value, six.string_types):

@PCManticore PCManticore added reviewed-waiting-updates and removed Needs review 🔍 Needs to be reviewed by one or multiple more persons labels Sep 29, 2017
Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lucas-C left a comment. I think this will be too nitpicky since it picks on valid use cases, such as implicit joining on multiple lines, which will generate a ton of errors. This PR should restrict the check only for string concatenation on the same line.

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Oct 12, 2017

tl;dr : I disagree but I made the required changes

While I totally agree with the checker beeing nickpicky, I think ignoring string concatenations over newlines also restrict the use of this warning.

For example, no warning will be raised for this code:

LIST = (
    'item1',
    'item2'
    'item3'
)

Whether or not it appears in pylint code base, I don't think it is very good code style to have string literal implicit concatenation in comma-separated lists/sets/tuples.
And I think pylint should let users decide on the matter by enabling or not this warning, in its most strict form.

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Dec 15, 2017

I rebased this PR on the master branch. Are you OK to merge it ?

@PCManticore
Copy link
Contributor

@Lucas-C Yes, just didn't get to it just yet

@vicyap
Copy link

vicyap commented Dec 15, 2017

I like what @Lucas-C said here: #1655 (comment). It would be useful to also include a check for accidental multiline string concatenations in sequences. Perhaps this could be included but default disabled?

@Lucas-C
Copy link
Contributor Author

Lucas-C commented May 14, 2018

I juste rebased this PR so it is not conflicting to merge it.
I don't want to put any pressure on closing this, but maybe the reviewed-waiting-updates tag is misleading and should be removed.

@coveralls
Copy link

coveralls commented May 14, 2018

Coverage Status

Coverage increased (+0.02%) to 89.706% when pulling e57b2ef on voyages-sncf-technologies:master into 0dd573f on PyCQA:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 89.924% when pulling 02c0765 on voyages-sncf-technologies:master into 36a0027 on PyCQA:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 89.924% when pulling 02c0765 on voyages-sncf-technologies:master into 36a0027 on PyCQA:master.

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Lucas-C Sorry for the extreme long wait! Thanks for rebasing this PR. The only change that I'd like is the use of ast.literal_eval. Other than that, this PR looks fine. Don't forget the usual boilerplate, an entry in Contributors and a What's New entry in 2.0 rst.

@Lucas-C
Copy link
Contributor Author

Lucas-C commented May 24, 2018

This should be good

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Jun 15, 2018

I don't understand the last error in the Travis CI build:

pylint/lib/python3.5/site-packages/pylint/checkers/utils.py:893:19: E1124: Argument 'qnames' passed by position and keyword in function call (redundant-keyword-arg)

@rkrzr
Copy link

rkrzr commented Aug 24, 2018

I'd also be interested in getting this PR merged, since I have gotten bitten by this problem before.

Thanks for the good work @Lucas-C .

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Oct 8, 2018

One year since the first version of this PR... :)
I updated it in order to fix the merge conflicts & failing tests.
Seems good to merge
What do you think @PCManticore ?

@PCManticore PCManticore merged commit fcc0151 into pylint-dev:master Oct 10, 2018
@PCManticore
Copy link
Contributor

@Lucas-C Thank you! Thank you for waiting over an year to get this merged, it's mostly my fault on not getting to it sooner.

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Oct 11, 2018

No need to blame yourself, there's no problem.
Thank you for merging it ! I'm glad it's done :)

@ghost
Copy link

ghost commented Jan 26, 2019

I'm interested in getting this warning when implicitly concatenating across lines. If I'm reading the thread correctly, that was implemented but changed. Is there a simple snippet I can use to get that behavior, perhaps in a plugin?

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Jan 28, 2019

You should get a warning with this code and pylint 2.2.2:

t = ('a', 'b' 'c')

Example:

$ bin/pylint test.py
************* Module test
test.py:1:0: W1403: Implicit string concatenation found in tuple (implicit-str-concat-in-sequence)

--------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 10.00/10, -10.00)

@ghost
Copy link

ghost commented Jan 28, 2019

Right, thanks.

"""Pylint 2.2 should warn implicit-str-concat-in-sequence.
https://github.com/PyCQA/pylint/pull/1655

pylint 2.2.2
astroid 2.1.0
Python 3.6.7
[GCC 8.2.0]

Current result:
names.py:13:0: W1403: Implicit string concatenation found in list (implicit-str-concat-in-sequence)

"""

X = ["a", "b" "c", "d"]

Y = ["a",
     "b"
     "c",
     "d"
]

print(len(X))
print(len(Y))

I'm interested in getting a warning for the multi-line case, Y in the above example. From this comment, I think the warning was added but removed before release. Is there a simple snippet I can use to get that behavior, perhaps in a plugin?

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Jan 28, 2019

Yes, your deductions are totally right.
I was also in favor of getting warnings in the multi-line case.
I do not know of any such option/flag mechanism builtin in pylint, but this is my only contribution to this project so others may be more helpful.
It should probably be doable with a plugin, but I do not know of any existing one that would provide you this behavior. You can try to develop one yourself, I would use it for sure :)

@PCManticore
Copy link
Contributor

FWIW, I would be in favour of implicit-str-concat-in-sequence to have an option for picking multiline cases as well, as long as it is not the default value.

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Jan 30, 2019

Thanks for your input @PCManticore
Would you have any suggestion on how such option could be implemented in pylint ? Would that mean another checker ID ?
Also, maybe we should move this discussion to a new issue instead of the bottom of a merged PR :)

@PCManticore
Copy link
Contributor

@Lucas-C There's no need for a new check, as long as this one can look for that flag when deciding for multiline vs same line behaviour, that should be enough. Here's some rough instructions:

  • Each checker can have an options configuration like this. That new options should go there.
  • Then in the check code itself, you can access any option with self.config.<name of the option with underscores>.
  • The new option could then be used both at CLI and in the configuration file.

Let me know if that makes sense, happy to discuss in a separate issue.

@Lucas-C
Copy link
Contributor Author

Lucas-C commented Jan 30, 2019

Thank you for those clear guidelines.
I just sent a PR implementing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants