GrafiteInc/FormMaker

View on GitHub

Showing 124 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

              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

                                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

                                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
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language