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

Support disabling inspections in a specific line with a comment #444

Open
ilkecan opened this issue Oct 19, 2021 · 3 comments
Open

Support disabling inspections in a specific line with a comment #444

ilkecan opened this issue Oct 19, 2021 · 3 comments

Comments

@ilkecan
Copy link

ilkecan commented Oct 19, 2021

I want to disable an inspection for a specific line or a function. For example, the user could do this with a comment such as:

-- stan-disable-next-line STAN-0006
mapCyclic = zipWith id . cycle

or

mapCyclic = zipWith id . cycle  -- stan-disable-line STAN-0006

Is it feasible to implement something like this?

@ilkecan
Copy link
Author

ilkecan commented Oct 20, 2021

I realized it is already possible to disable a specific observation using the ignore variable:

# .stan.toml
ignore = [
    { id = "OBS-STAN-0006-NO6o1e-42:26" },
    { id = "OBS-STAN-0101-NO6o1e-11:12" },
    { id = "OBS-STAN-0103-NO6o1e-34:12" },
    { id = "OBS-STAN-0103-YrzpQi-26:19" },
    { id = "OBS-STAN-0103-YrzpQi-26:57" },
    { id = "OBS-STAN-0105-NO6o1e-46:13" },
    { id = "OBS-STAN-0105-NO6o1e-46:24" },
]

But the problem with this is that the observation ID depends on the line number and this requires manual bookkeeping if any line is removed or added before that line. So an option to ignore a line with a comment before or in that line would be more convenient.

@ilkecan ilkecan changed the title Support disabling inspections in scopes smaller than "file" Support disabling inspections in a specific line with a comment Oct 20, 2021
@drlkf
Copy link

drlkf commented Jan 3, 2024

commenting in addition to thumbsup for visibility, i think this is an essential feature for a static analyzer, especially with the recent inclusion of STAN in HLS

@tomjaguarpaw
Copy link
Collaborator

I agree with this. I suspect we should probably learn from how hlint does it. To get started it might make most sense to do the easiest possible thing and just copy how ormolu can be disabled in regions of code. What do people think?

stan currently has no active developers. I'm only maintaining stan to keep it building with newer GHCs. I will put this reasonably high on my stack of things to look at, but can't guarantee it will ever reach the top. I'm willing to assist someone who wants to tackle it though.

I don't know where to start to add this feature. The first step would be to determine in which part of the code it belongs.

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

No branches or pull requests

3 participants