airbnb/superset

View on GitHub
superset-frontend/src/SqlLab/actions/sqlLab.js

Summary

Maintainability
F
6 days
Test Coverage

File sqlLab.js has 1194 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
Severity: Major
Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 3 days to fix

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

    export function switchQueryEditor(queryEditor, displayLimit) {
      return function (dispatch) {
        if (
          isFeatureEnabled(FeatureFlag.SqllabBackendPersistence) &&
          queryEditor &&
    Severity: Minor
    Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

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

      export function runQuery(query) {
        return function (dispatch) {
          dispatch(startQuery(query));
          const postPayload = {
            client_id: query.id,
      Severity: Minor
      Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

        Function migrateQueryEditorFromLocalStorage has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function migrateQueryEditorFromLocalStorage(
          queryEditor,
          tables,
          queries,
        ) {
        Severity: Minor
        Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

          Function addNewQueryEditor has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function addNewQueryEditor() {
            return function (dispatch, getState) {
              const {
                sqlLab: { queryEditors, tabHistory, unsavedQueryEditor, databases },
                common,
          Severity: Minor
          Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

            Function runTablePreviewQuery has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function runTablePreviewQuery(newTable) {
              return function (dispatch, getState) {
                const {
                  sqlLab: { databases },
                } = getState();
            Severity: Minor
            Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

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

              export function estimateQueryCost(queryEditor) {
                return (dispatch, getState) => {
                  const { dbId, schema, sql, selectedText, templateParams } =
                    getUpToDateQuery(getState(), queryEditor);
                  const requestSql = selectedText || sql;
              Severity: Minor
              Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

                Function syncTable has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function syncTable(table, tableMetadata) {
                  return function (dispatch) {
                    const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
                      ? SupersetClient.post({
                          endpoint: encodeURI('/tableschemaview/'),
                Severity: Minor
                Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

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

                  export function createDatasource(vizOptions) {
                    return dispatch => {
                      dispatch(createDatasourceStarted());
                      const { dbId, schema, datasourceName, sql } = vizOptions;
                      return SupersetClient.post({
                  Severity: Minor
                  Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

                    Function addQueryEditor has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function addQueryEditor(queryEditor) {
                      return function (dispatch) {
                        const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
                          ? SupersetClient.post({
                              endpoint: '/tabstateview/',
                    Severity: Minor
                    Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

                      Function setTables has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      export function setTables(tableSchemas) {
                        const tables = tableSchemas
                          .filter(tableSchema => tableSchema.description !== null)
                          .map(tableSchema => {
                            const {
                      Severity: Minor
                      Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

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

                        export function removeTables(tables) {
                          return function (dispatch) {
                            const tablesToRemove = tables?.filter(Boolean) ?? [];
                            const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
                              ? Promise.all(
                        Severity: Minor
                        Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 1 hr to fix

                          Function runQueryFromSqlEditor has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            database,
                            queryEditor,
                            defaultQueryLimit,
                            tempTable,
                            ctas,
                          Severity: Minor
                          Found in superset-frontend/src/SqlLab/actions/sqlLab.js - About 45 mins to fix

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

                            export function collapseTable(table) {
                              return function (dispatch) {
                                const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
                                  ? SupersetClient.post({
                                      endpoint: encodeURI(`/tableschemaview/${table.id}/expanded`),
                            Severity: Major
                            Found in superset-frontend/src/SqlLab/actions/sqlLab.js and 1 other location - About 5 hrs to fix
                            superset-frontend/src/SqlLab/actions/sqlLab.js on lines 1080..1102

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

                            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 function expandTable(table) {
                              return function (dispatch) {
                                const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
                                  ? SupersetClient.post({
                                      endpoint: encodeURI(`/tableschemaview/${table.id}/expanded`),
                            Severity: Major
                            Found in superset-frontend/src/SqlLab/actions/sqlLab.js and 1 other location - About 5 hrs to fix
                            superset-frontend/src/SqlLab/actions/sqlLab.js on lines 1104..1126

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

                            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 sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
                                  ? SupersetClient.delete({
                                      endpoint: encodeURI(`/tabstateview/${queryEditor.id}`),
                                    })
                                  : Promise.resolve();
                            Severity: Major
                            Found in superset-frontend/src/SqlLab/actions/sqlLab.js and 1 other location - About 1 hr to fix
                            superset-frontend/src/SqlLab/actions/sqlLab.js on lines 616..620

                            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

                                const sync = isFeatureEnabled(FeatureFlag.SqllabBackendPersistence)
                                  ? SupersetClient.post({
                                      endpoint: encodeURI(`/tabstateview/${queryEditor.id}/activate`),
                                    })
                                  : Promise.resolve();
                            Severity: Major
                            Found in superset-frontend/src/SqlLab/actions/sqlLab.js and 1 other location - About 1 hr to fix
                            superset-frontend/src/SqlLab/actions/sqlLab.js on lines 738..742

                            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

                            There are no issues that match your filters.

                            Category
                            Status