square / square-ruby-sdk

Ruby client library for the Square API
https://developer.squareup.com/docs
Other
69 stars 42 forks source link

rubocop reports 73 offenses detected #15

Closed tttlu closed 4 years ago

tttlu commented 4 years ago

Ran rubocop -c .rubocop.yml and got the following:

Inspecting 36 files
CC......C.....C....C..CC....CC..C.C.

Offenses:

spec/user_journey_spec.rb:6:10: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
describe "UserJourney" do
         ^^^^^^^^^^^^^
spec/user_journey_spec.rb:10:24: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  let(:phone_number) { "1-212-555-4240" }
                       ^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:11:25: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  let(:phone_number2) { "1-917-500-1000" }
                        ^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:12:23: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  let(:postal_code) { "10003" }
                      ^^^^^^^
spec/user_journey_spec.rb:13:24: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
  let(:postal_code2) { "98100" }
                       ^^^^^^^
spec/user_journey_spec.rb:17:9: C: Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
        "given_name": "Amelia",
        ^^^^^^^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:17:23: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        "given_name": "Amelia",
                      ^^^^^^^^
spec/user_journey_spec.rb:18:24: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        "family_name": "Earhart",
                       ^^^^^^^^^
spec/user_journey_spec.rb:20:17: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
        "note": "a customer",
                ^^^^^^^^^^^^
spec/user_journey_spec.rb:22:13: C: Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
            "address_line_1": "500 Electric Ave",
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:22:31: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            "address_line_1": "500 Electric Ave",
                              ^^^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:23:31: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            "address_line_2": "Suite 600",
                              ^^^^^^^^^^^
spec/user_journey_spec.rb:24:25: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            "locality": "New York",
                        ^^^^^^^^^^
spec/user_journey_spec.rb:25:48: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            "administrative_district_level_1": "NY",
                                               ^^^^
spec/user_journey_spec.rb:27:24: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
            "country": "US"
                       ^^^^
spec/user_journey_spec.rb:37:38: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    Square::Client.new(access_token: "bad_token")
                                     ^^^^^^^^^^^
spec/user_journey_spec.rb:48:8: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
    it "should contain following fields" do
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:73:1: C: Layout/EmptyLines: Extra blank line detected.
spec/user_journey_spec.rb:74:81: C: Metrics/LineLength: Line is too long. [104/80]
  # There is no sandbox support for V1 endpoints as production token is required for the following tests
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:84:81: C: Metrics/LineLength: Line is too long. [85/80]
  #     response = api.create_category(location_id: location_id, body: {name: name1})
                                                                                ^^^^^
spec/user_journey_spec.rb:97:81: C: Metrics/LineLength: Line is too long. [110/80]
  #     response = api.update_category(location_id: location_id, category_id: created_id, body: {name: name2})
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:102:81: C: Metrics/LineLength: Line is too long. [89/80]
  #     response = api.delete_category(location_id: location_id, category_id: created_id)
                                                                                ^^^^^^^^^
spec/user_journey_spec.rb:114:1: C: Layout/EmptyLines: Extra blank line detected.
spec/user_journey_spec.rb:119:81: C: Metrics/LineLength: Line is too long. [83/80]
      response = sq.customers.retrieve_customer(customer_id: created_customer[:id])
                                                                                ^^^
spec/user_journey_spec.rb:130:81: C: Metrics/LineLength: Line is too long. [98/80]
      response = sq.customers.update_customer(customer_id: created_customer[:id], body: customer2)
                                                                                ^^^^^^^^^^^^^^^^^^
spec/user_journey_spec.rb:136:81: C: Metrics/LineLength: Line is too long. [83/80]
      response = sq.customers.retrieve_customer(customer_id: created_customer[:id])
                                                                                ^^^
spec/user_journey_spec.rb:142:81: C: Metrics/LineLength: Line is too long. [81/80]
      response = sq.customers.delete_customer(customer_id: created_customer[:id])
                                                                                ^
examples/customers.rb:5:31: C: Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.
  access_token: 'ACCESS_TOKEN',
                              ^
examples/customers.rb:12:7: C: Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
      "given_name": "John",
      ^^^^^^^^^^^^^^^^^^^^
examples/customers.rb:12:21: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      "given_name": "John",
                    ^^^^^^
examples/customers.rb:13:22: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
      "family_name": "Smith",
                     ^^^^^^^
examples/customers.rb:15:11: C: Layout/IndentHash: Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
          "address_line_1": "500 Electric Ave",
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
examples/customers.rb:15:29: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          "address_line_1": "500 Electric Ave",
                            ^^^^^^^^^^^^^^^^^^
examples/customers.rb:16:29: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          "address_line_2": "Suite 600",
                            ^^^^^^^^^^^
examples/customers.rb:17:23: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          "locality": "New York",
                      ^^^^^^^^^^
examples/customers.rb:18:46: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          "administrative_district_level_1": "NY",
                                             ^^^^
examples/customers.rb:19:26: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          "postal_code": "98100",
                         ^^^^^^^
examples/customers.rb:20:22: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
          "country": "US"
                     ^^^^
examples/customers.rb:22:3: C: Layout/IndentHash: Indent the right brace the same as the start of the line where the left brace is.
  }
  ^
examples/customers.rb:43:80: C: Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
result = customers_api.update_customer(customer_id: created_customer_id, body: {"family_name": "Jackson"})
                                                                               ^
examples/customers.rb:43:81: C: Metrics/LineLength: Line is too long. [106/80]
result = customers_api.update_customer(customer_id: created_customer_id, body: {"family_name": "Jackson"})
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
examples/customers.rb:43:96: C: Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
result = customers_api.update_customer(customer_id: created_customer_id, body: {"family_name": "Jackson"})
                                                                                               ^^^^^^^^^
examples/customers.rb:43:105: C: Layout/SpaceInsideHashLiteralBraces: Space inside } missing.
result = customers_api.update_customer(customer_id: created_customer_id, body: {"family_name": "Jackson"})
                                                                                                        ^
lib/square/http/api_response.rb:33:30: C: Style/MultipleComparison: Avoid comparing a variable with multiple items in a conditional, use Array#include? instead.
          data.reject! { |k| k == :cursor || k == :errors }
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/square/api/payments_api.rb:142:81: C: Metrics/LineLength: Line is too long. [85/80]
    # @return [CancelPaymentByIdempotencyKeyResponse Hash] response from the API call
                                                                                ^^^^^
lib/square/api/inventory_api.rb:17:81: C: Metrics/LineLength: Line is too long. [83/80]
    # @return [RetrieveInventoryAdjustmentResponse Hash] response from the API call
                                                                                ^^^
lib/square/api/inventory_api.rb:91:81: C: Metrics/LineLength: Line is too long. [85/80]
    # @return [BatchRetrieveInventoryChangesResponse Hash] response from the API call
                                                                                ^^^^^
lib/square/api/inventory_api.rb:132:81: C: Metrics/LineLength: Line is too long. [84/80]
    # @return [BatchRetrieveInventoryCountsResponse Hash] response from the API call
                                                                                ^^^^
lib/square/api/inventory_api.rb:164:81: C: Metrics/LineLength: Line is too long. [86/80]
    # @return [RetrieveInventoryPhysicalCountResponse Hash] response from the API call
                                                                                ^^^^^^
lib/square/api/catalog_api.rb:27:81: C: Metrics/LineLength: Line is too long. [81/80]
    # @return [BatchDeleteCatalogObjectsResponse Hash] response from the API call
                                                                                ^
lib/square/api/catalog_api.rb:66:81: C: Metrics/LineLength: Line is too long. [83/80]
    # @return [BatchRetrieveCatalogObjectsResponse Hash] response from the API call
                                                                                ^^^
lib/square/api/catalog_api.rb:111:81: C: Metrics/LineLength: Line is too long. [81/80]
    # @return [BatchUpsertCatalogObjectsResponse Hash] response from the API call
                                                                                ^
lib/square/api/v1_items_api.rb:871:81: C: Metrics/LineLength: Line is too long. [93/80]
      _query_builder << '/v1/{location_id}/items/{item_id}/modifier-lists/{modifier_list_id}'
                                                                                ^^^^^^^^^^^^^
lib/square/api/v1_items_api.rb:913:81: C: Metrics/LineLength: Line is too long. [93/80]
      _query_builder << '/v1/{location_id}/items/{item_id}/modifier-lists/{modifier_list_id}'
                                                                                ^^^^^^^^^^^^^
