CartoDB/cartodb20

View on GitHub
lib/assets/javascripts/new-dashboard/store/actions/connector.js

Summary

Maintainability
F
4 days
Test Coverage

File connector.js has 395 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import 'whatwg-fetch';
import { getBaseURL } from 'new-dashboard/utils/base-url';

/*
  DEV CREDENTIALS:
Severity: Minor
Found in lib/assets/javascripts/new-dashboard/store/actions/connector.js - About 5 hrs to fix

    Function getFormData has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function getFormData (user, connector) {
      return JSON.stringify({
        fields: [
          {
            name: 'email',
    Severity: Minor
    Found in lib/assets/javascripts/new-dashboard/store/actions/connector.js - About 1 hr to fix

      Function createNewBQConnectionThroughOAuth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function createNewBQConnectionThroughOAuth (context) {
        if (!context.rootState.user) {
          return;
        }
      
      
      Severity: Minor
      Found in lib/assets/javascripts/new-dashboard/store/actions/connector.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

      Function updateBQConnectionBillingProject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function updateBQConnectionBillingProject (context, { id: bqConnectionId, billing_project }) {
        if (!context.rootState.user) {
          return;
        }
      
      
      Severity: Minor
      Found in lib/assets/javascripts/new-dashboard/store/actions/connector.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

      Function checkBQConnectionThroughOAuth has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function checkBQConnectionThroughOAuth (context) {
        if (!context.rootState.user) {
          return;
        }
      
      
      Severity: Minor
      Found in lib/assets/javascripts/new-dashboard/store/actions/connector.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

      Function createNewBQConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function createNewBQConnection (context, { name, billing_project, default_project, ...payload }) {
        if (!context.rootState.user) {
          return;
        }
      
      
      Severity: Minor
      Found in lib/assets/javascripts/new-dashboard/store/actions/connector.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

      Function editBQConnection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      export async function editBQConnection (context, { bqConnectionId, name, billing_project, default_project, ...payload }) {
        if (!context.rootState.user) {
          return;
        }
      
      
      Severity: Minor
      Found in lib/assets/javascripts/new-dashboard/store/actions/connector.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

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

        if (!response.ok) {
          let data;
          try {
            data = await response.json();
          } catch (e) {
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 279..290
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 311..322
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 369..380
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 399..410

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

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

        if (!response.ok) {
          let data;
          try {
            data = await response.json();
          } catch (e) {
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 279..290
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 311..322
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 338..349
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 399..410

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

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

        if (!response.ok) {
          let data;
          try {
            data = await response.json();
          } catch (e) {
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 279..290
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 311..322
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 338..349
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 369..380

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

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

        if (!response.ok) {
          let data;
          try {
            data = await response.json();
          } catch (e) {
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 311..322
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 338..349
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 369..380
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 399..410

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

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

        if (!response.ok) {
          let data;
          try {
            data = await response.json();
          } catch (e) {
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 279..290
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 338..349
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 369..380
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 399..410

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

      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 response = await fetch(url, { method: 'POST',
          headers: {
            'content-type': 'application/json'
          },
          body: JSON.stringify({ name, connector: 'bigquery', parameters: { billing_project, default_project, service_account: JSON.stringify(payload) } }) });
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 363..367

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

      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 response = await fetch(url, { method: 'PUT',
          headers: {
            'content-type': 'application/json'
          },
          body: JSON.stringify({ name, connector: 'bigquery', parameters: { billing_project, default_project, service_account: JSON.stringify(payload) } }) });
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 273..277

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

      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 (!response.ok) {
          context.commit('setBQDatasets', []);
          throw new Error(JSON.stringify({
            status: response.status,
            message: (await response.json()).errors
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 444..450

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

      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 (!response.ok) {
          context.commit('setProjects', []);
          throw new Error(JSON.stringify({
            status: response.status,
            message: (await response.json()).errors
      lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 466..472

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

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

        return new Promise((resolve, reject) => {
          context.rootState.client.post([CONFIG_PATH], opts, err => {
            if (err) {
              resolve(false);
            } else {
      lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 178..186
      lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 349..357

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

      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

        try {
          const response = await fetch(url);
          return await response.json();
        } catch (error) {
          console.error(`ERROR: ${error}`);
      lib/assets/javascripts/new-dashboard/store/actions/tileset.js on lines 39..44

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

      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

            {
              name: 'company',
              value:
                user.company ||
                (user.organization
      Severity: Minor
      Found in lib/assets/javascripts/new-dashboard/store/actions/connector.js and 1 other location - About 45 mins to fix
      lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 477..484

      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