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

Alternative fix for already initialized constant #259

Merged
merged 1 commit into from
May 23, 2016

Conversation

dankohn
Copy link
Contributor

@dankohn dankohn commented May 15, 2016

Signed-off-by: Dan Kohn [email protected]

This is an alternative fix to #258. It also resolves #257 and addresses the comment #258 (comment) by @jacobbednarz.

@dankohn
Copy link
Contributor Author

dankohn commented May 15, 2016

Cc @david-a-wheeler

@jacobbednarz
Copy link
Contributor

You didn't need a new pull request for this one :P I would have been happy with just another (even squashed) commit on the other branch. No issues here though 👍

LGTM.

@dankohn
Copy link
Contributor Author

dankohn commented May 15, 2016

I just thought I'd show both options for clarity. These values are never falsey, so the conditional assignment works equivalently here.

But, I'm always happy to have the opportunity to learn things, in this case from this excellent blog post: http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html

Thanks for your review.

@oreoshake
Copy link
Contributor

Does moving the definitions inside of the namespace block do anything?

@dankohn
Copy link
Contributor Author

dankohn commented May 23, 2016

@oreoshake I just checked and moving the constant within the namespace block dankohn@4bc4012 still results in:

$ rake test
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:4: warning: already initialized constant INLINE_SCRIPT_REGEX
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:4: warning: previous definition of INLINE_SCRIPT_REGEX was here
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:5: warning: already initialized constant INLINE_STYLE_REGEX
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:5: warning: previous definition of INLINE_STYLE_REGEX was here
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:6: warning: already initialized constant INLINE_HASH_SCRIPT_HELPER_REGEX
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:6: warning: previous definition of INLINE_HASH_SCRIPT_HELPER_REGEX was here
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:7: warning: already initialized constant INLINE_HASH_STYLE_HELPER_REGEX
/Users/dan/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bundler/gems/secureheaders-4bc4012e8e5b/lib/tasks/tasks.rake:7: warning: previous definition of INLINE_HASH_STYLE_HELPER_REGEX was here
Run options: --seed 42631

# Running:

So, please consider accepting this PR.

@oreoshake oreoshake merged commit 0b19881 into github:master May 23, 2016
@oreoshake
Copy link
Contributor

@dankohn
Copy link
Contributor Author

dankohn commented May 23, 2016

Thanks!

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.

Reloading Rakefile causes already initialized constant errors
3 participants