steadlane/silverstripe-vision6

View on GitHub

Showing 79 of 79 total issues

Vision6Api has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class Vision6Api extends Object
{
    /** @var bool */
    protected $apiKey = false;

Severity: Minor
Found in code/api/Vision6Service.php - About 2 hrs to fix

    Function invokeMethod has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function invokeMethod($apiKey, $methodName, $parameters)
        {
            $this->errorCode = false;
            $this->errorMessage = false;
    
    
    Severity: Minor
    Found in code/api/Vision6Service.php - About 1 hr 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

    Method postRequest has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function postRequest($methodName, $postData)
        {
            // Build request headers
            $headers = array(
                'Content-Type: application/json',
    Severity: Minor
    Found in code/api/Vision6Service.php - About 1 hr to fix

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

          public function subscribe($data, Form $form)
          {
              if (!$this->request->isPOST()) {
                  // Bad Request
                  return new SS_HTTPResponse(
      Severity: Minor
      Found in code/controllers/Vision6PageController.php - About 1 hr to fix

        Method syncFields has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function syncFields()
            {
                if (static::$is_flushing && !defined('VISION6_API_KEY')) {
                    return;
                }
        Severity: Minor
        Found in code/tasks/Vision6Sync.php - About 1 hr to fix

          Function build has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function build()
              {
                  if (!($this->list instanceof Vision6List)) {
                      user_error(
                          _t(
          Severity: Minor
          Found in code/Vision6FieldFactory.php - About 1 hr 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

          Method build has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function build()
              {
                  if (!($this->list instanceof Vision6List)) {
                      user_error(
                          _t(
          Severity: Minor
          Found in code/Vision6FieldFactory.php - About 1 hr to fix

            Method invokeMethod has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function invokeMethod($apiKey, $methodName, $parameters)
                {
                    $this->errorCode = false;
                    $this->errorMessage = false;
            
            
            Severity: Minor
            Found in code/api/Vision6Service.php - About 1 hr to fix

              Method validate has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function validate($validator)
                  {
                      $form = $this->getForm();
                      $data = $form->getData();
              
              
              Severity: Minor
              Found in code/forms/Vision6SubscribeField.php - About 1 hr to fix

                Method subscribeEmail has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function subscribeEmail($listId, $fieldOrEmail)
                    {
                        $email = null;
                
                        if ($fieldOrEmail instanceof TextField) {
                Severity: Minor
                Found in code/Vision6.php - About 1 hr to fix

                  Function postRequest has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function postRequest($methodName, $postData)
                      {
                          // Build request headers
                          $headers = array(
                              'Content-Type: application/json',
                  Severity: Minor
                  Found in code/api/Vision6Service.php - About 55 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 property $singular_name is not named in camelCase.
                  Open

                  class EditableVision6SubscribeField extends EditableFormField
                  {
                      /** @var array */
                      private static $db = array(
                          'ListID' => 'Int',

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  Avoid variables with short names like $db. Configured minimum length is 3.
                  Open

                      protected static $db = array(
                          "FieldID" => "Int", // The ID of the Field.
                          "Name" => "Varchar(100)", // The name of the Field in the List.
                          "Type" => "Varchar", // The type of the Field. See below for a list of supported Field types.
                          "IsMandatory" => "Int(0)", // A value indicating whether the Field is displayed as mandatory in Web Forms by default.
                  Severity: Minor
                  Found in code/models/Vision6Field.php by phpmd

                  ShortVariable

                  Since: 0.2

                  Detects when a field, local, or parameter has a very short name.

                  Example

                  class Something {
                      private $q = 15; // VIOLATION - Field
                      public static function main( array $as ) { // VIOLATION - Formal
                          $r = 20 + $this->q; // VIOLATION - Local
                          for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                              $r += $this->q;
                          }
                      }
                  }

                  Source https://phpmd.org/rules/naming.html#shortvariable

                  The property $allowed_actions is not named in camelCase.
                  Open

                  class Vision6PageController extends Page_Controller
                  {
                      /** @var array */
                      private static $allowed_actions = array(
                          'subscribe',

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The property $is_flushing is not named in camelCase.
                  Open

                  class Vision6Sync extends BuildTask implements Flushable
                  {
                      private static $is_flushing = false;
                  
                      /** @var string */
                  Severity: Minor
                  Found in code/tasks/Vision6Sync.php by phpmd

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The property $plural_name is not named in camelCase.
                  Open

                  class EditableVision6SubscribeField extends EditableFormField
                  {
                      /** @var array */
                      private static $db = array(
                          'ListID' => 'Int',

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  The property $many_many is not named in camelCase.
                  Open

                  class Vision6List extends DataObject
                  {
                      protected static $db = array(
                          "ListID" => "Int",
                          "Name" => "Varchar(200)",
                  Severity: Minor
                  Found in code/models/Vision6List.php by phpmd

                  CamelCasePropertyName

                  Since: 0.2

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

                  Example

                  class ClassName {
                      protected $property_name;
                  }

                  Source

                  Avoid variables with short names like $fp. Configured minimum length is 3.
                  Open

                          $fp = @fopen($this->getApiUrl(), 'rb', false, $context);
                  Severity: Minor
                  Found in code/api/Vision6Service.php by phpmd

                  ShortVariable

                  Since: 0.2

                  Detects when a field, local, or parameter has a very short name.

                  Example

                  class Something {
                      private $q = 15; // VIOLATION - Field
                      public static function main( array $as ) { // VIOLATION - Formal
                          $r = 20 + $this->q; // VIOLATION - Local
                          for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                              $r += $this->q;
                          }
                      }
                  }

                  Source https://phpmd.org/rules/naming.html#shortvariable

                  Avoid variables with short names like $db. Configured minimum length is 3.
                  Open

                      protected static $db = array(
                          "ListID" => "Int",
                          "Name" => "Varchar(200)",
                          "FileFolderID" => "Int"
                      );
                  Severity: Minor
                  Found in code/models/Vision6List.php by phpmd

                  ShortVariable

                  Since: 0.2

                  Detects when a field, local, or parameter has a very short name.

                  Example

                  class Something {
                      private $q = 15; // VIOLATION - Field
                      public static function main( array $as ) { // VIOLATION - Formal
                          $r = 20 + $this->q; // VIOLATION - Local
                          for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                              $r += $this->q;
                          }
                      }
                  }

                  Source https://phpmd.org/rules/naming.html#shortvariable

                  Avoid variables with short names like $db. Configured minimum length is 3.
                  Open

                      private static $db = array(
                          'ListID' => 'Int',
                          'EmailField' => 'Varchar(255)',
                          'GracefulReject' => 'Boolean'
                      );

                  ShortVariable

                  Since: 0.2

                  Detects when a field, local, or parameter has a very short name.

                  Example

                  class Something {
                      private $q = 15; // VIOLATION - Field
                      public static function main( array $as ) { // VIOLATION - Formal
                          $r = 20 + $this->q; // VIOLATION - Local
                          for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                              $r += $this->q;
                          }
                      }
                  }

                  Source https://phpmd.org/rules/naming.html#shortvariable

                  Severity
                  Category
                  Status
                  Source
                  Language