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

Naming conventions with regex #737

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

Conversation

pawelsag
Copy link
Contributor

@pawelsag pawelsag commented Apr 2, 2021

Fixes: #310

But first, the #651 need to be merged

@googlebot googlebot added the cla: yes All contributors in pull request have signed the CLA with Google. label Apr 2, 2021
@pawelsag pawelsag marked this pull request as draft April 2, 2021 14:39
@hzeller
Copy link
Collaborator

hzeller commented Apr 3, 2021

mmh, I have to think about this. I don't like std::regex at all as it uses exceptions to indicate issues with parsing expressions, which is the wrong choice of error reporting, because it is not exceptional (besides the std:: implementation being very slow).

OTOH, we already use it a one place in the lint_waiver, for which we then explicitly enabled exceptions.

The reason why we used std::regex in lint_waiver was to be compatible in C++11, C++14 and C++17, which was not very possible with the preferred choice, re2 (due to some compatibility issues with StringPiece == std::string_view or not). Given that we are now somewhat tied to C++17, this might be worthwhile revisting.

For this change, this should not hold us back for now, and we should proceed for now assuming we use std::regex.

@pawelsag pawelsag force-pushed the naming_conventions_with_regex branch from 1155efc to 0bdae87 Compare April 9, 2021 08:59
@pawelsag pawelsag force-pushed the naming_conventions_with_regex branch from 0bdae87 to 240d2cf Compare April 9, 2021 09:06
@pawelsag pawelsag changed the title WIP: Naming conventions with regex Naming conventions with regex Apr 9, 2021
@pawelsag pawelsag marked this pull request as ready for review April 9, 2021 09:15
@pawelsag pawelsag requested a review from hzeller April 9, 2021 09:16
Copy link
Collaborator

@hzeller hzeller left a comment

Choose a reason for hiding this comment

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

Some initial comments; mostly I think we have to make it clear to the user that the regex are in addition to the thing that is already tested.

In the meantime I'll explore using RE2 instead of std::regex as I like to avoid exceptions (long story). But nothing to worry about for this PR, this is fairly straightforward to change.

static std::string basic_desc =
absl::StrCat("Checks that ", Codify("enum", description_type),
" names use lower_snake_case naming convention"
" and end with '_t' or '_e'. See ",
Copy link
Collaborator

Choose a reason for hiding this comment

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

.. and also the additional optional regular expression.

Otherwise the explanation looks a bit confusing to the user: tests for_t and _e ... and then there is a parameter with regular expressions - it is unclear from seeing that if that is replacing the _t, _e rule or augmenting it.

Similar in the other rules you added regexp: we should update the documentation to include the optional regexp capability.

Copy link
Contributor Author

@pawelsag pawelsag Apr 30, 2021

Choose a reason for hiding this comment

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

Ok so I changed the description as suggested, but I change the phrase to: or also the additional optional regular expression., cause we can use either regex or the original rule, but when regex is enabled we do not validate the old rules.

verilog/analysis/checkers/enum_name_style_rule.cc Outdated Show resolved Hide resolved
@pawelsag
Copy link
Contributor Author

Ok so if I understand you correctly when regex is enabled we should validate the regex, if the regex does not match, we should fall back to the already implemented rules, right?

@hzeller
Copy link
Collaborator

hzeller commented Apr 16, 2021

I was mostly thinking: we always check the built-in rule, and then, in addition, also the regexp. IIRC, that is how you implemented it.

Mostly it was important to me that we describe what we do in the description.

We could of course think of an either/or approach (if regexp defined, use that, otherwise use built-in rule).

@pawelsag pawelsag requested a review from hzeller April 30, 2021 09:51
nikhiljha pushed a commit to nikhiljha/verible that referenced this pull request Sep 27, 2022
…iance#737)

This is not a desirable solution, but it's better than as-is.

There's a couple of reasons for this:
1) lspconfig only enables these commands upon successful attachment of
   servers, which doesn't really fit their use case.
2) We gain direct access to new Lua APIs for defining user commands,
   allowing us to leverage Lua callbacks and functions instead of
   intermediary global variables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes All contributors in pull request have signed the CLA with Google.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for naming conventions
3 participants