getsimpleadmin/simpleadmin-rails

View on GitHub

Showing 15 of 15 total issues

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

  def import_fields!
    models.model_names.each do |model_name|
      next unless model_names.key?(model_name)

      entity = project.entities.find_by(model_klass_name: model_name)
Severity: Minor
Found in app/services/simpleadmin/db_structure_import.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

Function connectCharts has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    connectCharts() {
        var selector = 'chart';

        if (!document.getElementsByClassName(selector)) {
            return false;
Severity: Minor
Found in app/javascript/packs/controllers/admin_controller.js - About 1 hr to fix

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

        toggleMobileMenu() {
          if (this.sidebarMenuTarget.classList.contains('sidebar-mobile-open')) {
            this.sidebarMenuTarget.classList.remove('sidebar-mobile-open');
          } else {
            this.sidebarMenuTarget.classList.add('sidebar-mobile-open');
    Severity: Major
    Found in app/javascript/packs/controllers/admin_controller.js and 2 other locations - About 1 hr to fix
    app/javascript/packs/controllers/admin_controller.js on lines 209..215
    app/javascript/packs/controllers/admin_controller.js on lines 225..231

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

    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 3 locations. Consider refactoring.
    Open

        toggleActionDropdownMenu() {
          if (this.actionDropdownMenuTarget.classList.contains('show')) {
            this.actionDropdownMenuTarget.classList.remove('show');
          } else {
            this.actionDropdownMenuTarget.classList.add('show');
    Severity: Major
    Found in app/javascript/packs/controllers/admin_controller.js and 2 other locations - About 1 hr to fix
    app/javascript/packs/controllers/admin_controller.js on lines 217..223
    app/javascript/packs/controllers/admin_controller.js on lines 225..231

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

    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 3 locations. Consider refactoring.
    Open

        toggleDropdownMenu() {
          if (this.dropdownMenuTarget.classList.contains('show')) {
            this.dropdownMenuTarget.classList.remove('show');
          } else {
            this.dropdownMenuTarget.classList.add('show');
    Severity: Major
    Found in app/javascript/packs/controllers/admin_controller.js and 2 other locations - About 1 hr to fix
    app/javascript/packs/controllers/admin_controller.js on lines 209..215
    app/javascript/packs/controllers/admin_controller.js on lines 217..223

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

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

        connectIconPicker() {
            var selector = 'icon-picker';
    
            if (!document.getElementsByClassName(selector)) {
                return false;
    Severity: Minor
    Found in app/javascript/packs/controllers/admin_controller.js - About 1 hr to fix

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

            if (tabName == 'form') {
              this.collectionTabTarget.classList.remove('active');
              this.formTabTarget.classList.add('active');
              this.showTabTarget.classList.remove('active');
            } else if (tabName == 'collection') {
      Severity: Major
      Found in app/javascript/packs/controllers/admin_controller.js and 2 other locations - About 1 hr to fix
      app/javascript/packs/controllers/admin_controller.js on lines 246..254
      app/javascript/packs/controllers/admin_controller.js on lines 250..254

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

      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 3 locations. Consider refactoring.
      Open

            } else if (tabName == 'collection') {
              this.collectionTabTarget.classList.add('active');
              this.formTabTarget.classList.remove('active');
              this.showTabTarget.classList.remove('active');
            } else if (tabName == 'show') {
      Severity: Major
      Found in app/javascript/packs/controllers/admin_controller.js and 2 other locations - About 1 hr to fix
      app/javascript/packs/controllers/admin_controller.js on lines 242..254
      app/javascript/packs/controllers/admin_controller.js on lines 250..254

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

      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 3 locations. Consider refactoring.
      Open

            } else if (tabName == 'show') {
              this.collectionTabTarget.classList.remove('active');
              this.formTabTarget.classList.remove('active');
              this.showTabTarget.classList.add('active');
            }
      Severity: Major
      Found in app/javascript/packs/controllers/admin_controller.js and 2 other locations - About 1 hr to fix
      app/javascript/packs/controllers/admin_controller.js on lines 242..254
      app/javascript/packs/controllers/admin_controller.js on lines 246..254

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

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

          connectSortable(items, context, contextFieldType) {
            const Sortable = require('sortablejs');
            const $ = require('jquery');
      
            Sortable.create(items, {
      Severity: Minor
      Found in app/javascript/packs/controllers/admin_controller.js - About 1 hr to fix

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

          class CreateResource < Base
            ENDPOINT_URL = 'v1/resources'
        
            def call
              uri = URI.parse(endpoint_url)
        Severity: Minor
        Found in app/services/simpleadmin/api/endpoints/v1/create_resource.rb and 1 other location - About 55 mins to fix
        app/services/simpleadmin/api/endpoints/v1/update_resource.rb on lines 4..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 45.

        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

          class UpdateResource < Base
            ENDPOINT_URL = 'v1/resources'
        
            def call
              uri = URI.parse(endpoint_url)
        Severity: Minor
        Found in app/services/simpleadmin/api/endpoints/v1/update_resource.rb and 1 other location - About 55 mins to fix
        app/services/simpleadmin/api/endpoints/v1/create_resource.rb on lines 4..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 45.

        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

              } else {
                blockContent.classList.add('hidden');
        
                iconElement.classList.remove('fa-angle-up');
                iconElement.classList.add('fa-angle-down');
        Severity: Minor
        Found in app/javascript/packs/controllers/admin_controller.js and 1 other location - About 40 mins to fix
        app/javascript/packs/controllers/admin_controller.js on lines 263..268

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

        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 (blockContent.classList.contains('hidden')) {
                blockContent.classList.remove('hidden');
        
                iconElement.classList.remove('fa-angle-down');
                iconElement.classList.add('fa-angle-up');
        Severity: Minor
        Found in app/javascript/packs/controllers/admin_controller.js and 1 other location - About 40 mins to fix
        app/javascript/packs/controllers/admin_controller.js on lines 268..273

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

        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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def initialize(table_name, project_url, encrypted_secret_key, params, url_attribute)
        Severity: Minor
        Found in app/services/simpleadmin/api/endpoints/v1/base.rb - About 35 mins to fix
          Severity
          Category
          Status
          Source
          Language