GrafiteInc/FormMaker

View on GitHub

Showing 124 of 139 total issues

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

    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

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

                            public static function styles($id, $options)
                            {
                                return <<<CSS
                        @media (prefers-color-scheme: dark) {
                            .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
                        Severity: Minor
                        Found in src/Fields/Bootstrap/Select2.php - About 1 hr to fix

                          Method delete has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

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

                            Method __construct has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function __construct()
                                {
                                    parent::__construct();
                            
                                    $this->url = app(UrlGenerator::class);
                            Severity: Minor
                            Found in src/Forms/HtmlForm.php - About 1 hr to fix

                              Method make has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function make()
                                  {
                                      if ($this->orientation === 'horizontal') {
                                          $this->formClass = $this->formClass ?? config('forms.form.horizontal-class', 'form-horizontal');
                                      }
                              Severity: Minor
                              Found in src/Forms/BaseForm.php - About 1 hr to fix

                                Method create has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function create()
                                    {
                                        $this->submitMethod = $this->submitMethods['create'] ?? null;
                                
                                        if ($this->orientation === 'horizontal') {
                                Severity: Minor
                                Found in src/Forms/ModelForm.php - About 1 hr to fix

                                  Method make has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function make(string $column, array $columnConfig, $object = null)
                                      {
                                          $this->builder
                                              ->setLivewire($this->withLivewire)
                                              ->setLivewireOnKeydown($this->livewireOnKeydown)
                                  Severity: Minor
                                  Found in src/Services/FieldMaker.php - About 1 hr to fix

                                    Method formButtonsAndClose has 39 lines of code (exceeds 25 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 1 hr to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language