osunyorg/admin

View on GitHub

Showing 54 of 54 total issues

File organizations_spec.rb has 534 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'swagger_helper'

RSpec.describe 'University::Organization' do
  fixtures :all

Severity: Major
Found in spec/requests/osuny/v1/university/organizations_spec.rb - About 1 day to fix

    File events_spec.rb has 524 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'swagger_helper'
    
    RSpec.describe 'Communication::Website::Agenda::Event' do
      fixtures :all
    
    
    Severity: Major
    Found in spec/requests/osuny/v1/communication/websites/events_spec.rb - About 1 day to fix

      File posts_spec.rb has 484 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'swagger_helper'
      
      RSpec.describe 'Communication::Website::Post' do
        fixtures :all
      
      
      Severity: Minor
      Found in spec/requests/osuny/v1/communication/websites/posts_spec.rb - About 7 hrs to fix

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

            init: function () {
                'use strict';
                var i;
                this.textareas = document.querySelectorAll('textarea[data-provider="codemirror"]');
                this.instances = [];
        Severity: Major
        Found in app/assets/javascripts/admin/plugins/codemirror.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/admin/plugins/sortable.js on lines 8..16

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

        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

            init: function () {
                'use strict';
                var i;
                this.containers = document.querySelectorAll('[data-sortable]');
                this.instances = [];
        Severity: Major
        Found in app/assets/javascripts/admin/plugins/sortable.js and 1 other location - About 3 hrs to fix
        app/assets/javascripts/admin/plugins/codemirror.js on lines 13..21

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

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

            setConfigs: function () {
                'use strict';
                this.setConfig('nothing',
                    {
                        toolbar: []
        Severity: Major
        Found in app/assets/javascripts/application/plugins/summernote.js - About 2 hrs to fix

          Method upsert has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def upsert
              posts_params = params[:posts] || []
              every_post_has_migration_identifier = posts_params.all? { |post_params|
                post_params[:migration_identifier].present?
              }
          Severity: Minor
          Found in app/controllers/api/osuny/communication/websites/posts_controller.rb - 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 upsert has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def upsert
              organizations_params = params[:organizations] || []
              every_organization_has_migration_identifier = organizations_params.all? { |organization_params|
                organization_params[:migration_identifier].present?
              }
          Severity: Minor
          Found in app/controllers/api/osuny/university/organizations_controller.rb - 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 upsert has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

            def upsert
              events_params = params[:events] || []
              every_event_has_migration_identifier = events_params.all? { |event_params|
                event_params[:migration_identifier].present?
              }

          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

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

              if (notyfNotices.length > 0) {
                  notyf.open({
                      type: 'success',
                      position: {
                          x: 'center',
          Severity: Major
          Found in app/assets/javascripts/application/plugins/notyf.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/application/plugins/notyf.js on lines 8..20

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

          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 (notyfAlerts.length > 0) {
                  notyf.open({
                      type: 'error',
                      position: {
                          x: 'center',
          Severity: Major
          Found in app/assets/javascripts/application/plugins/notyf.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/application/plugins/notyf.js on lines 21..33

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

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

            def set_l10n_attributes(base_params, resource)
              l10ns_attributes = base_params.delete(:localizations)
              base_params[:localizations_attributes] = []
              l10ns_attributes.each do |language_iso_code, l10n_params|
                l10n_permitted_params = l10n_params.permit(*l10n_permitted_keys)

          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

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

                  for (i = 0; i < this.editButtons.length; i += 1) {
                      button = this.editButtons[i];
                      button.addEventListener('click', this.onBlockActionClick.bind(this));
                  }
          app/assets/javascripts/admin/commons/content_editor/offcanvas.js on lines 21..24
          app/assets/javascripts/admin/commons/content_editor/tabs.js on lines 21..24
          app/assets/javascripts/admin/communication/websites/menu_items.js on lines 14..17

          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

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

              hide: function (target) {
                  'use strict';
                  var input = target.querySelector('select');
                  target.classList.add('d-none');
                  if (input) {
          Severity: Major
          Found in app/assets/javascripts/admin/commons/conditional.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/admin/commons/conditional.js on lines 46..54

          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

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

                  for (i = 0; i < this.addBlockButtons.length; i += 1) {
                      button = this.addBlockButtons[i];
                      button.addEventListener('click', this.onBlockActionClick.bind(this));
                  }
          app/assets/javascripts/admin/commons/content_editor/offcanvas.js on lines 17..20
          app/assets/javascripts/admin/commons/content_editor/tabs.js on lines 21..24
          app/assets/javascripts/admin/communication/websites/menu_items.js on lines 14..17

          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

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

                  for (i = 0; i < this.kinds.length; i += 1) {
                      kind = this.kinds[i];
                      kind.addEventListener('click', this.onKindChange.bind(this));
                  }
          app/assets/javascripts/admin/commons/content_editor/offcanvas.js on lines 17..20
          app/assets/javascripts/admin/commons/content_editor/offcanvas.js on lines 21..24
          app/assets/javascripts/admin/commons/content_editor/tabs.js on lines 21..24

          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

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

              show: function (target) {
                  'use strict';
                  var input = target.querySelector('select');
                  target.classList.remove('d-none');
                  if (input) {
          Severity: Major
          Found in app/assets/javascripts/admin/commons/conditional.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/admin/commons/conditional.js on lines 36..44

          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

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

                  for (i = 0; i < this.tabs.length; i += 1) {
                      tab = this.tabs[i];
                      tab.addEventListener('shown.bs.tab', this.tabChanged.bind(this));
                  }
          app/assets/javascripts/admin/commons/content_editor/offcanvas.js on lines 17..20
          app/assets/javascripts/admin/commons/content_editor/offcanvas.js on lines 21..24
          app/assets/javascripts/admin/communication/websites/menu_items.js on lines 14..17

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

              initSortable: function () {
                  'use strict';
                  var nestedSortables,
                      i;
          
          
          Severity: Minor
          Found in app/assets/javascripts/admin/plugins/treeview.js - About 1 hr to fix

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

              def upsert
                organizations_params = params[:organizations] || []
                every_organization_has_migration_identifier = organizations_params.all? { |organization_params|
                  organization_params[:migration_identifier].present?
                }
            Severity: Minor
            Found in app/controllers/api/osuny/university/organizations_controller.rb - About 1 hr to fix
              Severity
              Category
              Status
              Source
              Language