File sqlLab.js
has 1192 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
Function syncQueryEditor
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function syncQueryEditor(queryEditor) {
return function (dispatch, getState) {
const { tables, queries } = getState().sqlLab;
const localStorageTables = tables.filter(
table => table.inLocalStorage && table.queryEditorId === queryEditor.id,
Function runQuery
has 45 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,
Function runTablePreviewQuery
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function runTablePreviewQuery(newTable) {
return function (dispatch, getState) {
const {
sqlLab: { databases },
} = getState();
Function addNewQueryEditor
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function addNewQueryEditor() {
return function (dispatch, getState) {
const {
sqlLab: { queryEditors, tabHistory, unsavedQueryEditor, databases },
common,
Function estimateQueryCost
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function estimateQueryCost(queryEditor) {
return (dispatch, getState) => {
const { dbId, catalog, schema, sql, selectedText, templateParams } =
getUpToDateQuery(getState(), queryEditor);
const requestSql = selectedText || sql;
Function fetchQueryEditor
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fetchQueryEditor(queryEditor, displayLimit) {
return function (dispatch) {
SupersetClient.get({
endpoint: encodeURI(`/tabstateview/${queryEditor.id}`),
})
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/'),
Function createDatasource
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function createDatasource(vizOptions) {
return dispatch => {
dispatch(createDatasourceStarted());
const { dbId, catalog, schema, datasourceName, sql } = vizOptions;
return SupersetClient.post({
Function setTables
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function setTables(tableSchemas) {
const tables = tableSchemas
.filter(tableSchema => tableSchema.description !== null)
.map(tableSchema => {
const {
Function fetchQueryResults
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function fetchQueryResults(query, displayLimit, timeoutInMs) {
return function (dispatch, getState) {
const { SQLLAB_QUERY_RESULT_TIMEOUT } = getState().common?.conf ?? {};
dispatch(requestQueryResults(query));
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(
Function runQueryFromSqlEditor
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
database,
queryEditor,
defaultQueryLimit,
tempTable,
ctas,
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`),
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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`),
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
{
id: newTable.id,
dbId: newTable.dbId,
catalog: newTable.catalog,
schema: newTable.schema,
- Read upRead up
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 65.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76