AthensFramework/core

View on GitHub

Showing 104 of 104 total issues

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

        $this->onValidFunction = function (FormInterface $form) use ($onValidFunctions) {
            $args = array_merge([$this], func_get_args());

            foreach ($form->getWritableBearer()->getWritables() as $writable) {
                if ($writable instanceof FormInterface) {
Severity: Major
Found in src/form/FormBuilderTrait.php and 1 other location - About 2 hrs to fix
src/form/FormBuilderTrait.php on lines 246..260

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

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

        $this->onInvalidFunction = function (FormInterface $form) use ($onInvalidFunctions) {
            $args = array_merge([$this], func_get_args());

            foreach ($form->getWritableBearer()->getWritables() as $writable) {
                if ($writable instanceof FormInterface) {
Severity: Major
Found in src/form/FormBuilderTrait.php and 1 other location - About 2 hrs to fix
src/form/FormBuilderTrait.php on lines 315..329

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

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

Method visitPage has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function visitPage(PageInterface $page)
    {
        /** @var WritableInterface[] $writables */
        $writables = [$page];

Severity: Major
Found in src/writer/ExcelWriter.php - About 2 hrs to fix

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

                    } else {
                        athens.ajax_section.unsetGetVar(getVar(ajaxSectionName, handle, 'fieldname' + i));
                        athens.ajax_section.unsetGetVar(getVar(ajaxSectionName, handle, 'operation' + i));
                        athens.ajax_section.unsetGetVar(getVar(ajaxSectionName, handle, 'value' + i));
                    }
    Severity: Major
    Found in assets/js/search.js and 1 other location - About 2 hrs to fix
    assets/js/search.js on lines 111..115

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

    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

            for (var i = 0; i <= 5; i++) {
                athens.ajax_section.unsetGetVar(getVar(ajaxSectionName, handle, 'fieldname' + i));
                athens.ajax_section.unsetGetVar(getVar(ajaxSectionName, handle, 'operation' + i));
                athens.ajax_section.unsetGetVar(getVar(ajaxSectionName, handle, 'value' + i));
            }
    Severity: Major
    Found in assets/js/search.js and 1 other location - About 2 hrs to fix
    assets/js/search.js on lines 46..50

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

    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

    File Admin.php has 254 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Athens\Core\Admin;
    
    use Athens\Core\Etc\StringUtils;
    Severity: Minor
    Found in src/admin/Admin.php - About 2 hrs to fix

      Method applyToRows has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function applyToRows(array $rows)
          {
              $fieldName = $this->getFieldName();
              $condition = $this->getCondition();
              $criterion = $this->getCriterion();
      Severity: Minor
      Found in src/filter-statement/ExcludingFilterStatement.php - About 1 hr to fix

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

        athens.pagination = (function () {
        
            var getPaginationContainer = function (handle) {
                return $("div.pagination-container[data-handle-for=" + handle +"]");
            };
        Severity: Minor
        Found in assets/js/pagination.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

        Method build has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function build()
            {
                $this->validateInitializer();
                $this->validateRenderer();
                
        Severity: Minor
        Found in src/admin/AdminBuilder.php - About 1 hr to fix

          Function setupSoftPaginationFilter has 44 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var setupSoftPaginationFilter = function (handle) {
                  $(
                      function () {
                          var inactiveControls = getInactiveControls(handle);
                          var activeControls = getActiveControls(handle);
          Severity: Minor
          Found in assets/js/soft-pagination.js - About 1 hr to fix

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

                    if (sectionRegistry.hasOwnProperty(id) && !targetDiv.data("request-uri")) {
                        targetUrl = sectionRegistry[id];
                    } else {
                        targetUrl = targetDiv.data("request-uri");
                        sectionRegistry[id] = targetUrl;
            Severity: Major
            Found in assets/js/ajax-section.js and 1 other location - About 1 hr to fix
            assets/js/ajax-section.js on lines 179..184

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

            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 (sectionRegistry.hasOwnProperty(id) && !targetDiv.data("request-uri")) {
                            targetUrl = sectionRegistry[id];
                        } else {
                            targetUrl = targetDiv.data("request-uri");
                            sectionRegistry[id] = targetUrl;
            Severity: Major
            Found in assets/js/ajax-section.js and 1 other location - About 1 hr to fix
            assets/js/ajax-section.js on lines 156..161

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

            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 alert has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            athens.alert = (function () {
            
                /**
                 * Creates an alert div, appends it to the notification area, and schedules it for removal.
                 *
            Severity: Minor
            Found in assets/js/alert.js - About 1 hr to fix

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

                  public function queryFilter(QueryWrapperInterface $query)
                  {
                      $this->canQueryFilter = true;
                      if ($this->getNextFilter()->canQueryFilter === false) {
                          $this->canQueryFilter = false;
              Severity: Minor
              Found in src/filter/SortFilter.php - About 1 hr to fix

                Method buildTopMatter has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function buildTopMatter()
                    {
                        $topMatterBuilder = SectionBuilder::begin()
                            ->setType(SectionBuilder::TYPE_SPAN);
                
                
                Severity: Minor
                Found in src/page/PageBuilder.php - About 1 hr to fix

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

                      public function __construct(
                          $id,
                          $type,
                          array $classes,
                          array $data,
                  Severity: Minor
                  Found in src/admin/Admin.php - About 1 hr to fix

                    Method queryFilter has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function queryFilter(QueryWrapperInterface $query)
                        {
                            $this->canQueryFilter = true;
                            if ($this->getNextFilter()->canQueryFilter === false) {
                                $this->canQueryFilter = false;
                    Severity: Minor
                    Found in src/filter/RelationFilter.php - About 1 hr to fix

                      Function suffixFormFieldsFixed has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function suffixFormFieldsFixed(FormInterface $form, $suffix)
                          {
                              foreach ($form->getWritableBearer()->getWritables() as $writable) {
                                  if ($writable instanceof FieldInterface) {
                                      $writable->addSuffix($suffix);
                      Severity: Minor
                      Found in src/initializer/Initializer.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 submitForm has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function submitForm(form, success)
                          {
                              athens.alert.makeAlert("Submitting form.", "info");
                      
                              if (typeof(success) === 'undefined') {
                      Severity: Minor
                      Found in assets/js/ajax.js - About 1 hr to fix

                        Method build has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function build()
                            {
                                if ($this->type === null) {
                                    throw new \Exception("You must set a page type using ::setType before calling this function.");
                                }
                        Severity: Minor
                        Found in src/page/PageBuilder.php - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language