isprambiente/Domando

View on GitHub

Showing 18 of 18 total issues

Function send has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  send(body = '') {
    var options, position, width;
    width = this.element.dataset.modalSize || '90%';
    position = this.element.dataset.modalPosition || 'top';
    options = {
Severity: Minor
Found in app/javascript/controllers/modal_controller.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

    window.addEventListener("click",function(t){if("click->menu#open"!=t.target.getAttribute("data-action")&&"click->section#colShow"!=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: Critical
    Found in app/javascript/controllers/application.js - About 1 hr to fix

      Function slimSelect has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        slimSelect(select) {
          if (select.dataset.formAddable === 'true') {
            return new SlimSelect({
              addToBody: true,
              select: `#${select.id}`,
      Severity: Minor
      Found in app/javascript/controllers/form_controller.js - About 1 hr to fix

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

              if (tags[tags.length - 1].dataset.type === 'reset') {
                return tags[tags.length - 1].classList.remove('is-hidden');
              }
        Severity: Major
        Found in app/javascript/controllers/form_controller.js and 1 other location - About 1 hr to fix
        app/javascript/controllers/form_controller.js on lines 68..70

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

        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 (tags[tags.length - 1].dataset.type === 'reset') {
              return tags[tags.length - 1].classList.add('is-hidden');
            }
        Severity: Major
        Found in app/javascript/controllers/form_controller.js and 1 other location - About 1 hr to fix
        app/javascript/controllers/form_controller.js on lines 55..57

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

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

          def propose_send
            @author = propose_params[:author_id].present? ? User.find(propose_params[:author_id]) : ''
            if @author.present? && propose_params[:title].present?
              UserMailer.with(author: @author, propose: propose_params).propose_email.deliver_now
              User.admins.map { |u| FaqMailer.with(user: u, author: @author, propose: propose_params).propose_email.deliver_now }
        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

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

            if @user.destroy
              flash.now[:success] = 'Cancellazione avvenuta con successo'
              render turbo_stream: [
                  turbo_stream.remove("user_#{@user.id}"),
                  turbo_stream.replace(:flashes, partial: "flashes")
        Severity: Minor
        Found in app/controllers/users_controller.rb and 1 other location - About 45 mins to fix
        app/controllers/faqs_controller.rb on lines 60..69

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

        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 @faq.destroy
              flash.now[:success] = 'Cancellazione avvenuta con successo'
              render turbo_stream: [
                  turbo_stream.remove("faq_#{@faq.id}"),
                  turbo_stream.replace(:flashes, partial: "flashes")
        Severity: Minor
        Found in app/controllers/faqs_controller.rb and 1 other location - About 45 mins to fix
        app/controllers/users_controller.rb on lines 134..143

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

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

          slimSelect(select) {
            if (select.dataset.formAddable === 'true') {
              return new SlimSelect({
                addToBody: true,
                select: `#${select.id}`,
        Severity: Minor
        Found in app/javascript/controllers/form_controller.js - 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

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

          def perform(username: '')
            return if Rails.env.test?
        
            users = User.all.order(label: :asc)
            users = users.where(username: username) if username.present?
        Severity: Minor
        Found in app/jobs/users_check_job.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 list has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def list
            @filters = filter_params
            @page = params[:page] || 1
            faqs = Faq.accessible_by(current_ability).actived.approved
            @evidences = faqs.evidenced.limit(Settings.faq.max_faqs_in_evidence)
        Severity: Minor
        Found in app/controllers/home_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

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

              flash.now[:success] = 'Disattivazione avvenuta con successo'
              render turbo_stream: [
                  turbo_stream.replace("user_#{@user.id}", partial: 'users/user', locals: {user: @user, current_user: current_user}),
                  turbo_stream.replace(:flashes, partial: "flashes")
                ]
        Severity: Minor
        Found in app/controllers/users_controller.rb and 1 other location - About 25 mins to fix
        app/controllers/users_controller.rb on lines 115..120

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

        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

              flash.now[:success] = 'Riattivazione avvenuta con successo'
              render turbo_stream: [
                turbo_stream.replace("user_#{@user.id}", partial: 'users/user', locals: {user: @user, current_user: current_user}),
                turbo_stream.replace(:flashes, partial: "flashes")
              ]
        Severity: Minor
        Found in app/controllers/users_controller.rb and 1 other location - About 25 mins to fix
        app/controllers/users_controller.rb on lines 96..101

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

        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 6 (exceeds 5 allowed). Consider refactoring.
        Open

          send(message, level = 'success', 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 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

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

          def update
            if @faq.update(faq_params)
              flash.now[:success] = 'Modifica avvenuta con successo'
            else
              flash.now[:error] = write_errors(@faq)
        Severity: Minor
        Found in app/controllers/faqs_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/users_controller.rb on lines 79..86

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

        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

          def update
            if @user.update(user_params)
              flash.now[:success] = 'Modifica avvenuta con successo'
            else
              flash.now[:error] = write_errors(@user)
        Severity: Minor
        Found in app/controllers/users_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/faqs_controller.rb on lines 49..56

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

        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(:flashes, partial: "flashes"),
              turbo_stream.replace("faq_#{@faq.id}", partial: "home/faq", locals: {faq: @faq, user_faq_ids: @user_faq_ids})
            ]
          end
        Severity: Minor
        Found in app/controllers/home_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/home_controller.rb on lines 122..126

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

        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(:flashes, partial: "flashes"),
              turbo_stream.replace("faq_#{@faq.id}", partial: "home/faq", locals: {faq: @faq, user_faq_ids: @user_faq_ids})
            ]
          end
        Severity: Minor
        Found in app/controllers/home_controller.rb and 1 other location - About 15 mins to fix
        app/controllers/home_controller.rb on lines 105..109

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

        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