Skip to content

Precise WPS226 line/column number #3267

@ishonichev

Description

@ishonichev

WPS226 violation points to the file itself (line 0, column 1).
Why not to point to the beginning of the first string literal occurrence?
There won't be need to copy string from terminal, then searching it (most useful for large files).

flake8 output:

.\Jupyter [main +1 ~4 -0 !]> flake8 .\fbg5\monitor.py --select=WPS
.\fbg5\monitor.py:0:1: WPS226 Found string literal over-use: color > 3
.\fbg5\monitor.py:0:1: WPS226 Found string literal over-use: white > 3

Suggested output:

.\Jupyter [main +1 ~4 -0 !]> flake8 .\fbg5\monitor.py --select=WPS
.\fbg5\monitor.py:23:22: WPS226 Found string literal over-use: color > 3
.\fbg5\monitor.py:23:31: WPS226 Found string literal over-use: white > 3

Here is the example code:

import logging
import coloredlogs

BUFFER_SIZE = 1024
TEMP_LIMIT = 15
TEMP_FMT = "%.1f/%.1f"

logger = logging.getLogger("fbg5")
logger.setLevel(logging.INFO)

console_handler = logging.StreamHandler()
console_handler.setLevel(logging.INFO)

formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
console_handler.setFormatter(formatter)

logger.addHandler(console_handler)
coloredlogs.install(
    level="INFO",
    logger=logger,
    fmt="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    field_styles={
        "asctime": {"color": "white"},
        "name": {"color": "white"},
        "levelname": {"color": "white"},
        "message": {"color": "white"},
    },
    level_styles={
        "info": {"color": "green"},
        "warning": {"color": "yellow"},
        "error": {"color": "red"},
        "critical": {"color": "red", "bold": True},
    },
)

P.S. I hope, it's related to WPS not to flake8 itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueEntrypoint to the projecthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions