Here's a patch that cleans up the whitespace and newlines in the modules to follow Drupal best practices. I just opened each file in my editor and re-saved with auto formatting.

This will allow others to create patches for the module easier since there won't be a bunch of whitespace changes in their patches.

Comments

joelpittet’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Quick fix

Status: Reviewed & tested by the community » Needs work

The last submitted patch, commerce_coupon-whitespace_cleanup.patch, failed testing.

joelpittet’s picture

Issue tags: -Quick fix +Needs reroll

Looks like most of this was cleaned up somewhere else

chishah92’s picture

Assigned: Unassigned » chishah92
chishah92’s picture

Assigned: chishah92 » Unassigned
rasikap’s picture

Assigned: Unassigned » rasikap
rasikap’s picture

Assigned: rasikap » Unassigned
StatusFileSize
new12.43 KB

Please find the patch.

rasikap’s picture

Status: Needs work » Needs review
joelpittet’s picture

Status: Needs review » Needs work

These indenting look incorrect, why were they changed?

   $results = $query
-    ->entityCondition('entity_type', 'commerce_coupon')
-    ->propertyCondition('type', 'discount_coupon')
-    ->propertyCondition('code', $string, 'CONTAINS')
-    ->propertyOrderBy('code')
-    ->range(0, 3)
-    ->execute();
+      ->entityCondition('entity_type', 'commerce_coupon')
+      ->propertyCondition('type', 'discount_coupon')
+      ->propertyCondition('code', $string, 'CONTAINS')
+      ->propertyOrderBy('code')
+      ->range(0, 3)
+      ->execute();
chishah92’s picture

Status: Needs work » Needs review
StatusFileSize
new11.67 KB

Reverted with the correct indentation

~Chirag

joelpittet’s picture

Status: Needs review » Needs work

