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

Please keep the comment position in csgrep output #95

Open
praiskup opened this issue Nov 14, 2022 · 4 comments
Open

Please keep the comment position in csgrep output #95

praiskup opened this issue Nov 14, 2022 · 4 comments

Comments

@praiskup
Copy link
Member

See the "Added warnings" comment, it is not assigned to any report:

$ cat /tmp/test.err
# ================
#  Added warnings
# ================

Error: MYPY_ERROR:
copr_backend/constants.py:9: mypy[error]: Need type annotation for "DEF_REPOS" (hint: "DEF_REPOS: List[<type>] = ...")

Error: MYPY_ERROR:
copr_backend/constants.py:13: mypy[error]: Need type annotation for "DEF_MACROS" (hint: "DEF_MACROS: Dict[<type>, <type>] = ...")

Error: MYPY_ERROR:
copr_backend/helpers.py:26: mypy[error]: Library stubs not installed for "pytz" (or incompatible with Python 3.11)

Error: MYPY_NOTE:
copr_backend/helpers.py:26: mypy[note]: Hint: "python3 -m pip install types-pytz"

Error: MYPY_NOTE:
copr_backend/helpers.py:26: mypy[note]: (or run "mypy --install-types" to install all missing stub packages)

Error: MYPY_NOTE:
copr_backend/helpers.py:26: mypy[note]: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

Error: MYPY_ERROR:
copr_backend/helpers.py:31: mypy[error]: Library stubs not installed for "redis" (or incompatible with Python 3.11)

Error: MYPY_NOTE:
copr_backend/helpers.py:31: mypy[note]: Hint: "python3 -m pip install types-redis"
i

But csgrep assigns the rport to one of the issues:

$ csgrep -v --path copr_backend/helpers.py < /tmp/test.err
Error: MYPY_ERROR:
# ================
#  Added warnings 
# ================
copr_backend/constants.py:9: mypy[error]: Need type annotation for "DEF_REPOS" (hint: "DEF_REPOS: List[<type>] = ...")

Error: MYPY_ERROR:
copr_backend/constants.py:13: mypy[error]: Need type annotation for "DEF_MACROS" (hint: "DEF_MACROS: Dict[<type>, <type>] = ...")
@kdudka
Copy link
Member

kdudka commented Nov 14, 2022

This is currently not possible. Each comment belongs to a specific defect in the internal representation, which is shared by all the supported data formats. At the moment, csdiff supports 8 input and 3 output formats.

@praiskup
Copy link
Member Author

I'm not in hurry at all. I just wanted to report this.

@kdudka
Copy link
Member

kdudka commented Nov 14, 2022

If we allowed comments not "owned" by any defect, how would the plain-text parser distinguish them from the per-defect comments that we use today? Some developers write comments before the defects while others write comments after the defects. Empty lines are intentionally ignored in this format.

@praiskup
Copy link
Member Author

Aaah, you are right, now I see (I have a bad feeling I already reported this before, sorry).

I.e. indeed, there would have to be an additional rule in the format. Like \n\n implying an independent comment (it would be OK if csgrep filtered this out entirely). To me, this still doesn't sound that bad compared to the current behavior - a seemingly error-related comment (might be actually related to a set of errors) is moved down so it looks like a event-related one.

Perhaps we could define three types of comments, generic (separated by multiple newlines), error-related (on top of the ERROR header, single newline-separated) and event-related (on top of the event, single-newline-separated, this way csgrep prints the comment now).

I can imagine this is not a trivial thing to implement though.

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

No branches or pull requests

2 participants