clarat-org/clarat — pull request #8 by Twiek (2014-09-24 15:29:32+00:00)
Title: Pleasing rubocop

Hier müssen wir auch diverse Grundsatzentscheidungen treffen. Bei Gelegenheit bitte mal die unten aufgeführten Beispiele anschauen, den Code durchgehen und mich dann ansprechen.

Examples:
app/controllers/application_controller.rb:1:1: C: Missing top-level class documentation comment.
class ApplicationController < ActionController::Base
Basti: Rausnehmen!

app/controllers/application_controller.rb:18:7: C: Do not prefix reader method names with get_.
def get_language
^^^^^^^^^^^^
Basti: Häh? Warum?

app/controllers/offers_controller.rb:16:3: C: Keep a blank line before and after private.
private
^^^^^^^
Basti: Finde ich gut.
Related question: Indentation of private methods?

Auch Kommentare fallen unter das 80 character limit?
Basti: Nein, wenn sie hinter dem Code kommen, ja, wenn sie alleine stehen (die Zeile nur aus Kommentar besteht!? Praktikabel?
Bonusfrage: Wenn ein Kommentar dann zweizeilig wird, werden dann die Zeilen 2+ weiter eingerückt wie hier vorgeschlagen: https://github.com/bbatsov/ruby-style-guide#comment-annotations

^^^^^^^^^^^^^^^^^^
app/models/location.rb:26:13: C: Use && instead of and.
if name and !name.empty?
Basti: Ja.

app/models/offer.rb:16:25: C: %w-literals should be delimited by ( and )
enumerize :reach, in: %w[local variable national]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Basti: Zumindest im Beispiel finde ich [ und ] besser.

app/models/offer.rb:40:7: C: Use a guard clause instead of wrapping the code inside a conditional expression.
if self.location && self.location.organization_id != self.organization_id
^^
Basti: Nö (http://thechrisoshow.com/2009/02/16/using-guard-clauses-in-your-ruby-code/).

app/models/offer.rb:40:60: C: Redundant self detected.
if self.location && self.location.organization_id != self.organization_id
^^^^^^^^^^^^^^^^^^^^
Basti: Ja.

app/models/offer.rb:41:41: C: Prefer single-quoted strings when you don't need string interpolation or special symbols.
errors.add(:location_id, I18n.t("validations.offer.location_fits_organization.location_error"))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Basti: Ja.

app/models/tag.rb:4:5: C: Align the parameters of a method call if they span more than one line.
class_name: 'Tag',
^^^^^^^^^^^^^^^^^^
Basti: Eigentlich ja, aber im konkreten Beispiel sehr komisch

app/models/tag.rb:17:5: C: Favor modifier if usage when having a single-line body. Another good alternative is the usage of control flow &&/||.
if name
^^
Basti: Eigentlich ja, aber eventuell täuscht es uns dann bei der Testabdeckung

app/models/user.rb:6:35: C: Put a space before an end-of-line comment.
devise :database_authenticatable#, :registerable,
^^^^^^^^^^^^^^^^^
Basti: Finde ich gut

app/models/website.rb:11:27: C: Use %r for regular expressions matching more than 1 '/' character.
validates :url, format: /https?:\/\/\S+\.\S+/, uniqueness: true, presence: true
^^^^^^^^^^^^^^^^^^^^^

app/models/website.rb:11:27: C: Use %r for regular expressions matching more than 1 '/' character.
validates :url, format: /https?:\/\/\S+\.\S+/, uniqueness: true, presence: true
^^^^^^^^^^^^^^^^^^^^^
Basti: Eher nicht…

app/objects/form/search_form.rb:12:14: W: Unused method argument - page. If it's necessary, use _ or _page as an argument name to indicate that it won't be used. You can also write as search(*) if you want the method to accept any arguments but don't care about them.
def search page
Basti: Ja.

app/objects/form/search_form.rb:12:14: C: Use def with parentheses when there are parameters.
def search page
Basti: Ja (für mich liest es sich leichter, wenn parameter IMMER in Klammern stehen)

app/objects/form/search_form.rb:15:4: C: Final newline missing.
end
Basti: Ja.

app/policies/application_policy.rb:14:17: C: Use the new Ruby 1.9 hash syntax.
scope.where(:id => record.id).exists?
Basti: Ja.

app/policies/application_policy.rb:54:1: C: 1 trailing blank lines detected.
Basti: Ja.

config/initializers/devise.rb:44:35: C: Space inside square brackets detected.
config.case_insensitive_keys = [ :email ]
Basti: Ja.

config/initializers/rails_admin.rb:42:12: W: Ambiguous negative number operator. Parenthesize the method arguments if it's surely a negative number operator, or add a whitespace to the right of the - if it should be a subtraction.
weight -3
Basti: Ja.

test/controllers/pages_controller_test.rb:4:1: C: Extra empty line detected at body beginning.
Basti: Ja.

test/test_helper.rb:7:7: C: Use nested module/class definitions instead of compact style.
class ActiveSupport::TestCase
Basti: Not sure if I even understand that...