CartoDB/cartodb20

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

Summary

Maintainability
F
1 wk
Test Coverage

File catalog.js has 454 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import 'whatwg-fetch';

import { setUrlParameters } from 'new-dashboard/utils/catalog/url-parameters';
import { getBaseURL } from 'new-dashboard/utils/catalog/base-url';
import { getMetricsBaseURL } from '../../utils/catalog/base-url';
Severity: Minor
Found in lib/assets/javascripts/new-dashboard/store/actions/catalog.js - About 6 hrs to fix

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

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

      Function initFilter has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function initFilter (context, query) {
        const filter = {
          searchText: '',
          limit: process.env.VUE_APP_PAGE_SIZE || 10,
          page: 0,
      Severity: Minor
      Found in lib/assets/javascripts/new-dashboard/store/actions/catalog.js - About 1 hr to fix

        Function prepareDatasetToHubspot has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function prepareDatasetToHubspot (dataset) {
          return [
            {
              name: 'country_data',
              value: dataset.country_name || ''
        Severity: Minor
        Found in lib/assets/javascripts/new-dashboard/store/actions/catalog.js - About 1 hr to fix

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

          export async function performSubscribe (context, { id, type }) {
            if (!context.rootState.user) {
              return;
            }
            const baseURL = getBaseURL(context.rootState);
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 253..267

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

          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

          export async function performUnsubscribe (context, { id, type }) {
            if (!context.rootState.user) {
              return;
            }
            const baseURL = getBaseURL(context.rootState);
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 237..251

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

          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

          export async function fetchKeyVariables (context, { id, type }) {
            const baseURL = getBaseURL(context.rootState);
            const endpoint = type === 'dataset' ? datasetsEndpoint : geographiesEndpoint;
            const url = `${baseURL}/${endpoint}/${id}/key_variables`;
          
          
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 110..122

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

          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

          export async function fetchVariables (context, { id, type }) {
            const baseURL = getBaseURL(context.rootState);
            const endpoint = type === 'dataset' ? datasetsEndpoint : geographiesEndpoint;
            const url = `${baseURL}/${endpoint}/${id}/variables?minimal=true`;
          
          
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 96..108

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

          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

          export async function performSubscriptionSync (context, id) {
            if (!context.rootState.user) {
              return;
            }
            const baseURL = getBaseURL(context.rootState);
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 285..299
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 301..315

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

          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

          export async function performSubscriptionUnsync (context, id) {
            if (!context.rootState.user) {
              return;
            }
            const baseURL = getBaseURL(context.rootState);
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 269..283
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 301..315

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

          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

          export async function connectSubscriptionSample (context, id) {
            if (!context.rootState.user) {
              return;
            }
            const baseURL = getBaseURL(context.rootState);
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 269..283
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 285..299

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

          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 349..357
          lib/assets/javascripts/new-dashboard/store/actions/connector.js on lines 204..212

          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 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/connector.js on lines 204..212

          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

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

          export async function sendAccessAttemptMetrics (context, { datasetId, platform, licenseType }) {
            sendMetrics(context, { name: 'do_full_access_attempt', datasetId, platform, licenseType });
          }
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 393..395

          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

          export async function sendRequestAccessMetrics (context, { datasetId, platform, licenseType }) {
            sendMetrics(context, { name: 'do_full_access_request', datasetId, platform, licenseType });
          }
          lib/assets/javascripts/new-dashboard/store/actions/catalog.js on lines 385..387

          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

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

          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