isprambiente/medplan

View on GitHub

Showing 33 of 69 total issues

Consider simplifying this complex logical expression.
Open

window.addEventListener("click",function(t){if("click->menu#open"!=t.target.getAttribute("data-action")){const e=document.querySelector("#cart_col.quickview"),c=document.querySelector("#filters_col.quickview"),mm=document.querySelector("#menu_col.quickview");null==mm||mm.contains(t.target)||mm.classList.remove("is-active"),null==e||e.contains(t.target)||e.classList.remove("is-active"),null==c||c.contains(t.target)||c.classList.remove("is-active")}t.stopPropagation()});
Severity: Major
Found in app/javascript/controllers/application.js - About 1 hr to fix

    Function send has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      send(message, level = 'success', force = false, timeout = 2000, toast = true) {
        var options;
        options = {
          toast: level === 'error' ? false : toast,
          icon: level,
    Severity: Minor
    Found in app/javascript/controllers/users_controller.js - About 55 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 send has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      send(message, level = 'success', force = false, timeout = 2000, toast = true) {
        var options;
        options = {
          toast: level === 'error' ? false : toast,
          icon: level,
    Severity: Minor
    Found in app/javascript/controllers/audits_controller.js - About 55 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 send has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      send(message, level = 'success', force = false, timeout = 2000, toast = true) {
        var options;
        options = {
          toast: level === 'error' ? false : toast,
          icon: level,
    Severity: Minor
    Found in app/javascript/controllers/message_controller.js - About 55 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

    Method users has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def users
        @filters = filter_params
        selected = {}
        selected[:city] = @filters[:city] if @filters[:city].present?
        selected[:postazione] = @filters[:postazione] if @filters[:postazione].present?
    Severity: Minor
    Found in app/controllers/home_controller.rb - About 55 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

    Method perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def perform(*)
        url = Rails.application.credentials.api[:url] || Settings.api.url.to_s
    
        json_parsed = JSON.parse(URI.open(
          URI.parse(url),
    Severity: Minor
    Found in app/jobs/users_checknew_job.rb - 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

    Avoid deeply nested control flow statements.
    Open

                if (icon) {
                  icon.classList.add('fa-circle-minus');
                  icon.classList.remove('fa-circle-plus');
                }
    Severity: Major
    Found in app/javascript/controllers/form_controller.js - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if (option.indexOf("||") >= 0) {
                    option_splitted = option.split("||");
                    opt.value = option_splitted[0];
                    opt.text = option_splitted[1];
                  } else {
      Severity: Major
      Found in app/javascript/controllers/users_controller.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                    if (target.dataset.fieldValue === "") {
                      opt.selected = true;
                    }
        Severity: Major
        Found in app/javascript/controllers/users_controller.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if (icon) {
                        icon.classList.add('fa-circle-plus');
                        icon.classList.remove('fa-circle-minus');
                      }
          Severity: Major
          Found in app/javascript/controllers/form_controller.js - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                        if (option === target.dataset.fieldValue) {
                          opt.selected = true;
                        }
            Severity: Major
            Found in app/javascript/controllers/users_controller.js - About 45 mins to fix

              Method reserve has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def reserve
                  @template = params[:template].presence || 'user'
                  @event.user = @user
                  old_status = @event.status(@user)
                  @result = @event.update_status! if current_user.secretary? || (current_user == @user && @event.status(@user) == 'proposed')
              Severity: Minor
              Found in app/controllers/events_controller.rb - About 35 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

              Method users has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def users
                  @text = ['label ilike ?', "%#{filter_params[:text]}%"] if filter_params[:text].present?
                  search = {}
                  search[:city] = filter_params[:city] if filter_params[:city].present?
                  search[:categories] = { id: filter_params[:category] } if filter_params[:category].present?
              Severity: Minor
              Found in app/controllers/users_controller.rb - 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