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

Ruby: use the shared regex pack #11245

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

erik-krogh
Copy link
Contributor

@erik-krogh erik-krogh commented Nov 14, 2022

the commits should explain what's happening

Evaluation looks fine.

@erik-krogh erik-krogh requested a review from aibaars Nov 14, 2022
@erik-krogh erik-krogh marked this pull request as ready for review Nov 14, 2022
@erik-krogh erik-krogh requested a review from a team as a code owner Nov 14, 2022
msg = "This regular expression does not match script end tags like </script\\t\\n bar>."
)
}
private import codeql.ruby.regexp.RegExpTreeView::RegexTreeView as TreeView
Copy link
Contributor

@aibaars aibaars Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the repetitive RegExpTreeView::RegexTreeView . Is it really needed to have a RegexTreeView module in the RegexTreeView module?

Copy link
Contributor Author

@erik-krogh erik-krogh Nov 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as explained below I need a reference to a module instead of a file.

I could perhaps just do private import codeql.ruby.regexp.RegExpTreeView, but this was the thing I ended up with.

Copy link
Contributor

@aibaars aibaars left a comment

This looks good to me, thanks for splitting the changes in easy to review commits!

I don't really like the double import Impl statements. Is there a way to avoid exporting the same things twice under different names?

// exporting as RegexTreeView, and in the top-level scope.
import Impl as RegexTreeView
import Impl

@erik-krogh
Copy link
Contributor Author

erik-krogh commented Nov 14, 2022

This looks good to me, thanks for splitting the changes in easy to review commits!
I don't really like the double import Impl statements. Is there a way to avoid exporting the same things twice under different names?

I don't think there is another way, if we want to keep backwards compatibility.
My reasoning is:

  • A file cannot implement a module signature, only a module can do that.
    So I need the RegexTreeView module in order to have a module that implements the signature.
  • If I called the module RegexTreeView instead of Impl, then I would keep an ambiguous import when I did import RegexTreeView (because it can both reference the file and the module.).
    So I instead name the module Impl, and just re-export it as RegexTreeView, because I don't want the exported name to be Impl (or is that OK?).
  • Previously the RegExpTreeView file exported all the regex classes directly, so I need the import Impl in order to keep backwards compatibility.

@aibaars
Copy link
Contributor

aibaars commented Nov 14, 2022

This looks good to me, thanks for splitting the changes in easy to review commits!
I don't really like the double import Impl statements. Is there a way to avoid exporting the same things twice under different names?

I don't think there is another way, if we want to keep backwards compatibility. My reasoning is:

  • A file cannot implement a module signature, only a module can do that.
    So I need the RegexTreeView module in order to have a module that implements the signature.
  • If I called the module RegexTreeView instead of Impl, then I would keep an ambiguous import when I did import RegexTreeView (because it can both reference the file and the module.).
    So I instead name the module Impl, and just re-export it as RegexTreeView, because I don't want the exported name to be Impl (or is that OK?).
  • Previously the RegExpTreeView file exported all the regex classes directly, so I need the import Impl in order to keep backwards compatibility.

Yeah, I was afraid of that. Thanks for explaining. Sounds like we don't have much choice.

@erik-krogh erik-krogh requested a review from aibaars Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants