Browse Source

Merge pull request #795 from Shopify/fix_hash_comma_rubocop

Fix rubocop trailing hash comma cop
Paulo Margarido 4 years ago
parent
commit
9416afd22d

+ 0 - 16
.rubocop_todo.yml

@@ -333,22 +333,6 @@ Style/TrailingCommaInArrayLiteral:
     - 'test/fulfillment_test.rb'
     - 'test/meta_test.rb'
 
-# Offense count: 66
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleForMultiline.
-# SupportedStylesForMultiline: comma, consistent_comma, no_comma
-Style/TrailingCommaInHashLiteral:
-  Exclude:
-    - 'lib/shopify_api/metafields.rb'
-    - 'lib/shopify_api/resources/fulfillment_order.rb'
-    - 'lib/shopify_api/resources/fulfillment_v2.rb'
-    - 'lib/shopify_api/resources/inventory_level.rb'
-    - 'test/fulfillment_order_test.rb'
-    - 'test/fulfillment_test.rb'
-    - 'test/fulfillment_v2_test.rb'
-    - 'test/marketing_event_test.rb'
-    - 'test/meta_test.rb'
-
 # Offense count: 2
 # Cop supports --auto-correct.
 # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods.

+ 1 - 1
lib/shopify_api/metafields.rb

@@ -11,7 +11,7 @@ module ShopifyAPI
 
       metafield.prefix_options = {
         resource: self.class.collection_name,
-        resource_id: id
+        resource_id: id,
       }
       metafield.save
       metafield

+ 16 - 16
lib/shopify_api/resources/fulfillment_order.rb

@@ -37,8 +37,8 @@ module ShopifyAPI
     def move(new_location_id:)
       body = {
         fulfillment_order: {
-          new_location_id: new_location_id
-        }
+          new_location_id: new_location_id,
+        },
       }
       keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:move, {}, body.to_json))
       load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
@@ -54,8 +54,8 @@ module ShopifyAPI
     def close(message: nil)
       body = {
         fulfillment_order: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post(:close, {}, body.to_json))
     end
@@ -64,8 +64,8 @@ module ShopifyAPI
       body = {
         fulfillment_request: {
           fulfillment_order_line_items: fulfillment_order_line_items,
-          message: message
-        }
+          message: message,
+        },
       }
       keyed_fulfillment_orders = keyed_fulfillment_orders_from_response(post(:fulfillment_request, {}, body.to_json))
       load_keyed_fulfillment_order(keyed_fulfillment_orders, 'original_fulfillment_order')
@@ -75,8 +75,8 @@ module ShopifyAPI
     def accept_fulfillment_request(message: nil)
       body = {
         fulfillment_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('fulfillment_request/accept', {}, body.to_json))
     end
@@ -84,8 +84,8 @@ module ShopifyAPI
     def reject_fulfillment_request(message: nil)
       body = {
         fulfillment_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('fulfillment_request/reject', {}, body.to_json))
     end
@@ -93,8 +93,8 @@ module ShopifyAPI
     def request_cancellation(message: nil)
       body = {
         cancellation_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post(:cancellation_request, {}, body.to_json))
     end
@@ -102,8 +102,8 @@ module ShopifyAPI
     def accept_cancellation_request(message: nil)
       body = {
         cancellation_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('cancellation_request/accept', {}, body.to_json))
     end
@@ -111,8 +111,8 @@ module ShopifyAPI
     def reject_cancellation_request(message: nil)
       body = {
         cancellation_request: {
-          message: message
-        }
+          message: message,
+        },
       }
       load_attributes_from_response(post('cancellation_request/reject', {}, body.to_json))
     end

+ 2 - 2
lib/shopify_api/resources/fulfillment_v2.rb

@@ -11,8 +11,8 @@ module ShopifyAPI
       body = {
         fulfillment: {
           tracking_info: tracking_info,
-          notify_customer: notify_customer
-        }
+          notify_customer: notify_customer,
+        },
       }
       load_attributes_from_response(post(:update_tracking, {}, body.to_json))
     end

+ 2 - 2
lib/shopify_api/resources/inventory_level.rb

@@ -33,7 +33,7 @@ module ShopifyAPI
       body = {
         location_id: location_id,
         inventory_item_id: inventory_item_id,
-        available: new_available
+        available: new_available,
       }
       body[:disconnect_if_necessary] = disconnect_if_necessary unless disconnect_if_necessary.nil?
       load_attributes_from_response(
@@ -45,7 +45,7 @@ module ShopifyAPI
       body = {
         location_id: location_id,
         inventory_item_id: inventory_item_id,
-        available_adjustment: available_adjustment
+        available_adjustment: available_adjustment,
       }
       load_attributes_from_response(
         self.class.post(:adjust, {}, body.to_json)

+ 23 - 23
test/fulfillment_order_test.rb

@@ -210,8 +210,8 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         closed['status'] = 'incomplete'
         request_body = {
           fulfillment_order: {
-            message: "Test close message."
-          }
+            message: "Test close message.",
+          },
         }
         fake(
           'fulfillment_orders',
@@ -240,15 +240,15 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         body = {
           original_fulfillment_order: fake_original_fulfillment_order,
           submitted_fulfillment_order: fake_submitted_fulfillment_order,
-          unsubmitted_fulfillment_order: fake_unsubmitted_fulfillment_order
+          unsubmitted_fulfillment_order: fake_unsubmitted_fulfillment_order,
         }
         request_body = {
           fulfillment_request: {
             fulfillment_order_line_items: [
               { id: 1, quantity: 1 }
             ],
-            message: 'Fulfill this FO, please.'
-          }
+            message: 'Fulfill this FO, please.',
+          },
         }
         fake(
           'fulfillment_orders',
@@ -260,7 +260,7 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)
         params = {
           fulfillment_order_line_items: [{ id: 1, quantity: 1 }],
-          message: "Fulfill this FO, please."
+          message: "Fulfill this FO, please.",
         }
         response_fulfillment_orders = fulfillment_order.request_fulfillment(params)
 
@@ -299,8 +299,8 @@ class FulFillmentOrderTest < Test::Unit::TestCase
             fulfillment_order_line_items: [
               { id: 1, quantity: 1 }
             ],
-            message: 'Fulfill this FO, please.'
-          }
+            message: 'Fulfill this FO, please.',
+          },
         }
         fake(
           'fulfillment_orders',
@@ -312,7 +312,7 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         fulfillment_order = ShopifyAPI::FulfillmentOrder.find(519788021)
         params = {
           fulfillment_order_line_items: [{ id: 1, quantity: 1 }],
-          message: "Fulfill this FO, please."
+          message: "Fulfill this FO, please.",
         }
         response_fulfillment_orders = fulfillment_order.request_fulfillment(params)
 
@@ -339,11 +339,11 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "LGTM. Accept this FO fulfillment request"
         request_body = {
           'fulfillment_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
-          fulfillment_order: fulfillment_order.attributes.merge(status: 'in_progress', request_status: 'accepted')
+          fulfillment_order: fulfillment_order.attributes.merge(status: 'in_progress', request_status: 'accepted'),
         }
         fake(
           'fulfillment_orders',
@@ -367,11 +367,11 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "LBTM. Reject this FO fulfillment request"
         request_body = {
           'fulfillment_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
-          fulfillment_order: fulfillment_order.attributes.merge(status: 'open', request_status: 'rejected')
+          fulfillment_order: fulfillment_order.attributes.merge(status: 'open', request_status: 'rejected'),
         }
         fake(
           'fulfillment_orders',
@@ -395,8 +395,8 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "Cancelling this please."
         request_body = {
           'cancellation_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         cancelling = ActiveSupport::JSON.decode(load_fixture('fulfillment_order'))
         cancelling['status'] = 'in_progress'
@@ -423,12 +423,12 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = 'Already in-progress. Reject this FO cancellation request'
         request_body = {
           'cancellation_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
           fulfillment_order: fulfillment_order.attributes.merge(status: 'cancelled',
-                                                                request_status: 'cancellation_accepted')
+                                                                request_status: 'cancellation_accepted'),
         }
         fake(
           'fulfillment_orders',
@@ -452,12 +452,12 @@ class FulFillmentOrderTest < Test::Unit::TestCase
         message = "Already in-progress. Reject this FO cancellation request"
         request_body = {
           'cancellation_request' => {
-            'message' => message
-          }
+            'message' => message,
+          },
         }
         fake_response = {
           fulfillment_order: fulfillment_order.attributes.merge(status: 'in_progress',
-                                                                request_status: 'cancellation_rejected')
+                                                                request_status: 'cancellation_rejected'),
         }
         fake(
           'fulfillment_orders',

+ 13 - 13
test/fulfillment_test.rb

@@ -76,14 +76,14 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
+            company: "TFTC - the fulfillment/tracking company",
           },
           line_items_by_fulfillment_order: [
             {
               fulfillment_order_id: 3,
-              fulfillment_order_line_items: [{ id: 2, quantity: 1 }]
+              fulfillment_order_line_items: [{ id: 2, quantity: 1 }],
             }
-          ]
+          ],
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -108,14 +108,14 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
+            company: "TFTC - the fulfillment/tracking company",
           },
           line_items_by_fulfillment_order: [
             {
               fulfillment_order_id: 3,
-              fulfillment_order_line_items: [{ id: 2, quantity: 1 }]
+              fulfillment_order_line_items: [{ id: 2, quantity: 1 }],
             }
-          ]
+          ],
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -141,14 +141,14 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
+            company: "TFTC - the fulfillment/tracking company",
           },
           line_items_by_fulfillment_order: [
             {
               fulfillment_order_id: 3,
-              fulfillment_order_line_items: [{ id: 2, quantity: 1 }]
+              fulfillment_order_line_items: [{ id: 2, quantity: 1 }],
             }
-          ]
+          ],
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -175,8 +175,8 @@ class FulFillmentTest < Test::Unit::TestCase
           tracking_info: {
             number: "XSDFHYR23475",
             url: "https://tracking.example.com/XSDFHYR23475",
-            company: "TFTC - the fulfillment/tracking company"
-          }
+            company: "TFTC - the fulfillment/tracking company",
+          },
         }
         request_body = { fulfillment: create_fulfillment_attributes }
         response_body = { fulfillment: create_fulfillment_attributes.merge(id: 346743624) }
@@ -213,8 +213,8 @@ class FulFillmentTest < Test::Unit::TestCase
         request_body = {
           fulfillment: {
             tracking_info: tracking_info,
-            notify_customer: true
-          }
+            notify_customer: true,
+          },
         }
         url_prefix = url_prefix_for_activated_session_for('2020-01')
         fake(

+ 2 - 2
test/fulfillment_v2_test.rb

@@ -21,8 +21,8 @@ class FulfillmentV2Test < Test::Unit::TestCase
     @request_body = {
       fulfillment: {
         tracking_info: @tracking_info,
-        notify_customer: true
-      }
+        notify_customer: true,
+      },
     }
     @url_prefix = url_prefix_for_activated_session_for('2020-01')
     fake(

+ 1 - 1
test/marketing_event_test.rb

@@ -60,7 +60,7 @@ class MarketingEventTest < Test::Unit::TestCase
       favorites_count: nil,
       comments_count: nil,
       ad_spend: nil,
-      is_cumulative: true
+      is_cumulative: true,
     }
     marketing_event.add_engagements(engagement)
     assert("2017-04-20", engagement[:occurred_on])

+ 6 - 6
test/meta_test.rb

@@ -8,37 +8,37 @@ class ApiVersionTest < Test::Unit::TestCase
         "handle": "2019-01",
         "display_name": "2019-01",
         "supported": true,
-        "latest_supported": false
+        "latest_supported": false,
       },
       {
         "handle": "2019-04",
         "latest_supported": false,
         "display_name": "2019-04",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "2019-07",
         "latest_supported": false,
         "display_name": "2019-07",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "2019-10",
         "latest_supported": false,
         "display_name": "2019-10",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "2020-01",
         "latest_supported": true,
         "display_name": "2020-01 (Latest)",
-        "supported": true
+        "supported": true,
       },
       {
         "handle": "unstable",
         "latest_supported": false,
         "display_name": "unstable",
-        "supported": false
+        "supported": false,
       }
     ].to_json