nickwest/EloquentForms

View on GitHub

Showing 21 of 24 total issues

File Form.php has 394 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Nickwest\EloquentForms;

use Illuminate\Support\Facades\Request;
Severity: Minor
Found in src/Form.php - About 5 hrs to fix

    Form has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Form
    {
        use HasFields, Themeable{
            Themeable::setTheme as parentSetTheme;
        }
    Severity: Minor
    Found in src/Form.php - About 4 hrs to fix

      Function setPostValues has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setPostValues(array $post_data): void
          {
              foreach ($post_data as $field_name => $value) {
                  // We don't throw Exceptions here because post fields come from users and could be anything
                  // We just silently ignore invalid post fields
      Severity: Minor
      Found in src/FormTrait.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 setAllFormValues has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setAllFormValues(): void
          {
              foreach ($this->Form()->getFields() as $Field) {
                  // Use the Model Field's value if it has the field
                  if (isset($this->{$Field->getOriginalName()})) {
      Severity: Minor
      Found in src/FormTrait.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 fromJson has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function fromJson(string $json): self
          {
              $array = json_decode($json);
      
              foreach ($array as $key => $value) {
      Severity: Minor
      Found in src/Form.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 setMultipartIfNeeded has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function setMultipartIfNeeded()
          {
              if (isset($this->attributes->enctype)) {
                  return;
              }
      Severity: Minor
      Found in src/Form.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 isValid has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function isValid(): bool
          {
              $rules = [];
              foreach ($this->Fields as $Field) {
                  $rules[$Field->getOriginalName()] = [];
      Severity: Minor
      Found in src/Form.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 isFormValid has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          public function isFormValid(): bool
          {
              // Add required fields to field_rules
              $columns = $this->getAllColumns();
      
      
      Severity: Minor
      Found in src/FormTrait.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 fromJson has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function fromJson($json): void
          {
              $array = json_decode($json);
              foreach ($array as $key => $value) {
                  switch ($key) {
      Severity: Minor
      Found in src/Field.php - About 1 hr to fix

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

            public function getString(array $skip = []): string
            {
                $output = [];
        
                $this->prepareClassAttribute();
        Severity: Minor
        Found in src/Attributes.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 fromJson has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function fromJson($json): void
            {
                $array = json_decode($json);
                foreach ($array as $key => $value) {
                    switch ($key) {
        Severity: Minor
        Found in src/Field.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 setTypes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function setTypes(array $types): void
            {
                foreach ($types as $field_name => $type) {
                    if (isset($this->Fields[$field_name])) {
                        // If it's a custom type, it'll be an object
        Severity: Minor
        Found in src/Form.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 getFieldReplacement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getFieldReplacement(string $field, &$Object): string
            {
                $pattern = '/\{([a-zA-Z0-9_\?]+)\}/';
                $results = [];
                preg_match_all($pattern, $this->field_replacements[$field], $results, PREG_PATTERN_ORDER);
        Severity: Minor
        Found in src/Table.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 addMaxRule has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function addMaxRule($column, array &$rules)
            {
                // Set max length rule based on column length if available
                if (isset($column['length']) && $column['length'] != '') {
                    // Find existing max: rules
        Severity: Minor
        Found in src/FormTrait.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

        Method renameSubmitButton has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function renameSubmitButton(string $name, string $value, string $new_name, string $new_value = null, string $new_label = null): void
        Severity: Minor
        Found in src/Form.php - About 35 mins to fix

          Method setMargins has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public static function setMargins(\Maatwebsite\Excel\Sheet &$sheet, float $top = 0.7, float $right = 0.25, float $left = 0.25, float $bottom = 0.25): void
          Severity: Minor
          Found in src/Exports/TableExporter.php - About 35 mins to fix

            Function makeView has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function makeView(bool $prev_inline = false, bool $view_only = false): \Illuminate\View\View
                {
                    if ($this->error_message) {
                        $this->attributes->addClass('error');
                    }
            Severity: Minor
            Found in src/Field.php - About 35 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 renameSubmitButton has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function renameSubmitButton(string $name, string $value, string $new_name, string $new_value = null, string $new_label = null): void
                {
                    if (! isset($this->SubmitFields[$name.$value])) {
                        throw new InvalidFieldException($name.$value.' is not part of the Form');
                    }
            Severity: Minor
            Found in src/Form.php - About 35 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 getSQLEnumOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function getSQLEnumOptions(string $type, bool $nullable = false)
                {
                    if (strpos($type, 'enum') !== 0) {
                        return;
                    }
            Severity: Minor
            Found in src/Traits/DataFromMySQL.php - About 35 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 addSubform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function addSubform(string $name, self $Form, string $before_field = ''): void
                {
                    $this->addField($name);
                    $this->Fields[$name]->Subform = $Form;
            
            
            Severity: Minor
            Found in src/Form.php - About 25 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

            Severity
            Category
            Status
            Source
            Language