administrcms/form

View on GitHub

Showing 8 of 43 total issues

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

abstract class Form implements ValidatesWhenSubmitted
{
    use RenderAttributesTrait;

    protected $options = [];
Severity: Minor
Found in src/Form.php - About 3 hrs to fix

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

    abstract class Field
    {
        use RenderAttributesTrait;
    
        protected $name;
    Severity: Minor
    Found in src/Field/Field.php - About 3 hrs to fix

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

      <?php
      
      namespace Administr\Form;
      
      use Administr\Form\Contracts\ValidatesWhenSubmitted;
      Severity: Minor
      Found in src/Form.php - About 2 hrs to fix

        Function setEnctype has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            public function setEnctype()
            {
                if(array_key_exists('enctype', $this->options)) {
                    return $this;
                }
        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 translated has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function translated()
            {
                $languages = Language::pluck('id');
        
                $this->form($this->builder);
        Severity: Minor
        Found in src/Form.php - About 45 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 optionsToMethods has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function optionsToMethods(array $options)
            {
                foreach($options as $name => $value)
                {
                    if(! method_exists($this, $name) ) {
        Severity: Minor
        Found in src/Field/Field.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

        Function getParsedRules has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getParsedRules()
            {
                $transformedRules = $this->validator->make([], $this->rules())->getRules();
        
                foreach($transformedRules as $field => $rules) {
        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

        Function getValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getValue($field, $language_id = 0)
            {
                $dataSource = $this->dataSource;
        
                if ($dataSource instanceof Translatable && $language_id > 0) {
        Severity: Minor
        Found in src/FormBuilder.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