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

Parser chokes on sobelow_skip comment with trailing content #168

Open
mikebveil opened this issue Aug 20, 2024 · 0 comments
Open

Parser chokes on sobelow_skip comment with trailing content #168

mikebveil opened this issue Aug 20, 2024 · 0 comments

Comments

@mikebveil
Copy link

mikebveil commented Aug 20, 2024

Consider a code snippet like this:

# sobelow_skip ["DOS.StringToAtom"] (atoms are a fixed set of table names in the DB schema)
defp get_table_sizes() do
    …
end

The explanation given at the end of the sobelow_skip line will cause parsing to silently fail for the whole file when --skip is used. This is a insidious failure, since it will seem like the comment is working but we're also now ignoring any other findings in the file.

This is because of a regex that runs during parsing to convert these comment lines to @sobelow module attribute statements. The regex replaces the first part of the line but not any trailing content, which becomes garbage at the end of the attribute statement.

I see two ways to fix the regex:

  1. Don't match if sobelow_skip is followed by other content. So we fail to skip the finding but the failure is visible to the user.
  2. Match the whole line and delete any trailing content. This seems the more reasonable way to go, and I've opened a PR (Issue #168: trailing content on an sobelow_ignore line silently breaks parsing #169).
mikebveil added a commit to mikebveil/sobelow that referenced this issue Aug 20, 2024
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

1 participant