AthensFramework/core

View on GitHub

Showing 104 of 104 total issues

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

        if ($this->canQueryFilter === true) {
            $query = $this->getNextFilter()->queryFilter($query);
            $choiceKey = FilterControls::getControl($this->id, "value", array_keys($this->options)[0]);

            $choice = $this->options[$choiceKey];
Severity: Major
Found in src/filter/RelationFilter.php and 1 other location - About 1 day to fix
src/filter/SortFilter.php on lines 52..89

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

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

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

        if ($this->canQueryFilter === true) {
            $query = $this->getNextFilter()->queryFilter($query);
            $choiceKey = FilterControls::getControl($this->id, "value", array_keys($this->options)[0]);

            $choice = $this->options[$choiceKey];
Severity: Major
Found in src/filter/SortFilter.php and 1 other location - About 1 day to fix
src/filter/RelationFilter.php on lines 134..171

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

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

athens.ajax_section = (function () {

    /**
     * The set of get variables which shall be included when requesting a section
     *
Severity: Minor
Found in assets/js/ajax-section.js - About 7 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 ajax_section has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

athens.ajax_section = (function () {

    /**
     * The set of get variables which shall be included when requesting a section
     *
Severity: Major
Found in assets/js/ajax-section.js - About 5 hrs to fix

    Function soft_pagination has 129 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    athens.soft_pagination = (function () {
    
        var page, rows, table, paginateBy, numPages, select, div;
    
        page = 1;
    Severity: Major
    Found in assets/js/soft-pagination.js - About 5 hrs to fix

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

      class Field implements FieldInterface
      {
          use WritableTrait;
      
          /** @var bool  */
      Severity: Minor
      Found in src/field/Field.php - About 4 hrs to fix

        Function multi_panel has 119 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        athens.multi_panel = (function () {
        
            /**
             * Private method for creating a slider panel.
             *
        Severity: Major
        Found in assets/js/multi-panel.js - About 4 hrs to fix

          Function visitPage has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
          Open

              public function visitPage(PageInterface $page)
              {
                  /** @var WritableInterface[] $writables */
                  $writables = [$page];
          
          
          Severity: Minor
          Found in src/writer/ExcelWriter.php - About 4 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 ajax has 111 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          athens.ajax = (function () {
          
              /**
               * Private method which encapsulates retrieving the CSRFTOKEN global.
               *
          Severity: Major
          Found in assets/js/ajax.js - About 4 hrs to fix

            Function ajax has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
            Open

            athens.ajax = (function () {
            
                /**
                 * Private method which encapsulates retrieving the CSRFTOKEN global.
                 *
            Severity: Minor
            Found in assets/js/ajax.js - About 4 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 search has 93 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            athens.search = (function () {
            
                var searchDiv = $(".search-div");
            
                /**
            Severity: Major
            Found in assets/js/search.js - About 3 hrs to fix

              Function pagination has 89 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              athens.pagination = (function () {
              
                  var getPaginationContainer = function (handle) {
                      return $("div.pagination-container[data-handle-for=" + handle +"]");
                  };
              Severity: Major
              Found in assets/js/pagination.js - About 3 hrs to fix

                Function soft_pagination has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                athens.soft_pagination = (function () {
                
                    var page, rows, table, paginateBy, numPages, select, div;
                
                    page = 1;
                Severity: Minor
                Found in assets/js/soft-pagination.js - About 3 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 validate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function validate()
                    {
                        $this->isValid = true;
                
                        foreach ($this->getWritableBearer()->getWritables() as $name => $writable) {
                Severity: Minor
                Found in src/form/Form.php - About 3 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 build has 75 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function build()
                    {
                        $this->validateId();
                
                        $type = $this->retrieveOrException("type", __METHOD__);
                Severity: Major
                Found in src/filter/FilterBuilder.php - About 3 hrs to fix

                  Method getEnvironment has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function getEnvironment()
                      {
                          if ($this->environment === null) {
                              $loader = new \Twig_Loader_Filesystem($this->getTemplatesDirectories());
                              $this->environment = new \Twig_Environment($loader);
                  Severity: Major
                  Found in src/writer/TwigTemplateWriter.php - About 2 hrs to fix

                    Function multi_adder has 66 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    athens.multi_adder = (function () {
                    
                        var getLastRow = function (multiAdderTable) {
                            return multiAdderTable.find("tr.form-row").last();
                        };
                    Severity: Major
                    Found in assets/js/multi-adder.js - About 2 hrs to fix

                      Function multi_panel has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                      Open

                      athens.multi_panel = (function () {
                      
                          /**
                           * Private method for creating a slider panel.
                           *
                      Severity: Minor
                      Found in assets/js/multi-panel.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 makeDetail has 60 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function makeDetail()
                          {
                              /** @var boolean $idWasProvided */
                              $idWasProvided = static::getObjectId() !== null;
                      
                      
                      Severity: Major
                      Found in src/admin/Admin.php - About 2 hrs to fix

                        Method makeTables has 58 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function makeTables($queries = null)
                            {
                                /** @var WritableInterface[] $tables */
                                $tables = [];
                        
                        
                        Severity: Major
                        Found in src/admin/Admin.php - About 2 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language