cantino/huginn

View on GitHub
app/assets/javascripts/pages/agent-edit-page.js

Summary

Maintainability
D
2 days
Test Coverage

File agent-edit-page.js has 295 lines of code (exceeds 250 allowed). Consider refactoring.
Open

(function () {
  let formatAgentForSelect = undefined;
  const Cls = (this.AgentEditPage = class AgentEditPage {
    static initClass() {
      formatAgentForSelect = function (agent) {
Severity: Minor
Found in app/assets/javascripts/pages/agent-edit-page.js - About 3 hrs to fix

    Function constructor has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        constructor() {
          this.invokeDryRun = this.invokeDryRun.bind(this);
          $("#agent_source_ids").on("change", this.showEventDescriptions);
          this.showCorrectRegionsOnStartup();
          $("form.agent-form").on("submit", () => this.updateFromEditors());
    Severity: Major
    Found in app/assets/javascripts/pages/agent-edit-page.js - About 2 hrs to fix

      Function handleTypeChange has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          handleTypeChange(firstTime) {
            $(".event-descriptions").html("").hide();
            const type = $("#agent_type").val();
      
            if (type === "Agent") {
      Severity: Major
      Found in app/assets/javascripts/pages/agent-edit-page.js - About 2 hrs to fix

        Function buildAce has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            buildAce() {
              return $(".ace-editor").each(function () {
                if (!$(this).data("initialized")) {
                  const $this = $(this);
                  $this.data("initialized", true);
        Severity: Minor
        Found in app/assets/javascripts/pages/agent-edit-page.js - About 1 hr to fix

          Function showCorrectRegionsOnStartup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              showCorrectRegionsOnStartup() {
                if ($(".schedule-region")) {
                  if ($(".schedule-region").data("can-be-scheduled") === true) {
                    this.showSchedule();
                  } else {
          Severity: Minor
          Found in app/assets/javascripts/pages/agent-edit-page.js - About 1 hr to fix

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

                  if ($(".control-link-region")) {
                    if (
                      $(".control-link-region").data("can-control-other-agents") === true
                    ) {
                      this.showControlLinks();
            Severity: Major
            Found in app/assets/javascripts/pages/agent-edit-page.js and 2 other locations - About 1 hr to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 234..240
            app/assets/javascripts/pages/agent-edit-page.js on lines 242..248

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

                  if ($(".schedule-region")) {
                    if ($(".schedule-region").data("can-be-scheduled") === true) {
                      this.showSchedule();
                    } else {
                      this.hideSchedule();
            Severity: Major
            Found in app/assets/javascripts/pages/agent-edit-page.js and 2 other locations - About 1 hr to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 242..248
            app/assets/javascripts/pages/agent-edit-page.js on lines 250..258

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

                  if ($(".link-region")) {
                    if ($(".link-region").data("can-receive-events") === true) {
                      this.showLinks();
                    } else {
                      this.hideLinks();
            Severity: Major
            Found in app/assets/javascripts/pages/agent-edit-page.js and 2 other locations - About 1 hr to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 234..240
            app/assets/javascripts/pages/agent-edit-page.js on lines 250..258

            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

                hideEventCreation() {
                  $(".event-related-region .select2-container").hide();
                  $(".event-related-region .cannot-create-events").show();
                  return $(".event-related-region").data("can-create-events", false);
                }
            Severity: Minor
            Found in app/assets/javascripts/pages/agent-edit-page.js and 1 other location - About 50 mins to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 207..211

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

            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

                showEventCreation() {
                  $(".event-related-region .select2-container").show();
                  $(".event-related-region .cannot-create-events").hide();
                  return $(".event-related-region").data("can-create-events", true);
                }
            Severity: Minor
            Found in app/assets/javascripts/pages/agent-edit-page.js and 1 other location - About 50 mins to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 201..205

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

            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 (
                      $(".link-region").length &&
                      $(".link-region").data("can-receive-events") === false
                    ) {
                      $(".link-region .select2-linked-tags option:selected").removeAttr(
            Severity: Minor
            Found in app/assets/javascripts/pages/agent-edit-page.js and 1 other location - About 45 mins to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 40..47

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

            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 (
                      $(".control-link-region").length &&
                      $(".control-link-region").data("can-control-other-agents") === false
                    ) {
                      $(
            Severity: Minor
            Found in app/assets/javascripts/pages/agent-edit-page.js and 1 other location - About 45 mins to fix
            app/assets/javascripts/pages/agent-edit-page.js on lines 31..38

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

            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

            There are no issues that match your filters.

            Category
            Status