wemake-services / wemake-services/wemake-python-styleguide
Detect missed trailing whitespace in concatenated messages
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 430
- Avg merge
- 5h 14m
- Merged PRs (30d)
- 34
Description
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 #1182)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the proposed examples and deciding how to distinguish human-facing messages from SQL, URLs, and other machine-oriented concatenations. Define the heuristic and its edge cases, then add coverage showing that missed whitespace is reported without flagging valid concatenation; no implementation files or tests are named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100