airbnb/caravel

View on GitHub

Showing 2,441 of 6,157 total issues

Function fetchExploreData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

const fetchExploreData = async (exploreUrlParams: URLSearchParams) => {
  try {
    const rv = await makeApi<{}, ExploreResponsePayload>({
      method: 'GET',
      endpoint: 'api/v1/explore/',
Severity: Minor
Found in superset-frontend/src/pages/Chart/index.tsx - About 45 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 DashboardEmbedControls has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const DashboardEmbedControls = ({ dashboardId, onHide }: Props) => {
  const { addInfoToast, addDangerToast } = useToasts();
  const [ready, setReady] = useState(true); // whether we have initialized yet
  const [loading, setLoading] = useState(false); // whether we are currently doing an async thing
  const [embedded, setEmbedded] = useState<EmbeddedDashboard | null>(null); // the embedded dashboard config
Severity: Minor
Found in superset-frontend/src/dashboard/components/EmbeddedModal/index.tsx - About 45 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 render has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const { contentWidth, contentHeight, width, height, renderContent } =
      this.props;

    const overflowX = checkNumber(contentWidth) && contentWidth > width;

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 constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  constructor(config: ChartPluginConfig<FormData, Props>) {
    super();
    const {
      metadata,
      buildQuery,

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 SafeMarkdown has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

function SafeMarkdown({
  source,
  htmlSanitization = true,
  htmlSchemaOverrides = {},
}: SafeMarkdownProps) {

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

Avoid deeply nested control flow statements.
Open

            if (valueString !== undefined) {
              formData.append(key, valueString);
            }

    Function normalizeOrderBy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export default function normalizeOrderBy(
      queryObject: QueryObject,
    ): QueryObject {
      if (Array.isArray(queryObject.orderby) && queryObject.orderby.length > 0) {
        // ensure a valid orderby clause

    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 getColor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      getColor(value?: string, sliceId?: number, colorScheme?: string): string {
        const cleanedValue = stringifyAndTrim(value);
        // priority: forced color (i.e. custom label colors) > shared color > scale color
        const forcedColor = this.forcedColors?.[cleanedValue];
        const isExistingLabel = this.chartLabelsColorMap.has(cleanedValue);

    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 getColorFormatters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      (
        columnConfig: ConditionalFormattingConfig[] | undefined,
        data: DataRecord[],
        alpha?: boolean,
      ) =>

    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 getColorFunction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    export const getColorFunction = (
      {
        operator,
        targetValue,
        targetValueLeft,

    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

    Consider simplifying this complex logical expression.
    Open

            if (
              !state.queries.hasOwnProperty(id) ||
              (state.queries[id].state !== QueryState.Stopped &&
                state.queries[id].state !== QueryState.Failed)
            ) {
    Severity: Major
    Found in superset-frontend/src/SqlLab/reducers/sqlLab.js - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

                if (
                  unsavedQueryEditors.length > 0 ||
                  hasUnsavedActiveTabState ||
                  hasUnsavedDeletedQueryEditors
                ) {
      Severity: Major
      Found in superset-frontend/src/SqlLab/middlewares/persistSqlLabStateEnhancer.js - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                    if (
                      !hasWarned &&
                      isParentProperty &&
                      value &&
                      (hasLiteralColor(value, true) ||
        Severity: Major
        Found in superset-frontend/tools/eslint-plugin-theme-colors/index.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                if (totalRecord[key] !== undefined && !key.includes(comparisonSuffix)) {
                  transformedTotals[`Main ${key}`] =
                    parseInt(transformedTotals[`Main ${key}`]?.toString() || '0', 10) +
                    parseInt(totalRecord[key]?.toString() || '0', 10);
                  transformedTotals[`# ${key}`] =
          Severity: Major
          Found in superset-frontend/plugins/plugin-chart-table/src/transformProps.ts - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                  if (onContextMenu) {
                    eventParams.event.stop();
                    const { data, seriesName, seriesIndex } = eventParams;
                    const pointerEvent = eventParams.event.event;
                    const drillToDetailFilters: BinaryQueryObjectFilterClause[] = [];

              Consider simplifying this complex logical expression.
              Open

                  } else if (!isEmpty(shift) || startDateOffset) {
                    const promise: any = fetchTimeRange(
                      dashboardTimeRange ?? (currentTimeRangeFilter as any).comparator,
                      currentTimeRangeFilter.subject,
                    );

                Consider simplifying this complex logical expression.
                Open

                    if (
                      labelNameElement &&
                      labelsColorElement &&
                      (labelNameElement.scrollWidth > labelNameElement.offsetWidth ||
                        labelNameElement.scrollHeight > labelNameElement.offsetHeight ||

                  Consider simplifying this complex logical expression.
                  Open

                      if (activeTab && activeTab.id === id) {
                        queryEditor = {
                          version: activeTab.extra_json?.version ?? QueryEditorVersion.V1,
                          id: id.toString(),
                          loaded: true,
                  Severity: Major
                  Found in superset-frontend/src/SqlLab/reducers/getInitialState.ts - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                        if (
                          isEditMode &&
                          (!currentCssTemplate?.id ||
                            (cssTemplate && cssTemplate?.id !== currentCssTemplate.id) ||
                            (isHidden && show))
                    Severity: Major
                    Found in superset-frontend/src/features/cssTemplates/CssTemplateModal.tsx - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                        if (
                          fileList.length > 0 &&
                          (alreadyExists.length ||
                            passwordFields.length ||
                            sshTunnelPasswordFields.length ||
                      Severity: Major
                      Found in superset-frontend/src/features/databases/DatabaseModal/index.tsx - About 40 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language