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

Add rubocop, fix syntax #32

Merged
merged 4 commits into from
Mar 30, 2015
Merged

Conversation

shortdudey123
Copy link
Contributor

3rd PR from breaking up #27

I can break up each major syntax change into a separate commit if needed (i.e. quotes, 1.9 hash style, etc...)

require "rspec/core/rake_task"
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
Copy link
Member

Choose a reason for hiding this comment

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

Can we make the rule: always double quotes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reasoning for not using single quotes? Rubocop does not have a rule for forcing double quotes on non-interpolationed strings

Copy link
Member

Choose a reason for hiding this comment

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

  • For consistency; doing things one way, is better than doing things two ways. I'd like to stick with one form of quotes unless the situation requires something else. Double quotes fits most situations so we should stick with that.
  • For development speed; I don't want to have to change the quoting symbol when adding or removing interpolation to a string. That wastes time and effort.
  • Recommended in GitHub's styleguide for ruby https://github.com/styleguide/ruby

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm i wouldn't agree with the consistency part (Example: https://github.com/envato/pagerduty/pull/32/files#diff-b2dabed64552f7bd74f43e99df8d27dbR78). Most project use ' instead of " per option A of the original style guide at https://github.com/bbatsov/ruby-style-guide#consistent-string-literals

Robocop does not have a cop to force all double so there will be no checks on consistency if it switch it back.

Let me know if you still think it should be switched.

Copy link
Member

Choose a reason for hiding this comment

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

The instance you point to has a good reason to not use double quote delimiters; the string contains double quotes. To use double quote delimiters would mean escaping all the " characters. I don't advocate a hard rule of using " all the time. Rather I find it fits most of the time. So it's a good default. I like pragmatism.

Note that the style guide says:

The second style is arguably a bit more popular in the Ruby community. The string literals in this guide, however, are aligned with the first style.

That means " is arguably more popular than '.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, however this repo isn't standardized on ".

@@ -19,7 +18,7 @@
expect(transport).to have_received(:send_payload).with(
service_key: "a-test-service-key",
event_type: "trigger",
description: "a-test-description",
description: "a-test-description"
Copy link
Member

Choose a reason for hiding this comment

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

Does Rubocop check for trailing ,? What's the rationale behind this one?

I find it quite handy to have trailing ,; it's then fast to add lines and the diff is cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@orien
Copy link
Member

orien commented Mar 30, 2015

Thanks @shortdudey123!

orien added a commit that referenced this pull request Mar 30, 2015
@orien orien merged commit 769ca7f into envato:master Mar 30, 2015
@shortdudey123 shortdudey123 deleted the beef_up_testing branch March 30, 2015 01:31
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

2 participants