steeffffeen/FancyManiaLinks

View on GitHub
FML/Script/Script.php

Summary

Maintainability
B
5 hrs
Test Coverage
B
89%

The class Script has 12 public methods. Consider refactoring Script to keep number of public methods under 10.
Open

class Script
{

    /*
     * Constants
Severity: Minor
Found in FML/Script/Script.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

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

Script has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Script
{

    /*
     * Constants
Severity: Minor
Found in FML/Script/Script.php - About 2 hrs to fix

    Method getMainFunction has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getMainFunction()
        {
            $mainFunction = '
    Void FML_Dummy() {}
    main() {
    Severity: Minor
    Found in FML/Script/Script.php - About 1 hr to fix

      The method appendGenericScriptLabel has a boolean flag argument $isolated, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function appendGenericScriptLabel($name, $text = null, $isolated = false)
      Severity: Minor
      Found in FML/Script/Script.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

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

              } else {
                  $scriptFunction = new ScriptFunction($name, $text);
              }
      Severity: Minor
      Found in FML/Script/Script.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 addScriptConstant uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $scriptConstant = new ScriptConstant($name, $value);
              }
      Severity: Minor
      Found in FML/Script/Script.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 appendGenericScriptLabel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $scriptLabel = new ScriptLabel($name, $text, $isolated);
              }
      Severity: Minor
      Found in FML/Script/Script.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 addCustomScriptLabel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $scriptLabel = new ScriptLabel($name, $text);
              }
      Severity: Minor
      Found in FML/Script/Script.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 setScriptInclude uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $scriptInclude = new ScriptInclude($file, $namespace);
              }
      Severity: Minor
      Found in FML/Script/Script.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

      TODO found
      Open

           * @TODO: get rid of generic script labels approach
      Severity: Minor
      Found in FML/Script/Script.php by fixme

      TODO found
      Open

      // TODO: rename the protected getXYZ methods to getXZYText (point out that it's a compiled string and not an array)
      Severity: Minor
      Found in FML/Script/Script.php by fixme

      TODO found
      Open

           * @TODO: get rid of generic script labels approach
      Severity: Minor
      Found in FML/Script/Script.php by fixme

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

          public function addCustomScriptLabel($name, $text = null)
          {
              if ($name instanceof ScriptLabel) {
                  $scriptLabel = $name;
              } else {
      Severity: Minor
      Found in FML/Script/Script.php and 2 other locations - About 30 mins to fix
      FML/Script/Script.php on lines 104..115
      FML/Script/Script.php on lines 135..146

      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 91.

      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 3 locations. Consider refactoring.
      Open

          public function addScriptConstant($name, $value = null)
          {
              if ($name instanceof ScriptConstant) {
                  $scriptConstant = $name;
              } else {
      Severity: Minor
      Found in FML/Script/Script.php and 2 other locations - About 30 mins to fix
      FML/Script/Script.php on lines 135..146
      FML/Script/Script.php on lines 156..167

      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 91.

      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 3 locations. Consider refactoring.
      Open

          public function addScriptFunction($name, $text = null)
          {
              if ($name instanceof ScriptFunction) {
                  $scriptFunction = $name;
              } else {
      Severity: Minor
      Found in FML/Script/Script.php and 2 other locations - About 30 mins to fix
      FML/Script/Script.php on lines 104..115
      FML/Script/Script.php on lines 156..167

      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 91.

      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

      Class constants must be uppercase; expected VAR_SCRIPTSTART but found VAR_ScriptStart
      Open

          const VAR_ScriptStart = "FML_ScriptStart";
      Severity: Minor
      Found in FML/Script/Script.php by phpcodesniffer

      Class constants must be uppercase; expected VAR_LOOPCOUNTER but found VAR_LoopCounter
      Open

          const VAR_LoopCounter = "FML_LoopCounter";
      Severity: Minor
      Found in FML/Script/Script.php by phpcodesniffer

      Class constants must be uppercase; expected VAR_LASTTICK but found VAR_LastTick
      Open

          const VAR_LastTick    = "FML_LastTick";
      Severity: Minor
      Found in FML/Script/Script.php by phpcodesniffer

      The closing brace for the class must go on the next line after the body
      Open

      }
      Severity: Minor
      Found in FML/Script/Script.php by phpcodesniffer

      Constant VAR_ScriptStart should be defined in uppercase
      Open

          const VAR_ScriptStart = "FML_ScriptStart";
      Severity: Minor
      Found in FML/Script/Script.php by phpmd

      ConstantNamingConventions

      Since: 0.2

      Class/Interface constant names should always be defined in uppercase.

      Example

      class Foo {
          const MY_NUM = 0; // ok
          const myTest = ""; // fail
      }

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

      Constant VAR_LoopCounter should be defined in uppercase
      Open

          const VAR_LoopCounter = "FML_LoopCounter";
      Severity: Minor
      Found in FML/Script/Script.php by phpmd

      ConstantNamingConventions

      Since: 0.2

      Class/Interface constant names should always be defined in uppercase.

      Example

      class Foo {
          const MY_NUM = 0; // ok
          const myTest = ""; // fail
      }

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

      Constant VAR_LastTick should be defined in uppercase
      Open

          const VAR_LastTick    = "FML_LastTick";
      Severity: Minor
      Found in FML/Script/Script.php by phpmd

      ConstantNamingConventions

      Since: 0.2

      Class/Interface constant names should always be defined in uppercase.

      Example

      class Foo {
          const MY_NUM = 0; // ok
          const myTest = ""; // fail
      }

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

      There are no issues that match your filters.

      Category
      Status