GrafiteInc/FormMaker

View on GitHub

Showing 139 of 139 total issues

Function indexBody has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public function indexBody($query = null)
    {
        $fields = $this->parseVisibleFields($this->parseFields($this->fields()));
        $sortBy = array_keys($fields)[0];
        $query = $query;
Severity: Minor
Found in src/Forms/Concerns/HasIndex.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 Country.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Grafite\Forms\Fields\Bootstrap;

use Grafite\Forms\Fields\Bootstrap\Select;
Severity: Minor
Found in src/Fields/Bootstrap/Country.php - About 2 hrs to fix

    Method handler has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handler($content)
        {
            $convertor = new HtmlConvertor([
                'raw' => function ($html) {
                    return $html;
    Severity: Major
    Found in src/Parsers/Editor.php - About 2 hrs to fix

      Method js has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function js($id, $options)
          {
              return <<<JS
                  _formsjs_editorField = function (element) {
                      if (! element.getAttribute('data-formsjs-rendered')) {
      Severity: Major
      Found in src/Fields/Editor.php - About 2 hrs to fix

        Method styles has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function styles($id, $options)
            {
                $colorVariable = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? '--bs-primary' : '--primary';
                $position = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? 'relative' : 'absolute';
                $labelSpacing = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? ".form-check-label[for=\"{$id}\"] {margin-left: -24px;}" : '';
        Severity: Major
        Found in src/Fields/Toggled.php - About 2 hrs to fix

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

                  _fields[i].addEventListener("change", function (e) {
                      if (this.value.length > 0) {
                          this.classList.remove('_formValidationClass');
                          if (this.nextSibling) {
                              this.nextSibling.remove();
          Severity: Major
          Found in src/JavaScript/validation.js and 2 other locations - About 2 hrs to fix
          src/JavaScript/validation.js on lines 5..12
          src/JavaScript/validation.js on lines 14..21

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

                  _fields[i].addEventListener("keyup", function (e) {
                      if (this.value.length > 0) {
                          this.classList.remove('_formValidationClass');
                          if (this.nextSibling) {
                              this.nextSibling.remove();
          Severity: Major
          Found in src/JavaScript/validation.js and 2 other locations - About 2 hrs to fix
          src/JavaScript/validation.js on lines 14..21
          src/JavaScript/validation.js on lines 23..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 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 3 locations. Consider refactoring.
          Open

                  _fields[i].addEventListener("onfocusout", function (e) {
                      if (this.value.length > 0) {
                          this.classList.remove('_formValidationClass');
                          if (this.nextSibling) {
                              this.nextSibling.remove();
          Severity: Major
          Found in src/JavaScript/validation.js and 2 other locations - About 2 hrs to fix
          src/JavaScript/validation.js on lines 5..12
          src/JavaScript/validation.js on lines 23..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 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

          Method makeSelect has 57 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function makeSelect($name, $selected, $options)
              {
                  $selectOptions = '';
          
                  if (isset($options['attributes']['value'])) {
          Severity: Major
          Found in src/Builders/FieldBuilder.php - About 2 hrs to fix

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

                public function indexHeaders()
                {
                    $headers = '';
            
                    $columns = (! empty($this->indexColumns())) ? $this->indexColumns() : $this->parseVisibleFields($this->parseFields($this->fields()));
            Severity: Minor
            Found in src/Forms/Concerns/HasIndex.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 onLoadJsData has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function onLoadJsData($id, $options)
                {
                    $route = null;
            
                    if (isset($options['upload_route'])) {
            Severity: Major
            Found in src/Fields/Quill.php - About 2 hrs to fix

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

              window._formsjs_trigger_onclick_function = function (event) {
                  event.preventDefault();
              
                  let _form = event.target.form;
                  let _method = event.target.getAttribute('data-formsjs-onclick');
              Severity: Minor
              Found in src/JavaScript/core.js - 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 js has 52 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function js($id, $options)
                  {
                      return <<<JS
                              _formsjs_grapesjsField = function (element) {
                                  if (! element.getAttribute('data-formsjs-rendered')) {
              Severity: Major
              Found in src/Fields/GrapesJs.php - About 2 hrs to fix

                File Country.php has 253 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                
                namespace Grafite\Forms\Fields;
                
                use Grafite\Forms\Fields\AutoSuggestSelect;
                Severity: Minor
                Found in src/Fields/Country.php - About 2 hrs to fix

                  File WizardForm.php has 252 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  
                  namespace Grafite\Forms\Forms;
                  
                  class WizardForm extends HtmlForm
                  Severity: Minor
                  Found in src/Forms/WizardForm.php - About 2 hrs to fix

                    Method action has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function action($method, $route, $button = 'Send', $options = [], $asModal = false, $disableOnSubmit = false, $submitViaAjax = false)
                        {
                            if (! is_null($this->submitViaAjax)) {
                                $submitViaAjax = $this->submitViaAjax;
                            }
                    Severity: Major
                    Found in src/Forms/Form.php - About 2 hrs to fix

                      Method styles has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function styles($id, $options)
                          {
                              $themes = [];
                      
                              $themes['light'] = <<<CSS
                      Severity: Major
                      Found in src/Fields/Editor.php - About 2 hrs to fix

                        Method edit has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function edit($model = null)
                            {
                                if (! is_null($model)) {
                                    $this->setInstance($model);
                                }
                        Severity: Minor
                        Found in src/Forms/ModelForm.php - About 2 hrs to fix

                          Method indexBody has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function indexBody($query = null)
                              {
                                  $fields = $this->parseVisibleFields($this->parseFields($this->fields()));
                                  $sortBy = array_keys($fields)[0];
                                  $query = $query;
                          Severity: Minor
                          Found in src/Forms/Concerns/HasIndex.php - About 1 hr to fix

                            Method js has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function js($id, $options)
                                {
                                    return <<<JS
                                        _formsjs_trixField = function (element) {
                                            element.addEventListener('grafite-form-change', function (event) {
                            Severity: Minor
                            Found in src/Fields/Trix.php - About 1 hr to fix
                              Severity
                              Category
                              Status
                              Source
                              Language