Showing 22 of 40 total issues

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

<?php

namespace Galahad\Aire\Components;

use Galahad\Aire\Elements\CheckboxGroup as CheckboxGroupElement;
Severity: Major
Found in src/Components/CheckboxGroup.php and 1 other location - About 1 wk to fix
src/Components/RadioGroup.php on lines 1..247

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

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 Galahad\Aire\Components;

use Galahad\Aire\Elements\RadioGroup as RadioGroupElement; 
Severity: Major
Found in src/Components/RadioGroup.php and 1 other location - About 1 wk to fix
src/Components/CheckboxGroup.php on lines 1..247

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

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

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

class Form extends \Galahad\Aire\DTD\Form implements NonInput
{
    use CreatesElements, CreatesInputTypes;
    
    /**
Severity: Minor
Found in src/Elements/Form.php - About 4 hrs to fix

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

    <?php
    
    namespace Galahad\Aire\Elements;
    
    use BadMethodCallException;
    Severity: Minor
    Found in src/Elements/Form.php - About 4 hrs to fix

      Function connect has 97 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const connect = (target, rules = {}, messages = {}, form_request = null) => {
          if (!supported) {
              return null;
          }
          
      Severity: Major
      Found in js/src/Aire.js - About 3 hrs to fix

        Input has 30 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Input extends Element
        {
            public $name = 'input';
            
            /**
        Severity: Minor
        Found in src/DTD/Input.php - About 3 hrs to fix

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

                          if (name in classnames.invalid) {
                              const fails_classnames = classnames.invalid[name].split(' ');
                              if (fails_classnames.length) {
                                  if (fails) {
                                      element.classList.add(...fails_classnames);
          Severity: Major
          Found in js/src/Aire.js and 1 other location - About 3 hrs to fix
          js/src/Aire.js on lines 81..90

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

          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

                          if (name in classnames.valid) {
                              const passes_classnames = classnames.valid[name].split(' ');
                              if (passes_classnames.length) {
                                  if (passes) {
                                      element.classList.add(...passes_classnames);
          Severity: Major
          Found in js/src/Aire.js and 1 other location - About 3 hrs to fix
          js/src/Aire.js on lines 92..101

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

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

              public function data($data_key, $value) : self
              {
                  $key = "data-{$data_key}";
                  
                  if (null === $value) {
          Severity: Minor
          Found in src/Elements/Element.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

          Attributes has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Attributes implements Htmlable, ArrayAccess, Arrayable
          {
              /**
               * @var array
               */
          Severity: Minor
          Found in src/Elements/Attributes/Attributes.php - About 2 hrs to fix

            Function run has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const run = (e) => {
                    if ('undefined' !== typeof e && 'target' in e) {
                        touch(e);
                    }
                    
            Severity: Minor
            Found in js/src/Aire.js - About 1 hr to fix

              Method variantClassNames has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function variantClassNames() : array
                  {
                      if (null === $this->element) {
                          return [];
                      }
              Severity: Minor
              Found in src/Elements/Attributes/ClassNames.php - About 1 hr to fix

                Method aireHtml has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function aireHtml() : string
                    {
                        if (static::$aire_loaded) {
                            return '';
                        }
                Severity: Minor
                Found in src/Elements/ClientValidation.php - About 1 hr to fix

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

                  const getData = (form) => {
                      const formData = new FormData(form);
                      const values = {};
                      for (let [key, value] of formData.entries()) {
                          const name = key.replace(/\[]$/, '');
                  Severity: Minor
                  Found in js/src/Aire.js - 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 connect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export const connect = (target, rules = {}, messages = {}, form_request = null) => {
                      if (!supported) {
                          return null;
                      }
                      
                  Severity: Minor
                  Found in js/src/Aire.js - 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

                  Function offsetGet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function offsetGet($key)
                      {
                          $value = $this->items[$key] ?? null;
                          
                          if (isset($this->mutators[$key])) {
                  Severity: Minor
                  Found in src/Elements/Attributes/Attributes.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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function __construct(Aire $aire, $element_id, array $rules = [], array $messages = [], string $form_request = null, $dev_mode = false)
                  Severity: Minor
                  Found in src/Elements/ClientValidation.php - About 45 mins to fix

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

                    <?php
                    
                    namespace Galahad\Aire\Elements;
                    
                    use Galahad\Aire\Aire;
                    Severity: Minor
                    Found in src/Elements/RadioGroup.php and 1 other location - About 40 mins to fix
                    src/Elements/CheckboxGroup.php on lines 1..28

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

                    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 Galahad\Aire\Elements;
                    
                    use Galahad\Aire\Aire;
                    Severity: Minor
                    Found in src/Elements/CheckboxGroup.php and 1 other location - About 40 mins to fix
                    src/Elements/RadioGroup.php on lines 1..35

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

                    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

                    Avoid too many return statements within this method.
                    Open

                                return;
                    Severity: Major
                    Found in src/Elements/Form.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language