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

Enable Rubocop ambiguity warnings #1180

Merged
merged 14 commits into from Jun 17, 2019

Conversation

pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Jun 13, 2019

Rouge currently disables Rubocop's AmbiguousRegexpLiteral cop and its Lint/AmbiguousOperator. Presumably this was because of the large number of regular expressions used in Rouge that are defined using the /.../ literal syntax.

This commit prepends all regular expressions of that form with %r. It also tidies up a few uses of the *%w() construct that are present in the codebase. This allows these warnings to be turned on without causing any issues.

It should be noted that having the warnings disabled is not a problem in and of itself. However, these constructs also raise warnings when running Ruby with the -w switch. Getting Rouge to a point where it can be run with the -w switch will allow for a safer development environment.

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Jun 13, 2019
Rouge currently disables Rubocop's AmbiguousRegexpLiteral cop and its
Lint/AmbiguousOperator. Presumably this was because of the large number
of regular expressions used in Rouge that are defined using the `/.../`
literal syntax.

This commit prepends all regular expressions of that form with `%r`. It
also tidies up a few uses of the `*%w()` construct that are present in
the codebase. This allows these warnings to be turned on without causing
any issues.

It should be noted that having the warnings disabled is not a problem in
and of itself. However, these constructs also raise warnings when
running Ruby with the `-w` switch. Getting Rouge to a point where it can
be run with the `-w` switch will allow for a safer development
environment.
.rubocop.yml Outdated Show resolved Hide resolved
espositoandrea and others added 3 commits June 16, 2019 22:15
This adds support for the Brainfuck language.
Reset the value of `@all` only if it has been defined.
The Python lexer only supported minor version numbers for shebangs
involving `python2`. Minor versions of Python 3 should also be included.
This commit corrects that problem and supports minor version numbers
higher than 9.
@pyrmont
Copy link
Contributor Author

pyrmont commented Jun 17, 2019

If this PR is merged, I'm not sure what to do about the lexers that have been proposed in outstanding PRs and that don't use the %r syntax. I'm sort of loathe to ask the authors (who've been waiting so long) to go back and write their regexs in this format and yet if they don't, the Travis output is going to be a mess. Not sure what to do.

@ashmaroli
Copy link
Contributor

@pyrmont My recommendation would be to merge this a.s.a.p. Then, handle the remaining warnings before tackling backlog PRs.. (#1189 reduces warnings further)

@pyrmont
Copy link
Contributor Author

pyrmont commented Jun 17, 2019

Yeah, that's probably the right way forward. I need to rebase this against master to fix the Brainfuck lexer. Should be able to do that tonight. Can then merge.

ashmaroli and others added 7 commits June 17, 2019 21:01
This commit allows for the Rake tasks to be run with warnings enabled.
It also creates a task for the Travis CI builds that runs with warnings enabled.
Rouge currently disables Rubocop's AmbiguousRegexpLiteral cop and its
Lint/AmbiguousOperator. Presumably this was because of the large number
of regular expressions used in Rouge that are defined using the `/.../`
literal syntax.

This commit prepends all regular expressions of that form with `%r`. It
also tidies up a few uses of the `*%w()` construct that are present in
the codebase. This allows these warnings to be turned on without causing
any issues.

It should be noted that having the warnings disabled is not a problem in
and of itself. However, these constructs also raise warnings when
running Ruby with the `-w` switch. Getting Rouge to a point where it can
be run with the `-w` switch will allow for a safer development
environment.
@ashmaroli
Copy link
Contributor

ashmaroli commented Jun 17, 2019

@pyrmont I see that you occasionally use squash-merge when merging PRs. In that case, you need not rebase a PR to master. Just pulling the master should suffice. Of course it'll add a merge commit. But you can handle that at the time of squash-merge.
The advantage of this route is that the total commits of the PR in GitHub UI don't blow up..

@pyrmont pyrmont merged commit f31a5ee into rouge-ruby:master Jun 17, 2019
@pyrmont
Copy link
Contributor Author

pyrmont commented Jun 17, 2019

@ashmaroli Oh, that sounds handy. So you're saying in future that I would do the following?

  1. run git fetch upstream;
  2. switch to my development branch (eg. git checkout <name-of-local-branch>);
  3. pull master (eg. git pull master).

And that's it?

@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Jun 17, 2019
@ashmaroli
Copy link
Contributor

So you're saying in future that I would do the following?

Actually no. The steps are:

# checkout PR branch
git checkout feature/branch

# Pull in changes from upstream's 'master' branch.
# Resolve any merge conflicts along the way.
# Note: This creates a merge commit if there are unmerged commits in the PR branch.
git pull upstream master

# push current snapshot of PR branch to remote
git push origin feature/branch

@pyrmont
Copy link
Contributor Author

pyrmont commented Jun 17, 2019

@ashmaroli Thank you—good to know! :)

@pyrmont pyrmont deleted the bugfix.rubocop-warnings branch January 8, 2020 20:06
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

Successfully merging this pull request may close these issues.

None yet

3 participants