ampache/ampache

View on GitHub
src/Module/Util/Horde_Browser.php

Summary

Maintainability
F
5 days
Test Coverage

match accesses the super-global variable $_SERVER.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Minor
Found in src/Module/Util/Horde_Browser.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

match accesses the super-global variable $_SERVER.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Minor
Found in src/Module/Util/Horde_Browser.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

match accesses the super-global variable $_SERVER.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Minor
Found in src/Module/Util/Horde_Browser.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

match accesses the super-global variable $_SERVER.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Minor
Found in src/Module/Util/Horde_Browser.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

match accesses the super-global variable $_SERVER.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Minor
Found in src/Module/Util/Horde_Browser.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

match accesses the super-global variable $_SERVER.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Minor
Found in src/Module/Util/Horde_Browser.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Function match has a Cognitive Complexity of 151 (exceeds 5 allowed). Consider refactoring.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Minor
Found in src/Module/Util/Horde_Browser.php - About 3 days 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 match has 401 lines of code (exceeds 200 allowed). Consider refactoring.
Open

    public function match($userAgent = null, $accept = null): void
    {
        // Set our agent string.
        if ($userAgent == null) {
            if (isset($_SERVER['HTTP_USER_AGENT'])) {
Severity: Major
Found in src/Module/Util/Horde_Browser.php - About 1 day to fix

    The class Horde_Browser has an overall complexity of 137 which is very high. The configured complexity threshold is 50.
    Open

    class Horde_Browser
    {
        /**
         * Major version number.
         *
    Severity: Minor
    Found in src/Module/Util/Horde_Browser.php by phpmd

    Function getDownloadHeaders has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getDownloadHeaders(
            $filename = 'unknown',
            $cType = null,
            $inline = false,
            $cLength = null
    Severity: Minor
    Found in src/Module/Util/Horde_Browser.php - About 2 hrs 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

    File Horde_Browser.php has 524 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * vim:set softtabstop=4 shiftwidth=4 expandtab:
     *
    Severity: Major
    Found in src/Module/Util/Horde_Browser.php - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if (strpos($lowerAgent, 'iemobile') !== false || strpos($lowerAgent, 'mobileexplorer') !== false || strpos($lowerAgent, 'openwave') !== false) {
                  $this->setFeature('frames', false);
                  $this->setFeature('javascript', false);
                  $this->setQuirk('avoid_popup_windows');
                  $this->_mobile = true;
      Severity: Critical
      Found in src/Module/Util/Horde_Browser.php - About 2 hrs to fix

        Consider simplifying this complex logical expression.
        Open

                    if (
                        strpos($agent, 'Mobile') !== false ||
                        strpos($agent, 'Android') !== false ||
                        strpos($agent, 'SAMSUNG-GT') !== false ||
                        ((strpos($agent, 'Nokia') !== false || strpos($agent, 'Symbian') !== false) && strpos($agent, 'WebKit') !== false) ||
        Severity: Critical
        Found in src/Module/Util/Horde_Browser.php - About 2 hrs to fix

          The method match() has 449 lines of code. Current threshold is set to 100. Avoid really long methods.
          Open

              public function match($userAgent = null, $accept = null): void
              {
                  // Set our agent string.
                  if ($userAgent == null) {
                      if (isset($_SERVER['HTTP_USER_AGENT'])) {
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phpmd

          The method getDownloadHeaders() has an NPath complexity of 324. The configured NPath complexity threshold is 200.
          Open

              public function getDownloadHeaders(
                  $filename = 'unknown',
                  $cType = null,
                  $inline = false,
                  $cLength = null
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phpmd

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

          Source https://phpmd.org/rules/codesize.html#npathcomplexity

          The method match() has an NPath complexity of 31572. The configured NPath complexity threshold is 200.
          Open

              public function match($userAgent = null, $accept = null): void
              {
                  // Set our agent string.
                  if ($userAgent == null) {
                      if (isset($_SERVER['HTTP_USER_AGENT'])) {
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phpmd

          NPathComplexity

          Since: 0.1

          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

          Example

          class Foo {
              function bar() {
                  // lots of complicated code
              }
          }

          Source https://phpmd.org/rules/codesize.html#npathcomplexity

          The method getDownloadHeaders() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
          Open

              public function getDownloadHeaders(
                  $filename = 'unknown',
                  $cType = null,
                  $inline = false,
                  $cLength = null
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phpmd

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

          Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

          The method match() has a Cyclomatic Complexity of 112. The configured cyclomatic complexity threshold is 10.
          Open

              public function match($userAgent = null, $accept = null): void
              {
                  // Set our agent string.
                  if ($userAgent == null) {
                      if (isset($_SERVER['HTTP_USER_AGENT'])) {
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phpmd

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

          Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

          Refactor this function to reduce its Cognitive Complexity from 20 to the 15 allowed.
          Open

              public function getDownloadHeaders(
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.php by sonar-php

          Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

          See

          Refactor this function to reduce its Cognitive Complexity from 169 to the 15 allowed.
          Open

              public function match($userAgent = null, $accept = null): void
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.php by sonar-php

          Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

          See

          This function "match" has 448 lines, which is greater than the 150 lines authorized. Split it into smaller functions.
          Open

              public function match($userAgent = null, $accept = null): void
          Severity: Major
          Found in src/Module/Util/Horde_Browser.php by sonar-php

          A function that grows too large tends to aggregate too many responsibilities.

          Such functions inevitably become harder to understand and therefore harder to maintain.

          Above a specific threshold, it is strongly advised to refactor into smaller functions which focus on well-defined tasks.

          Those smaller functions will not only be easier to understand, but also probably easier to test.

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

                  } else {
                      $this->_accept = strtolower($accept);
                  }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 match uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          // Konqueror.
                          $this->setFeature('javascript', 1.1);
                          $this->setFeature('iskonqueror');
                          switch ($this->_majorVersion) {
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 setPlatform uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $this->_platform = 'unix';
                  }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 match uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                          } else {
                              if ($this->_majorVersion >= 312) {
                                  $this->_minorVersion = 3;
                              } elseif ($this->_majorVersion >= 124) {
                                  $this->_minorVersion = 2;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 match uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                              } else {
                                  $this->_minorVersion = 0;
                              }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 getDownloadHeaders uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $headers['Content-Type'] = 'application/octet-stream';
                      }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 getDownloadHeaders uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      if ($this->isBrowser('msie')) {
                          $headers['Content-Type'] = 'application/x-msdownload';
                      } elseif ($cType !== null) {
                          $headers['Content-Type'] = trim($cType);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 getDownloadHeaders uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $headers['Content-Type'] = 'application/octet-stream';
                      }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 match uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      $this->_agent = $userAgent;
                  }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 getDownloadHeaders uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $headers['Content-Disposition'] = 'attachment; filename="' . $filename . '"';
                      }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 setFeature uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                  } else {
                      unset($this->_features[$feature]);
                  }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 assigning values to variables in if clauses and the like (line '757', column '18').
          Open

              public function getDownloadHeaders(
                  $filename = 'unknown',
                  $cType = null,
                  $inline = false,
                  $cLength = null
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phpmd

          IfStatementAssignment

          Since: 2.7.0

          Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($foo = 'bar') { // possible typo
                      // ...
                  }
                  if ($baz = 0) { // always false
                      // ...
                  }
              }
          }

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

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

                  } else {
                      unset($this->_quirks[$quirk]);
                  }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 match uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $this->_majorVersion = $version[1];
                          $this->_minorVersion = 0;
                      }
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 match uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                              } else {
                                  // MSIE 5 for Windows.
                                  $this->setFeature('javascript', 1.4);
                                  $this->setFeature('dom');
                                  if ($this->_minorVersion >= 5) {
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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 "optgroup" 5 times.
          Open

                          $this->setFeature('optgroup');
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "frames" 7 times.
          Open

                  'frames' => true,
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "accesskey" 9 times.
          Open

                          $this->setFeature('accesskey');
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "xhtml" 3 times.
          Open

                      $this->setFeature('xhtml');
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "xmlhttpreq" 11 times.
          Open

                              $this->setFeature('xmlhttpreq');
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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.

          Move this "case default" clause to the end of this "switch" statement.
          Open

                          default:
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.php by sonar-php

          The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

          Noncompliant Code Example

          switch ($param) {  //missing default clause
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
          }
          
          switch ($param) {
            default: // default clause should be the last one
              error();
              break;
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
          }
          

          Compliant Solution

          switch ($param) {
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
            default:
              error();
              break;
          }
          

          See

          • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
          • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
          • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
          • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
          • MISRA C:2012, 16.1 - All switch statements shall be well-formed
          • MISRA C:2012, 16.4 - Every switch statement shall have a default label
          • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
          • MITRE, CWE-478 - Missing Default Case in Switch Statement
          • CERT, MSC01-C. - Strive for logical completeness
          • CERT, MSC01-CPP. - Strive for logical completeness

          Add a "case default" clause to this "switch" statement.
          Open

                          switch ($this->_majorVersion) {
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.php by sonar-php

          The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

          Noncompliant Code Example

          switch ($param) {  //missing default clause
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
          }
          
          switch ($param) {
            default: // default clause should be the last one
              error();
              break;
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
          }
          

          Compliant Solution

          switch ($param) {
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
            default:
              error();
              break;
          }
          

          See

          • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
          • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
          • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
          • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
          • MISRA C:2012, 16.1 - All switch statements shall be well-formed
          • MISRA C:2012, 16.4 - Every switch statement shall have a default label
          • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
          • MITRE, CWE-478 - Missing Default Case in Switch Statement
          • CERT, MSC01-C. - Strive for logical completeness
          • CERT, MSC01-CPP. - Strive for logical completeness

          Move this "case default" clause to the end of this "switch" statement.
          Open

                          default:
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.php by sonar-php

          The requirement for a final case default clause is defensive programming. The clause should either take appropriate action, or contain a suitable comment as to why no action is taken. Even when the switch covers all current values of an enum, a default case should still be used because there is no guarantee that the enum won't be extended.

          Noncompliant Code Example

          switch ($param) {  //missing default clause
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
          }
          
          switch ($param) {
            default: // default clause should be the last one
              error();
              break;
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
          }
          

          Compliant Solution

          switch ($param) {
            case 0:
              do_something();
              break;
            case 1:
              do_something_else();
              break;
            default:
              error();
              break;
          }
          

          See

          • MISRA C:2004, 15.0 - The MISRA C switch syntax shall be used.
          • MISRA C:2004, 15.3 - The final clause of a switch statement shall be the default clause
          • MISRA C++:2008, 6-4-3 - A switch statement shall be a well-formed switch statement.
          • MISRA C++:2008, 6-4-6 - The final clause of a switch statement shall be the default-clause
          • MISRA C:2012, 16.1 - All switch statements shall be well-formed
          • MISRA C:2012, 16.4 - Every switch statement shall have a default label
          • MISRA C:2012, 16.5 - A default label shall appear as either the first or the last switch label of a switch statement
          • MITRE, CWE-478 - Missing Default Case in Switch Statement
          • CERT, MSC01-C. - Strive for logical completeness
          • CERT, MSC01-CPP. - Strive for logical completeness

          Define a constant instead of duplicating this literal "iframes" 9 times.
          Open

                          $this->setFeature('iframes');
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "images" 5 times.
          Open

                  'images' => true,
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "javascript" 30 times.
          Open

                  'javascript' => true,
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "dataurl" 4 times.
          Open

                              $this->setFeature('dataurl', 4100);
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "Content-Disposition" 3 times.
          Open

                      $headers['Content-Disposition'] = 'inline; filename="' . $filename . '"';
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "avoid_popup_windows" 8 times.
          Open

                      $this->setQuirk('avoid_popup_windows');
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "homepage" 3 times.
          Open

                              $this->setFeature('homepage');
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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 "Content-Type" 6 times.
          Open

                          $headers['Content-Type'] = trim($cType);
          Severity: Critical
          Found in src/Module/Util/Horde_Browser.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.

          TODO found
          Open

           * @TODO http://ajaxian.com/archives/parse-user-agent
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by fixme

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1.4);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                      $this->setFeature('javascript', 1.1);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning int to property but \Ampache\Module\Util\Horde_Browser->_minorVersion is string
          Open

                              $this->_minorVersion                             = (int)($this->_minorVersion);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                                  $this->setFeature('javascript', 1.2);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                          $this->setFeature('javascript', 1.4);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning 0 to property but \Ampache\Module\Util\Horde_Browser->_minorVersion is string
          Open

                                  $this->_minorVersion = 0;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning 2 to property but \Ampache\Module\Util\Horde_Browser->_majorVersion is string
          Open

                              $this->_majorVersion = 2;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning 2 to property but \Ampache\Module\Util\Horde_Browser->_minorVersion is string
          Open

                                  $this->_minorVersion = 2;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1.5);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is 1 but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                          $this->setFeature('javascript', 1.5);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is 0 but \Ampache\Module\Util\Horde_Browser::setQuirk() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:673
          Open

                          $this->setQuirk('empty_file_input_value', 0);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                          $this->setFeature('javascript', 1.4);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning 3 to property but \Ampache\Module\Util\Horde_Browser->_minorVersion is string
          Open

                                  $this->_minorVersion = 3;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning 1 to property but \Ampache\Module\Util\Horde_Browser->_majorVersion is string
          Open

                              $this->_majorVersion = 1;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1.4);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                                  $this->setFeature('javascript', 1.4);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning 0 to property but \Ampache\Module\Util\Horde_Browser->_minorVersion is string
          Open

                              $this->_minorVersion = 0;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1.3);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is 4100 but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('dataurl', 4100);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1.4);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1.2);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                          $this->setFeature('javascript', 1.1);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Assigning 0 to property but \Ampache\Module\Util\Horde_Browser->_minorVersion is string
          Open

                          $this->_minorVersion = 0;
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Argument 2 (value) is float but \Ampache\Module\Util\Horde_Browser::setFeature() takes bool|true defined at /code/src/Module/Util/Horde_Browser.php:720
          Open

                              $this->setFeature('javascript', 1.1);
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php by phan

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  } elseif (strpos($agent, 'MOT-') !== false) {
                      $this->setBrowser('motorola');
                      $this->setFeature('html', false);
                      $this->setFeature('javascript', false);
                      $this->setFeature('hdml');
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php and 1 other location - About 30 mins to fix
          src/Module/Util/Horde_Browser.php on lines 566..573

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 90.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  } elseif (strpos($lowerAgent, 'wap') !== false) {
                      $this->setBrowser('wap');
                      $this->setFeature('html', false);
                      $this->setFeature('javascript', false);
                      $this->setFeature('hdml');
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.php and 1 other location - About 30 mins to fix
          src/Module/Util/Horde_Browser.php on lines 592..599

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 90.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          The class Horde_Browser is not named in CamelCase.
          Open

          class Horde_Browser
          {
              /**
               * Major version number.
               *
          Severity: Minor
          Found in src/Module/Util/Horde_Browser.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

          Property name "$_accept" should not be prefixed with an underscore to indicate visibility
          Open

              private $_accept = '';

          Property name "$_features" should not be prefixed with an underscore to indicate visibility
          Open

              private $_features = array(

          Property name "$_lowerAgent" should not be prefixed with an underscore to indicate visibility
          Open

              private $_lowerAgent = '';

          Property name "$_platform" should not be prefixed with an underscore to indicate visibility
          Open

              private $_platform = '';

          Property name "$_quirks" should not be prefixed with an underscore to indicate visibility
          Open

              private $_quirks = array();

          Property name "$_mobile" should not be prefixed with an underscore to indicate visibility
          Open

              private $_mobile = false;

          Property name "$_agent" should not be prefixed with an underscore to indicate visibility
          Open

              private $_agent = '';

          Property name "$_browser" should not be prefixed with an underscore to indicate visibility
          Open

              private $_browser = '';

          Property name "$_majorVersion" should not be prefixed with an underscore to indicate visibility
          Open

              private $_majorVersion = 0;

          Property name "$_minorVersion" should not be prefixed with an underscore to indicate visibility
          Open

              private $_minorVersion = 0;

          Property name "$_tablet" should not be prefixed with an underscore to indicate visibility
          Open

              private $_tablet = false;

          Expected 0 spaces after opening bracket; newline found
          Open

                      if (

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

          class Horde_Browser

          There are no issues that match your filters.

          Category
          Status