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

Detect missed trailing whitespace in concatenated messages #1835

Open
orsinium opened this issue Jan 26, 2021 · 0 comments
Open

Detect missed trailing whitespace in concatenated messages #1835

orsinium opened this issue Jan 26, 2021 · 0 comments
Labels
rule request Adding a new rule

Comments

@orsinium
Copy link
Collaborator

Rule request

Thesis

Sometimes, a plaintext message is split by a few separate string literals with concatenation. And sometimes a whitespace is missed. For example:

message = "An error occurred."  # <- would have a whitespace at the end.
message += "Try to call for help."
print(message)
# An error occurred.Try to call for help.

Reasoning

For human-facing messages, it is a typo.

Implementation

The challenge is to make an effective heuristic to detect when it is a plain message and when it is something else (for machines). Please, share your examples. Do you have string concatenation for something else rather than for human-facing messages?

Examples I have in mind:

  • SQL queries. For them, prefer multiline strings instead of concatenation, SQL databases are pretty fine with newlines in queries.
  • URLs. I'd say, it's better just not to split them (see Smart code line length validation #1182)
@orsinium orsinium added the rule request Adding a new rule label Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule request Adding a new rule
Projects
None yet
Development

No branches or pull requests

1 participant