src/Shop/Views/Order.php

Summary

Maintainability
B
4 hrs
Test Coverage

Method find has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function find($request, $match)
    {
        $order = new Shop_Order();
        $pag = new Pluf_Paginator($order);
        $manager = $order->getManager();
Severity: Minor
Found in src/Shop/Views/Order.php - About 1 hr to fix

    Method pay has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function pay($request, $match)
        {
            /**
             *
             * @var Shop_Order $order
    Severity: Minor
    Found in src/Shop/Views/Order.php - About 1 hr to fix

      Function create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function create($request, $match)
          {
              $user = $request->user;
              $data = $request->REQUEST;
              if (isset($user)) {
      Severity: Minor
      Found in src/Shop/Views/Order.php - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function pay has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function pay($request, $match)
          {
              /**
               *
               * @var Shop_Order $order
      Severity: Minor
      Found in src/Shop/Views/Order.php - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      The class Shop_Views_Order has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
      Open

      class Shop_Views_Order
      {
      
          /**
           * یک تقاضای جدید در سیستم ایجاد می‌کند.
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      CouplingBetweenObjects

      Since: 1.1.0

      A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

      Example

      class Foo {
          /**
           * @var \foo\bar\X
           */
          private $x = null;
      
          /**
           * @var \foo\bar\Y
           */
          private $y = null;
      
          /**
           * @var \foo\bar\Z
           */
          private $z = null;
      
          public function setFoo(\Foo $foo) {}
          public function setBar(\Bar $bar) {}
          public function setBaz(\Baz $baz) {}
      
          /**
           * @return \SplObjectStorage
           * @throws \OutOfRangeException
           * @throws \InvalidArgumentException
           * @throws \ErrorException
           */
          public function process(\Iterator $it) {}
      
          // ...
      }

      Source https://phpmd.org/rules/design.html#couplingbetweenobjects

      Missing class import via use statement (line '163', column '22').
      Open

              $order = new Shop_Order($order->id);
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '237', column '23').
      Open

                  throw new Pluf_Exception_BadRequest('Invalid payment. ' . //
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '287', column '34').
      Open

              $pag->forced_where = new Pluf_SQL('id=%s', array(
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '59', column '22').
      Open

              $order = new Shop_Order();
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '199', column '23').
      Open

                  throw new \Pluf\Exception("You are not allowed to access to this order.");
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '366', column '20').
      Open

              return new \Pluf\Exception('An error is occurred while processing order');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '243', column '23').
      Open

                  throw new Pluf_Exception_BadRequest('Invalid amount: ' . $price);
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '286', column '20').
      Open

              $pag = new Pluf_Paginator(new Bank_Receipt());
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '119', column '24').
      Open

                  return new Pluf_Exception_Unauthorized('You are not allowed to do this action.');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '225', column '28').
      Open

                      return new Pluf_Exception_Unauthorized('You are not allowed to do this action.');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '229', column '23').
      Open

                  throw new Pluf_Exception_PermissionDenied('Could not pay again for an already payed order');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '193', column '64').
      Open

              $sql = $manager->createOrderFilter($request)->SAnd(new Pluf_SQL('id=%s', array(
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '286', column '39').
      Open

              $pag = new Pluf_Paginator(new Bank_Receipt());
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '60', column '20').
      Open

              $pag = new Pluf_Paginator($order);
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid using static access to class 'Pluf' in method 'create'.
      Open

              $form = Pluf_Shortcuts_GetFormForModel(Pluf::factory('Shop_Order'), $request->REQUEST);
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class 'Pluf' in method 'update'.
      Open

                  Pluf::loadFunction('Shop_Shortcuts_GetObjectBySecureIdOr404');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class 'Pluf' in method 'pay'.
      Open

              Pluf::loadFunction('Bank_Shortcuts_IsCurrenciesCompatible');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class 'Pluf' in method 'find'.
      Open

              Pluf::loadFunction('Shop_Shortcuts_NormalizeItemPerPage');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      The method update uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $order = Pluf_Shortcuts_GetObjectOr404('Shop_Order', $match['orderId']);
              }
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      Avoid using static access to class 'Pluf' in method 'pay'.
      Open

              Pluf::loadFunction('Bank_Shortcuts_ConvertCurrency');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      The method actions uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $order = Pluf_Shortcuts_GetObjectOr404('Shop_Order', $match['orderId']);
                  self::checkAccess($request, $order);
              }
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      The method doAction uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $order = Pluf_Shortcuts_GetObjectOr404('Shop_Order', $match['orderId']);
                  self::checkAccess($request, $order);
              }
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      Avoid using static access to class 'Bank_Service' in method 'updateReceiptInfo'.
      Open

              Bank_Service::update($receipt);
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class 'Shop_Precondition' in method 'pay'.
      Open

                  if (! Shop_Precondition::canModifyOrder($request, $order)) {
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class 'Bank_Service' in method 'pay'.
      Open

              $payment = Bank_Service::create($receiptData, 'shop-order', $order->id);
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class 'Tenant_Service' in method 'pay'.
      Open

              $tenantCurrency = Tenant_Service::setting('local.currency');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      The method pay uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $order = Pluf_Shortcuts_GetObjectOr404('Shop_Order', $match['orderId']);
                  if (! Shop_Precondition::canModifyOrder($request, $order)) {
                      return new Pluf_Exception_Unauthorized('You are not allowed to do this action.');
                  }
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      Avoid using static access to class 'Pluf' in method 'create'.
      Open

              Pluf::loadFunction('Pluf_Shortcuts_GetFormForModel');
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      Avoid using static access to class 'Shop_Precondition' in method 'get'.
      Open

              if (! Shop_Precondition::canViewOrder($request, $order)) {
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

      Source https://phpmd.org/rules/cleancode.html#staticaccess

      The method payInfo uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $order = Pluf_Shortcuts_GetObjectOr404('Shop_Order', $match['orderId']);
                  self::checkAccess($request, $order);
              }
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      Define a constant instead of duplicating this literal "phone" 3 times.
      Open

                  'phone',
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Remove the unused function parameter "$request".
      Open

          public static function getBySecureId($request, $match)
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

      Noncompliant Code Example

      function doSomething($a, $b) { // "$a" is unused
        return compute($b);
      }
      

      Compliant Solution

      function doSomething($b) {
        return compute($b);
      }
      

      Exceptions

      Functions in classes that override a class or implement interfaces are ignored.

      class C extends B {
      
        function doSomething($a, $b) {     // no issue reported on $b
          compute($a);
        }
      
      }
      

      See

      • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
      • MISRA C:2012, 2.7 - There should be no unused parameters in functions
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC12-CPP. - Detect and remove code that has no effect

      Remove the unused function parameter "$match".
      Open

          public static function create($request, $match)
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

      Noncompliant Code Example

      function doSomething($a, $b) { // "$a" is unused
        return compute($b);
      }
      

      Compliant Solution

      function doSomething($b) {
        return compute($b);
      }
      

      Exceptions

      Functions in classes that override a class or implement interfaces are ignored.

      class C extends B {
      
        function doSomething($a, $b) {     // no issue reported on $b
          compute($a);
        }
      
      }
      

      See

      • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
      • MISRA C:2012, 2.7 - There should be no unused parameters in functions
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC12-CPP. - Detect and remove code that has no effect

      Remove this commented out code.
      Open

              // self::checkAccess($request, $order);
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Programmers should not comment out code as it bloats programs and reduces readability.

      Unused code should be deleted and can be retrieved from source control history if required.

      See

      • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
      • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
      • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
      • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

      Define a constant instead of duplicating this literal "state" 3 times.
      Open

                  'state',
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "full_name" 4 times.
      Open

                  if(!array_key_exists('full_name', $data)){                
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "email" 3 times.
      Open

                  'email',
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Define a constant instead of duplicating this literal "Shop_Order" 16 times.
      Open

              $form = Pluf_Shortcuts_GetFormForModel(Pluf::factory('Shop_Order'), $request->REQUEST);
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Remove this commented out code.
      Open

                  // $request->REQUEST['full_name'] = isset($data['full_name']) ? $data['full_name'] : $user->first_name . ' ' . $user->last_name;
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Programmers should not comment out code as it bloats programs and reduces readability.

      Unused code should be deleted and can be retrieved from source control history if required.

      See

      • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
      • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
      • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
      • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

      Merge this if statement with the enclosing one.
      Open

                  if(!array_key_exists('full_name', $data)){                
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Merging collapsible if statements increases the code's readability.

      Noncompliant Code Example

      if (condition1) {
        if (condition2) {
          ...
        }
      }
      

      Compliant Solution

      if (condition1 && condition2) {
        ...
      }
      

      Define a constant instead of duplicating this literal "province" 3 times.
      Open

                  'province',
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Remove the unused function parameter "$match".
      Open

          public static function find($request, $match)
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

      Noncompliant Code Example

      function doSomething($a, $b) { // "$a" is unused
        return compute($b);
      }
      

      Compliant Solution

      function doSomething($b) {
        return compute($b);
      }
      

      Exceptions

      Functions in classes that override a class or implement interfaces are ignored.

      class C extends B {
      
        function doSomething($a, $b) {     // no issue reported on $b
          compute($a);
        }
      
      }
      

      See

      • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
      • MISRA C:2012, 2.7 - There should be no unused parameters in functions
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC12-CPP. - Detect and remove code that has no effect

      Remove the unused function parameter "$request".
      Open

          public static function checkPay($request, $match)
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

      Noncompliant Code Example

      function doSomething($a, $b) { // "$a" is unused
        return compute($b);
      }
      

      Compliant Solution

      function doSomething($b) {
        return compute($b);
      }
      

      Exceptions

      Functions in classes that override a class or implement interfaces are ignored.

      class C extends B {
      
        function doSomething($a, $b) {     // no issue reported on $b
          compute($a);
        }
      
      }
      

      See

      • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
      • MISRA C:2012, 2.7 - There should be no unused parameters in functions
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC12-CPP. - Detect and remove code that has no effect

      Define a constant instead of duplicating this literal "orderId" 8 times.
      Open

              $order = Pluf_Shortcuts_GetObjectOr404('Shop_Order', $match['orderId']);
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Remove the unused function parameter "$request".
      Open

          public static function delete($request, $match)
      Severity: Major
      Found in src/Shop/Views/Order.php by sonar-php

      Unused parameters are misleading. Whatever the value passed to such parameters is, the behavior will be the same.

      Noncompliant Code Example

      function doSomething($a, $b) { // "$a" is unused
        return compute($b);
      }
      

      Compliant Solution

      function doSomething($b) {
        return compute($b);
      }
      

      Exceptions

      Functions in classes that override a class or implement interfaces are ignored.

      class C extends B {
      
        function doSomething($a, $b) {     // no issue reported on $b
          compute($a);
        }
      
      }
      

      See

      • MISRA C++:2008, 0-1-11 - There shall be no unused parameters (named or unnamed) in nonvirtual functions.
      • MISRA C:2012, 2.7 - There should be no unused parameters in functions
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC12-CPP. - Detect and remove code that has no effect

      Define a constant instead of duplicating this literal "secureId" 15 times.
      Open

              $order->_a['cols']['secureId']['readable'] = true;
      Severity: Critical
      Found in src/Shop/Views/Order.php by sonar-php

      Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

      On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

      Noncompliant Code Example

      With the default threshold of 3:

      function run() {
        prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
        execute('action1');
        release('action1');
      }
      

      Compliant Solution

      ACTION_1 = 'action1';
      
      function run() {
        prepare(ACTION_1);
        execute(ACTION_1);
        release(ACTION_1);
      }
      

      Exceptions

      To prevent generating some false-positives, literals having less than 5 characters are excluded.

      Avoid unused parameters such as '$match'.
      Open

          public static function find($request, $match)
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid unused parameters such as '$match'.
      Open

          public static function create($request, $match)
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid unused parameters such as '$request'.
      Open

          public static function delete($request, $match)
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid unused parameters such as '$request'.
      Open

          public static function getBySecureId($request, $match)
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid unused parameters such as '$request'.
      Open

          public static function checkPay($request, $match)
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Each class must be in a namespace of at least one level (a top-level vendor name)
      Open

      class Shop_Views_Order
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 4 and the first side effect is on line 2.
      Open

      <?php
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      The class Shop_Views_Order is not named in CamelCase.
      Open

      class Shop_Views_Order
      {
      
          /**
           * یک تقاضای جدید در سیستم ایجاد می‌کند.
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

      Line exceeds 120 characters; contains 140 characters
      Open

                  // $request->REQUEST['full_name'] = isset($data['full_name']) ? $data['full_name'] : $user->first_name . ' ' . $user->last_name;
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      Whitespace found at end of line
      Open

                  if(!array_key_exists('full_name', $data)){                
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      Class name "Shop_Views_Order" is not in camel caps format
      Open

      class Shop_Views_Order
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      Expected 1 space after closing parenthesis; found 0
      Open

                  if(!array_key_exists('full_name', $data)){                
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

                  if(!array_key_exists('full_name', $data)){                
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      Expected 1 space after IF keyword; 0 found
      Open

                      if($profiles->count() > 0){
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      Expected 1 space after closing parenthesis; found 0
      Open

                      if($profiles->count() > 0){
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpcodesniffer

      The variable $sort_fields is not named in camelCase.
      Open

          public static function find($request, $match)
          {
              $order = new Shop_Order();
              $pag = new Pluf_Paginator($order);
              $manager = $order->getManager();
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $search_fields is not named in camelCase.
      Open

          public static function find($request, $match)
          {
              $order = new Shop_Order();
              $pag = new Pluf_Paginator($order);
              $manager = $order->getManager();
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $sort_fields is not named in camelCase.
      Open

          public static function find($request, $match)
          {
              $order = new Shop_Order();
              $pag = new Pluf_Paginator($order);
              $manager = $order->getManager();
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $search_fields is not named in camelCase.
      Open

          public static function find($request, $match)
          {
              $order = new Shop_Order();
              $pag = new Pluf_Paginator($order);
              $manager = $order->getManager();
      Severity: Minor
      Found in src/Shop/Views/Order.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status