lib/square/api/v1_items_api.rb:999:81: C: Metrics/LineLength: Line is too long. [85/80]
      _query_builder << '/v1/{location_id}/items/{item_id}/variations/{variation_id}'
                                                                                ^^^^^
lib/square/api/v1_items_api.rb:1044:81: C: Metrics/LineLength: Line is too long. [85/80]
      _query_builder << '/v1/{location_id}/items/{item_id}/variations/{variation_id}'
                                                                                ^^^^^
lib/square/api/v1_items_api.rb:1281:81: C: Metrics/LineLength: Line is too long. [94/80]
      _query_builder << '/v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options'
                                                                                ^^^^^^^^^^^^^^
lib/square/api/v1_items_api.rb:1326:81: C: Metrics/LineLength: Line is too long. [115/80]
      _query_builder << '/v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options/{modifier_option_id}'
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/square/api/v1_items_api.rb:1371:81: C: Metrics/LineLength: Line is too long. [115/80]
      _query_builder << '/v1/{location_id}/modifier-lists/{modifier_list_id}/modifier-options/{modifier_option_id}'
                                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/square/api/transactions_api.rb:215:81: C: Metrics/LineLength: Line is too long. [83/80]
      _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}'
                                                                                ^^^
lib/square/api/transactions_api.rb:257:81: C: Metrics/LineLength: Line is too long. [91/80]
      _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/capture'
                                                                                ^^^^^^^^^^^
lib/square/api/transactions_api.rb:308:81: C: Metrics/LineLength: Line is too long. [90/80]
      _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/refund'
                                                                                ^^^^^^^^^^
lib/square/api/transactions_api.rb:352:81: C: Metrics/LineLength: Line is too long. [88/80]
      _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/void'
                                                                                ^^^^^^^^
lib/square/api/reporting_api.rb:36:81: C: Metrics/LineLength: Line is too long. [96/80]
    # @return [ListAdditionalRecipientReceivableRefundsResponse Hash] response from the API call
                                                                                ^^^^^^^^^^^^^^^^
lib/square/api/reporting_api.rb:46:81: C: Metrics/LineLength: Line is too long. [93/80]
      _query_builder << '/v2/locations/{location_id}/additional-recipient-receivable-refunds'
                                                                                ^^^^^^^^^^^^^
lib/square/api/reporting_api.rb:102:81: C: Metrics/LineLength: Line is too long. [90/80]
    # @return [ListAdditionalRecipientReceivablesResponse Hash] response from the API call
                                                                                ^^^^^^^^^^
lib/square/api/reporting_api.rb:112:81: C: Metrics/LineLength: Line is too long. [86/80]
      _query_builder << '/v2/locations/{location_id}/additional-recipient-receivables'
                                                                                ^^^^^^
lib/square/api/mobile_authorization_api.rb:28:81: C: Metrics/LineLength: Line is too long. [85/80]
    # @return [CreateMobileAuthorizationCodeResponse Hash] response from the API call
                                                                                ^^^^^
lib/square/api_helper.rb:140:7: C: Style/RedundantReturn: Redundant return detected.
      return JSON.parse(json, symbolize_names: true)
      ^^^^^^
lib/square/api_helper.rb:164:27: C: Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.
    def self.custom_merge(a, b)
                          ^
lib/square/api_helper.rb:164:30: C: Naming/UncommunicativeMethodParamName: Method parameter must be at least 3 characters long.
    def self.custom_merge(a, b)
                             ^
lib/square/api_helper.rb:275:9: C: Style/DateTime: Prefer Date or Time over DateTime.
        DateTime.rfc3339(date_time)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/square/api_helper.rb:277:9: C: Style/DateTime: Prefer Date or Time over DateTime.
        DateTime.rfc3339(date_time + 'Z')
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

36 files inspected, 73 offenses detected

Using -a can auto fix these if the code quality is of a priority.

or maybe removing .rubocop.yml if rubocopy is not supposed to run against this repo.

havenwood commented 4 years ago

Thanks for the report! It looks like a combination of a few style fixes and tweaks to the .rubocop.yml should resolve this issue.

I'd suggest that we bump the Metrics/LineLength to 120, switch Layout/SpaceInsideHashLiteralBraces to no spaces, and then resolve the remaining style and layout issues at the generator level.

tttlu commented 4 years ago

Hmm... looks like quite a lot of fixes to me. Anyway, it's more of an FYI. Feel free to close this issue whenever you guys want to.