isprambiente/medplan

View on GitHub

Showing 69 of 69 total issues

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

            } else {
              container.classList.add('active');
              container.classList.remove('expired');
              return link.closest("td").classList.remove('expired');
            }
Severity: Major
Found in app/javascript/controllers/audits_controller.js and 1 other location - About 1 hr to fix
app/javascript/controllers/audits_controller.js on lines 76..80

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

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

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

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

    const loading = (event) => { event.target.classList.add('is-loading'); document.getElementById('loader').classList.remove('is-hidden')};
    Severity: Major
    Found in app/javascript/loader.js and 1 other location - About 1 hr to fix
    app/javascript/loader.js on lines 2..2

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

    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

    const loaded = (event) => {  event.target.classList.remove('is-loading'); document.getElementById('loader').classList.add('is-hidden') };
    Severity: Major
    Found in app/javascript/loader.js and 1 other location - About 1 hr to fix
    app/javascript/loader.js on lines 1..1

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

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

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

        render turbo_stream: [
          turbo_stream.replace("user_#{@user.id}", partial: 'users/user', locals: {user: @user, current_user: current_user}),
          turbo_stream.replace("user_#{@user.id}_category_#{category.id}", partial: 'audits/category', locals: {user: @user, category: category}),
          turbo_stream.replace(:flashes, partial: "flashes")
        ]
    Severity: Minor
    Found in app/controllers/audits_controller.rb and 1 other location - About 55 mins to fix
    app/controllers/audits_controller.rb on lines 111..116

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

    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

        render turbo_stream: [
          turbo_stream.replace("user_#{@user.id}", partial: 'users/user', locals: {user: @user, current_user: current_user}),
          turbo_stream.replace("user_#{@user.id}_category_#{category.id}", partial: 'audits/category', locals: {user: @user, category: category}),
          turbo_stream.replace(:flashes, partial: "flashes")
        ]
    Severity: Minor
    Found in app/controllers/audits_controller.rb and 1 other location - About 55 mins to fix
    app/controllers/audits_controller.rb on lines 55..60

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

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

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

                  Settings.events.ranges.each do |range|
                    timer += (range.start_time.in_time_zone.to_datetime.to_i .. range.end_time.in_time_zone.to_datetime.to_i).step(range.interval.minutes).map{|t| Time.zone.at(t).strftime('%H:%M') }
                  end
              Severity: Minor
              Found in app/controllers/events_controller.rb and 1 other location - About 30 mins to fix
              app/controllers/events_controller.rb on lines 56..58

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

              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

                  Settings.events.ranges.each do |range|
                    timer += (range.start_time.in_time_zone.to_datetime.to_i .. range.end_time.in_time_zone.to_datetime.to_i).step(range.interval.minutes).map{|t| Time.zone.at(t).strftime('%H:%M') }
                  end
              Severity: Minor
              Found in app/controllers/events_controller.rb and 1 other location - About 30 mins to fix
              app/controllers/events_controller.rb on lines 240..242

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

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

                def create
                  @risk = Risk.new(risk_params)
                  if @risk.save
                    risks
                    flash.now[:success] = 'Creazione avvenuta con successo'
              Severity: Minor
              Found in app/controllers/risks_controller.rb and 1 other location - About 30 mins to fix
              app/controllers/categories_controller.rb on lines 49..58

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

              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

              Severity
              Category
              Status
              Source
              Language