Sorry there were a lot more where that one came from, can you check all the spots where there are 4 spaces changed and make sure they are 2? Thanks for updating the patch @chishah92

  1. +++ b/commerce_coupon.module
    @@ -533,7 +533,7 @@ function commerce_coupon_commerce_discount_rule_build($rule, $discount) {
    -      )
    +          )
    

    This change is 4 spaces instead of 2.

  2. +++ b/commerce_coupon.module
    @@ -616,12 +616,12 @@ function commerce_coupon_evaluate_inline_conditions(EntityDrupalWrapper $coupon_
    -    ->entityCondition('entity_type', 'commerce_coupon')
    -    ->propertyCondition('type', 'discount_coupon')
    -    ->propertyCondition('code', $code)
    -    ->propertyCondition('status', TRUE)
    -    ->fieldCondition('commerce_discount_reference', 'target_id', $discount_id)
    -    ->execute();
    +      ->entityCondition('entity_type', 'commerce_coupon')
    +      ->propertyCondition('type', 'discount_coupon')
    +      ->propertyCondition('code', $code)
    +      ->propertyCondition('status', TRUE)
    +      ->fieldCondition('commerce_discount_reference', 'target_id', $discount_id)
    +      ->execute();
    

    This change doesn't need to happen.

  3. +++ b/commerce_coupon.module
    @@ -636,9 +636,9 @@ function commerce_coupon_get_discount_properties($discount, $options, $name) {
    -          ->entityCondition('entity_type', 'commerce_coupon')
    -          ->fieldCondition('commerce_discount_reference', 'target_id', $discount->discount_id)
    -          ->execute();
    +            ->entityCondition('entity_type', 'commerce_coupon')
    +            ->fieldCondition('commerce_discount_reference', 'target_id', $discount->discount_id)
    +            ->execute();
    

    This should be fine at 2 spaces, too.

  4. +++ b/commerce_coupon.module
    @@ -660,13 +660,13 @@ function commerce_coupon_get_discount_properties($discount, $options, $name) {
    -           ->fields('c', array('coupon_id'));
    +            ->fields('c', array('coupon_id'));
    

    same here, 2 spaces not 4, but the 3 is incorrect.

  5. +++ b/commerce_coupon.module
    @@ -660,13 +660,13 @@ function commerce_coupon_get_discount_properties($discount, $options, $name) {
    -           ->condition('c.status', 1)
    -           ->condition('d.commerce_discount_reference_target_id', $discount->discount_id)
    -           ->condition('d.deleted', 0)
    -           ->condition('d.entity_type', 'commerce_coupon');
    +            ->condition('c.status', 1)
    +            ->condition('d.commerce_discount_reference_target_id', $discount->discount_id)
    +            ->condition('d.deleted', 0)
    +            ->condition('d.entity_type', 'commerce_coupon');
    

    This should be 2 spaces not 4

  6. +++ b/commerce_coupon.module
    @@ -1260,10 +1259,10 @@ function commerce_coupon_load_coupon_code_discounts($code) {
    -    ->entityCondition('entity_type', 'commerce_discount')
    -    ->fieldCondition('commerce_coupon_reference', 'target_id', $coupon->coupon_id)
    -    ->propertyCondition('enabled', 1)
    -    ->execute();
    +      ->entityCondition('entity_type', 'commerce_discount')
    +      ->fieldCondition('commerce_coupon_reference', 'target_id', $coupon->coupon_id)
    +      ->propertyCondition('enabled', 1)
    +      ->execute();
    

    This was correct before at 2 spaces.

  7. +++ b/commerce_coupon.module
    @@ -1458,7 +1457,7 @@ function commerce_coupon_form_commerce_discount_form_alter(&$form, &$form_state)
    -  $coupons =& $form_state['coupons'];
    +  $coupons = & $form_state['coupons'];
    

    Can you point to the rule for this change? I think it was correct before.

  8. +++ b/commerce_coupon.module
    @@ -1515,11 +1514,7 @@ function commerce_coupon_form_commerce_discount_form_alter(&$form, &$form_state)
    -      $form['coupons']['coupon_form'],
    -      $form_state,
    -      $coupon,
    -      $ajax,
    -      array(array('coupons'))
    +        $form['coupons']['coupon_form'], $form_state, $coupon, $ajax, array(array('coupons'))
    
    @@ -1580,11 +1575,7 @@ function commerce_coupon_form_commerce_discount_form_alter(&$form, &$form_state)
    -          $form['coupons']['manage_coupons'][$delta]['coupon_form'],
    -          $form_state,
    -          $coupon,
    -          $ajax,
    -          array(array('coupons', 'manage_coupons', $delta))
    +            $form['coupons']['manage_coupons'][$delta]['coupon_form'], $form_state, $coupon, $ajax, array(array('coupons', 'manage_coupons', $delta))
             );
    

    These may be correct but need to be 2 spaces instead of 4... there is a pattern forming here...

  9. +++ b/commerce_coupon.module
    @@ -2206,6 +2196,7 @@ function commerce_coupon_commerce_coupon_legacy_mapping($coupon) {
     function commerce_coupon_type_disable() {
    ...
     }
    

    Extra space got added by accident.

  10. +++ b/commerce_coupon.rules_defaults.inc
    @@ -15,10 +16,10 @@ function commerce_coupon_default_rules_configuration() {
    -    ->event('commerce_coupon_applied_to_cart')
    -    ->action('drupal_message', array(
    -      'message' => t('Coupon code applied.'),
    -    ));
    +      ->event('commerce_coupon_applied_to_cart')
    +      ->action('drupal_message', array(
    +        'message' => t('Coupon code applied.'),
    

    2 spaces

chishah92’s picture

Assigned: Unassigned » chishah92

Will add all the corrections in the next patch.

~Chirag

chishah92’s picture

Status: Needs work » Needs review
StatusFileSize
new16.84 KB

Please Review , and need guidance on point 8 (unclear)

Status: Needs review » Needs work

The last submitted patch, 13: 2301037-13.patch, failed testing.

joelpittet’s picture

I don't think 8) is needed, there is no reference in the coding standards to that case.
https://www.drupal.org/docs/develop/standards/coding-standards#indenting

Looks like something went awry with #13

chishah92’s picture

Status: Needs work » Needs review
StatusFileSize
new9.94 KB

Adding a new patch

joelpittet’s picture

Status: Needs review » Needs work
Issue tags: -Needs reroll

There are still 4 space tabs left in this patch, setting this to needs work to remove those.

chishah92’s picture

Can you show me with screenshot where these corrections has to be made . Is it the query part ?

Please Advice
~Chirag

joelpittet’s picture

Here's a list if that helps but even better is to run PHPCodeSniffer with phpcbf which can auto-do a lot of this for you.
https://www.drupal.org/node/1419988

  1. +++ b/commerce_coupon.module
    @@ -533,7 +533,7 @@ function commerce_coupon_commerce_discount_rule_build($rule, $discount) {
    -      )
    +        )
           );
    

    These should be comined on the same line as )); and in the same indent as $rule->condition

  2. +++ b/commerce_coupon.module
    @@ -1260,10 +1259,10 @@ function commerce_coupon_load_coupon_code_discounts($code) {
    -    ->entityCondition('entity_type', 'commerce_discount')
    -    ->fieldCondition('commerce_coupon_reference', 'target_id', $coupon->coupon_id)
    -    ->propertyCondition('enabled', 1)
    -    ->execute();
    +      ->entityCondition('entity_type', 'commerce_discount')
    +      ->fieldCondition('commerce_coupon_reference', 'target_id', $coupon->coupon_id)
    +      ->propertyCondition('enabled', 1)
    +      ->execute();
    

    This should be left alone

  3. +++ b/commerce_coupon.module
    @@ -1515,11 +1514,7 @@ function commerce_coupon_form_commerce_discount_form_alter(&$form, &$form_state)
         commerce_coupon_attach_ajax_coupon_entity_form(
    -      $form['coupons']['coupon_form'],
    -      $form_state,
    -      $coupon,
    -      $ajax,
    -      array(array('coupons'))
    +        $form['coupons']['coupon_form'], $form_state, $coupon, $ajax, array(array('coupons'))
         );
    

    This should likely just go on one line or leave it alone

  4. +++ b/commerce_coupon.module
    @@ -1580,11 +1575,7 @@ function commerce_coupon_form_commerce_discount_form_alter(&$form, &$form_state)
             commerce_coupon_attach_ajax_coupon_entity_form(
    -          $form['coupons']['manage_coupons'][$delta]['coupon_form'],
    -          $form_state,
    -          $coupon,
    -          $ajax,
    -          array(array('coupons', 'manage_coupons', $delta))
    +            $form['coupons']['manage_coupons'][$delta]['coupon_form'], $form_state, $coupon, $ajax, array(array('coupons', 'manage_coupons', $delta))
             );
    

    Same

  5. +++ b/commerce_coupon.module
    @@ -1764,11 +1755,11 @@ function commerce_coupon_form_attach_coupons_validate(&$form, &$form_state) {
    -      $coupon_fields_form =& $form['coupons']['manage_coupons'][$coupon->delta]['coupon_form']['commerce_coupon_fields'];
    +      $coupon_fields_form = & $form['coupons']['manage_coupons'][$coupon->delta]['coupon_form']['commerce_coupon_fields'];
    ...
    -      $coupon_fields_form =& $form['coupons']['coupon_form']['commerce_coupon_fields'];
    +      $coupon_fields_form = & $form['coupons']['coupon_form']['commerce_coupon_fields'];
    

    don't think the space is needed between the = and &

  6. +++ b/commerce_coupon.module
    @@ -2023,8 +2014,8 @@ function theme_commerce_coupon_manage_discount_coupons($variables) {
           $row = array(array(
    -        'data' => drupal_render($form),
    -        'colspan' => 3,
    +          'data' => drupal_render($form),
    +          'colspan' => 3,
             ),
    

    This was correct before.

  7. +++ b/commerce_coupon.module
    @@ -2206,6 +2195,7 @@ function commerce_coupon_commerce_coupon_legacy_mapping($coupon) {
     function commerce_coupon_type_disable() {
    +  ¶
     }
    

    Extra whitespace added

chishah92’s picture

Thanks joelpittet , will submit the patch on the same

~Chirag

chishah92’s picture

Status: Needs work » Needs review
StatusFileSize
new9.5 KB

Made all the changes in this new patch.

Thanks!
~Chirag

joelpittet’s picture

Status: Needs review » Needs work

That's looking better, did you try the PHPCFB?

Here's another review

  1. +++ b/commerce_coupon.module
    @@ -1458,7 +1456,7 @@ function commerce_coupon_form_commerce_discount_form_alter(&$form, &$form_state)
    -  $coupons =& $form_state['coupons'];
    

    This should be left as is, because that is how we do this.

  2. +++ b/commerce_coupon.rules_defaults.inc
    @@ -15,10 +16,10 @@ function commerce_coupon_default_rules_configuration() {
    -    ->event('commerce_coupon_applied_to_cart')
    -    ->action('drupal_message', array(
    -      'message' => t('Coupon code applied.'),
    -    ));
    +      ->event('commerce_coupon_applied_to_cart')
    +      ->action('drupal_message', array(
    +        'message' => t('Coupon code applied.'),
    +  ));
    

    This should be left how it was as well, escaped the ending )); indent is correct.

  3. +++ b/commerce_coupon.rules_defaults.inc
    @@ -47,20 +48,20 @@ function commerce_coupon_default_rules_configuration() {
    -      // Coupon must be active.
    -      ->condition('data_is', array(
    -        'data:select' => 'commerce-coupon:status',
    -        'op' => '==',
    -        'value' => '1',
    -      ))
    -      // Inline conditions must pass.
    -      ->condition('commerce_coupon_evaluate_coupon_inline_conditions_rule', array(
    -        'commerce_coupon:select' => 'commerce_coupon',
    -      ))
    -      // Permissions for "redeeem" must pass.
    -      ->condition('commerce_coupon_current_user_may_redeem', array(
    -        'commerce_coupon:select' => 'commerce_coupon',
    -      ));
    +        // Coupon must be active.
    +        ->condition('data_is', array(
    +          'data:select' => 'commerce-coupon:status',
    +          'op' => '==',
    +          'value' => '1',
    +        ))
    +        // Inline conditions must pass.
    +        ->condition('commerce_coupon_evaluate_coupon_inline_conditions_rule', array(
    +          'commerce_coupon:select' => 'commerce_coupon',
    +        ))
    +        // Permissions for "redeeem" must pass.
    +        ->condition('commerce_coupon_current_user_may_redeem', array(
    +          'commerce_coupon:select' => 'commerce_coupon',
    +    ));
    

    Same here the ending )); indent is correct the but the -> should be left at 2 spaces

chishah92’s picture

Status: Needs work » Needs review
StatusFileSize
new8.39 KB

Added the new changes

~Chirag

joelpittet’s picture

+++ b/commerce_coupon.rules_defaults.inc
@@ -47,19 +48,19 @@ function commerce_coupon_default_rules_configuration() {
-      // Coupon must be active.
+        // Coupon must be active.
       ->condition('data_is', array(
-        'data:select' => 'commerce-coupon:status',
-        'op' => '==',
-        'value' => '1',
-      ))
-      // Inline conditions must pass.
+          'data:select' => 'commerce-coupon:status',
+          'op' => '==',
+          'value' => '1',
+        ))
+        // Inline conditions must pass.
       ->condition('commerce_coupon_evaluate_coupon_inline_conditions_rule', array(
-        'commerce_coupon:select' => 'commerce_coupon',
-      ))
-      // Permissions for "redeeem" must pass.
+          'commerce_coupon:select' => 'commerce_coupon',
+        ))
+        // Permissions for "redeeem" must pass.
       ->condition('commerce_coupon_current_user_may_redeem', array(
-        'commerce_coupon:select' => 'commerce_coupon',
+          'commerce_coupon:select' => 'commerce_coupon',

these changes dont need to happen

chishah92’s picture

I did this according this suggestion "Same here the ending )); indent is correct the but the -> should be left at 2 spaces"

Please Advice

~Chirag

chishah92’s picture

StatusFileSize
new8.13 KB

Done with the changes . Please review

~Chirag

joelpittet’s picture

Sorry if I'm not being clear, everything looks fine except this:

+++ b/commerce_coupon.rules_defaults.inc
@@ -47,17 +48,17 @@ function commerce_coupon_default_rules_configuration() {
-      // Coupon must be active.
+        // Coupon must be active.
...
-      ))
-      // Inline conditions must pass.
+        ))
+        // Inline conditions must pass.
...
-      ))
-      // Permissions for "redeeem" must pass.
+        ))
+        // Permissions for "redeeem" must pass.

These can be left alone, remove these changes.

yogeshmpawar’s picture

StatusFileSize
new7.31 KB

I have rerolled the patch as per changes mentioned in #27

joelpittet’s picture

Assigned: chishah92 » Unassigned
Status: Needs review » Reviewed & tested by the community

@Yogesh Pawar thanks that's looks right. Thanks to both of you for your patience

yogeshmpawar’s picture

Any update on this issue ?

yogeshmpawar’s picture

@maintainers - please look into this issue.