lovata/oc-toolbox-plugin

View on GitHub

Showing 227 of 236 total issues

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

    protected function importImageList()
    {
        if (!$this->bNeedUpdateImageList) {
            return;
        }
Severity: Minor
Found in classes/helper/AbstractImportModel.php - About 1 hr to fix

    Function update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function update($arData)
        {
            $arReplaceList = array_get($this->arData, 'replace');
    
            if (empty($arData) || !is_array($arData) || empty($arReplaceList) || !$this->bUpdate) {
    Severity: Minor
    Found in classes/parser/update/PluginLangUpdateFile.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 getModeProperty has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function getModeProperty()
        {
            $arResult = [
                self::PROPERTY_MODE        => [
                    'title'   => 'lovata.toolbox::lang.component.property_mode',
    Severity: Minor
    Found in classes/component/ComponentSubmitForm.php - About 1 hr to fix

      Method sendMail has 28 lines of code (exceeds 25 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

        Method setFieldList has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function setFieldList($arException = [], $arOnlyThis = [])
            {
                if ($this->checkAdditionList(self::CODE_FIELDS)) {
                    return;
                }
        Severity: Minor
        Found in classes/console/CommonCreateFile.php - About 1 hr to fix

          Function setCachedFieldList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function setCachedFieldList()
              {
                  if (!$this->obElement->methodExists('getCachedField')) {
                      return;
                  }
          Severity: Minor
          Found in classes/item/ElementItem.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 initImageList has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function initImageList()
              {
                  if (!array_key_exists('images', $this->arImportData)) {
                      $this->bNeedUpdateImageList = false;
                      return;
          Severity: Minor
          Found in classes/helper/AbstractImportModelFromXML.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 subscribe has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function subscribe()
              {
                  $sModelClass = $this->getModelClass();
          
                  $sModelClass::extend(function ($obModel) {
          Severity: Minor
          Found in classes/event/AbstractModelRelationHandler.php - About 1 hr to fix

            Method initImageList has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function initImageList()
                {
                    if (!array_key_exists('images', $this->arImportData)) {
                        $this->bNeedUpdateImageList = false;
                        return;
            Severity: Minor
            Found in classes/helper/AbstractImportModelFromXML.php - About 1 hr to fix

              Method setLangProperties has 26 lines of code (exceeds 25 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 1 hr to fix

                Method importPreviewImage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function importPreviewImage()
                    {
                        if (!$this->bNeedUpdatePreviewImage) {
                            return;
                        }
                Severity: Minor
                Found in classes/helper/AbstractImportModel.php - About 1 hr to fix

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

                      protected function initImageList()
                      {
                          if (!array_key_exists('images', $this->arImportData)) {
                              $this->bNeedUpdateImageList = false;
                              return;
                  Severity: Minor
                  Found in classes/helper/AbstractImportModelFromCSV.php - About 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      protected function setEnableList($arData)
                      {
                          if (empty($arData)) {
                              return;
                          }
                  Severity: Minor
                  Found in classes/console/CommonCreateFile.php - About 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      protected function getActiveLangList()
                      {
                          if (self::$arActiveLangList !== null || !PluginManager::instance()->hasPlugin('RainLab.Translate')) {
                              return self::$arActiveLangList;
                          }
                  Severity: Minor
                  Found in traits/helpers/TraitInitActiveLang.php - About 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      protected function importPreviewImage()
                      {
                          if (!$this->bNeedUpdatePreviewImage) {
                              return;
                          }
                  Severity: Minor
                  Found in classes/helper/AbstractImportModel.php - About 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

                  Function update has a Cognitive Complexity of 9 (exceeds 5 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 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      protected function setAuthorAndPlugin($bExpansion, $sCode, $sExpansionCode, $sExample)
                      {
                          if (empty($sCode) || empty($sExpansionCode) || empty($sExample) || !is_bool($bExpansion)) {
                              return;
                          }
                  Severity: Minor
                  Found in classes/console/CommonCreateFile.php - About 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      protected static function addPriceFiledMethods($obElement)
                      {
                          if (empty($obElement->arPriceField) || !is_array($obElement->arPriceField)) {
                              return;
                          }
                  Severity: Minor
                  Found in traits/helpers/PriceHelperTrait.php - About 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

                  Function callCommandList has a Cognitive Complexity of 9 (exceeds 5 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 55 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      public function first()
                      {
                          if ($this->isEmpty()) {
                              return $this->makeItem(null);
                          }
                  Severity: Minor
                  Found in classes/collection/ElementCollection.php and 1 other location - About 45 mins to fix
                  classes/collection/ElementCollection.php on lines 437..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 56.

                  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

                  Severity
                  Category
                  Status
                  Source
                  Language