GrafiteInc/FormMaker

View on GitHub

Showing 139 of 139 total issues

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

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

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

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

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

          public static function styles($id, $options)
          {
              return <<<CSS
      .bs-select {
          position: relative;
      Severity: Major
      Found in src/Fields/Bootstrap/SimpleSelect.php - About 3 hrs to fix

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

            public static function styles($id, $options)
            {
                return <<<CSS
        .bs-select {
            position: relative;
        Severity: Major
        Found in src/Fields/Bootstrap/SimpleDatalist.php - About 3 hrs to fix

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

              public static function js($id, $options)
              {
                  $listGroup = config('forms.html.list-group', 'list-group list-group-flush');
                  $listGroupItem = config('forms.html.list-group-item', 'list-group-item');
                  $badge = config('forms.html.badge-tag', 'badge badge-primary float-end');
          Severity: Major
          Found in src/Fields/Attachments.php - About 3 hrs to fix

            File ModelForm.php has 303 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            
            namespace Grafite\Forms\Forms;
            
            use Exception;
            Severity: Minor
            Found in src/Forms/ModelForm.php - About 3 hrs to fix

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

              window._formsjs_trigger_onchange_function = function (event) {
                  let _method = event.target.getAttribute('data-formsjs-onchange');
              
                  if (! _method) {
                      _method = event.target.closest('form').getAttribute('data-formsjs-onchange');
              Severity: Major
              Found in src/JavaScript/core.js and 1 other location - About 3 hrs to fix
              src/JavaScript/core.js on lines 13..23

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

              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

              window._formsjs_trigger_onkeydown_function = function (event) {
                  let _method = event.target.getAttribute('data-formsjs-onkeydown');
              
                  if (! _method) {
                      _method = event.target.closest('form').getAttribute('data-formsjs-onkeydown');
              Severity: Major
              Found in src/JavaScript/core.js and 1 other location - About 3 hrs to fix
              src/JavaScript/core.js on lines 1..11

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

              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

              File FieldBuilder.php has 297 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace Grafite\Forms\Builders;
              
              use DateTime;
              Severity: Minor
              Found in src/Builders/FieldBuilder.php - About 3 hrs to fix

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

                    public static function styles($id, $options)
                    {
                        $color = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? 'var(--bs-gray-400)' : 'rgba(0, 0, 0, .1)';
                        $borderLight = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? "1px solid $color !important" : "1px solid $color !important";
                        $borderDark = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? "2px solid #444 !important" : "1px solid #444 !important";
                Severity: Major
                Found in src/Fields/Bootstrap/Select.php - About 3 hrs to fix

                  HtmlForm has 26 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  class HtmlForm extends Form
                  {
                      /**
                       * Simple wrapper for cards
                       *
                  Severity: Minor
                  Found in src/Forms/HtmlForm.php - About 3 hrs to fix

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

                        public function styles()
                        {
                            $color = $this->progressBarColor ?? '#28a745';
                            $numberOfSteps = count($this->steps($this->fieldsForSteps));
                            $size = $numberOfSteps * 100;
                    Severity: Major
                    Found in src/Forms/WizardForm.php - About 2 hrs to fix

                      FormMaker has 25 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class FormMaker
                      {
                          use HasLivewire;
                          use HasErrorBag;
                      
                      
                      Severity: Minor
                      Found in src/Services/FormMaker.php - About 2 hrs to fix

                        Method makeField has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function makeField($columnConfig, $label, $column, $value, $errors)
                            {
                                $field = null;
                        
                                if (in_array($columnConfig['type'], $this->standard)) {
                        Severity: Major
                        Found in src/Services/FieldMaker.php - About 2 hrs to fix

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

                              public static function styles($id, $options)
                              {
                                  return <<<CSS
                          .flatpickr-current-month .flatpickr-monthDropdown-months {
                              appearance: none !important;
                          Severity: Major
                          Found in src/Fields/Flatpickr.php - About 2 hrs to fix

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

                                public static function styles($id, $options)
                                {
                                    $color = (Str::of(config('forms.bootstrap-version'))->startsWith('5')) ? '--bs-primary' : '--primary';
                            
                                    $darkTheme = '';
                            Severity: Major
                            Found in src/Fields/Datepicker.php - About 2 hrs to fix

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

                                  public static function js($id, $options)
                                  {
                                      return <<<JS
                                      _formsjs_bootstrapSelect_addInpKeyPress = function (t, ev, id) {
                                          ev.stopPropagation();
                              Severity: Major
                              Found in src/Fields/Bootstrap/Select.php - About 2 hrs to fix

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

                                <?php
                                
                                namespace Grafite\Forms\Html;
                                
                                use Grafite\Forms\Html\HtmlSnippet;
                                Severity: Major
                                Found in src/Html/Button.php and 1 other location - About 2 hrs to fix
                                src/Html/Link.php on lines 1..26

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

                                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 Grafite\Forms\Html;
                                
                                use Attribute;
                                Severity: Major
                                Found in src/Html/Link.php and 1 other location - About 2 hrs to fix
                                src/Html/Button.php on lines 1..26

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

                                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 formButtonsAndClose has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    protected function formButtonsAndClose()
                                    {
                                        $rowAlignment = config('forms.form.sections.row-alignment-end', 'd-flex justify-content-end');
                                
                                        if (isset($this->buttons['cancel']) || $this->columns === 'steps' || $this->buttonsJustified) {
                                Severity: Minor
                                Found in src/Forms/HtmlForm.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

                                Severity
                                Category
                                Status
                                Source
                                Language