lovata/oc-toolbox-plugin

View on GitHub

Showing 227 of 236 total issues

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

    protected function setController()
    {
        if ($this->checkAdditionList(self::CODE_CONTROLLER)) {
            return;
        }
Severity: Major
Found in classes/console/CommonCreateFile.php and 1 other location - About 2 hrs to fix
classes/console/CommonCreateFile.php on lines 228..242

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

CommonCreateFile has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class CommonCreateFile extends Command
{
    use LogoTrait;

    const PREFIX_LOWER   = 'lower_';
Severity: Minor
Found in classes/console/CommonCreateFile.php - About 2 hrs to fix

    CommonProperty has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class CommonProperty extends ImportModel
    {
        const NAME = 'property';
    
        use Validation;
    Severity: Minor
    Found in models/CommonProperty.php - About 2 hrs to fix

      Function setLangProperties has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          private function setLangProperties()
          {
              if (empty($this->obElement) || !$this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) {
                  return;
              }
      Severity: Minor
      Found in classes/item/ElementItem.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

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

      <?php namespace Lovata\Toolbox\Classes\Console;
      
      use Lovata\Toolbox\Classes\Parser\Create\ExtendModelColumnsHandlerCreateFile;
      
      /**
      Severity: Major
      Found in classes/console/CreateExtendModelColumnsHandler.php and 1 other location - About 2 hrs to fix
      classes/console/CreateExtendModelFieldsHandler.php on lines 1..30

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

      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

      <?php namespace Lovata\Toolbox\Classes\Console;
      
      use Lovata\Toolbox\Classes\Parser\Create\ExtendModelFieldsHandlerCreateFile;
      
      /**
      Severity: Major
      Found in classes/console/CreateExtendModelFieldsHandler.php and 1 other location - About 2 hrs to fix
      classes/console/CreateExtendModelColumnsHandler.php on lines 1..30

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

      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

          public function parseByWrapper($arNameList, $sContent)
          {
              if (empty($arNameList) || !is_array($arNameList) || empty($sContent)) {
                  return '';
              }
      Severity: Major
      Found in traits/parse/ParseByPatternTrait.php and 1 other location - About 2 hrs to fix
      traits/parse/ParseByPatternTrait.php on lines 36..48

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

      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

          public function parseByNameWrapper($arNameList, $sContent)
          {
              if (empty($arNameList) || !is_array($arNameList) || empty($sContent)) {
                  return '';
              }
      Severity: Major
      Found in traits/parse/ParseByPatternTrait.php and 1 other location - About 2 hrs to fix
      traits/parse/ParseByPatternTrait.php on lines 56..68

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

      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

      Function getWidgetData has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getWidgetData()
          {
              $arResult = [];
      
              switch ($this->type) {
      Severity: Minor
      Found in models/CommonProperty.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

      Method getWidgetData has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getWidgetData()
          {
              $arResult = [];
      
              switch ($this->type) {
      Severity: Major
      Found in models/CommonProperty.php - About 2 hrs to fix

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

            protected function checkEnableList($sCode)
            {
                $arEnableList = array_get($this->arData, 'enable');
        
                if (!empty($sCode) && !empty($arEnableList) && is_array($arEnableList) && in_array($sCode, $arEnableList)) {
        Severity: Major
        Found in classes/console/CommonCreateFile.php and 1 other location - About 2 hrs to fix
        classes/console/CommonCreateFile.php on lines 439..448

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

        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

            protected function checkAdditionList($sCode)
            {
                $arAdditionList = array_get($this->arData, 'addition');
        
                if (!empty($sCode) && !empty($arAdditionList) && is_array($arAdditionList) && in_array($sCode, $arAdditionList)) {
        Severity: Major
        Found in classes/console/CommonCreateFile.php and 1 other location - About 2 hrs to fix
        classes/console/CommonCreateFile.php on lines 423..432

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

        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

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

            protected function save()
            {
                if (!$this->bSave || empty($this->arYAML) || !isset($this->sFilePath) || empty($this->sFilePath)) {
                    return;
                }
        Severity: Major
        Found in classes/parser/update/PluginVersionYAMLUpdateFile.php and 1 other location - About 1 hr to fix
        classes/parser/update/PluginYAMLUpdateFile.php on lines 165..173

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

        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

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

            protected function save()
            {
                if (!$this->bSave || empty($this->arYAML) || !isset($this->sFilePath) || empty($this->sFilePath)) {
                    return;
                }
        Severity: Major
        Found in classes/parser/update/PluginYAMLUpdateFile.php and 1 other location - About 1 hr to fix
        classes/parser/update/PluginVersionYAMLUpdateFile.php on lines 149..157

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

        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

        Method callCommandList has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function callCommandList()
            {
                $sMessage = Lang::get('lovata.toolbox::lang.message.create', ['name' => self::CODE_MODEL]);
        
                if ($this->confirm($sMessage, true)) {
        Severity: Minor
        Found in classes/console/CreateAll.php - About 1 hr to fix

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

              protected function sendMail($sEmail)
              {
                  if (empty($this->sMailTemplate) || empty($sEmail)) {
                      return;
                  }
          Severity: Minor
          Found in classes/helper/SendMailHelper.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

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

              protected function getElementListFromDB($arElementIDList, $arResult)
              {
                  if (empty($arElementIDList)) {
                      return $arResult;
                  }
          Severity: Minor
          Found in classes/collection/ElementCollection.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 parse has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function parse()
              {
                  if (empty($this->arImportSettings)) {
                      return;
                  }
          Severity: Minor
          Found in classes/helper/ParseXMLNode.php - About 1 hr to fix

            Method getUrlParamList has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getUrlParamList($sPageCode, $sComponentName, $sParamName = 'slug', $bFindWildcard = false)
                {
                    $sCacheKey = implode('_', [$sPageCode, $sComponentName, $sParamName, (int) $bFindWildcard]);
                    if ($this->hasCache($sCacheKey)) {
                        return $this->getCachedData($sCacheKey);
            Severity: Minor
            Found in classes/helper/PageHelper.php - About 1 hr to fix

              Method update has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function update()
                  {
                      if (!$this->bUpdate || !isset($this->sFilePath) || empty($this->sFilePath)) {
                          return;
                      }
              Severity: Minor
              Found in classes/parser/update/PluginYAMLUpdateFile.php - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language