airbnb/caravel

View on GitHub
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx

Summary

Maintainability
F
4 days
Test Coverage

Function AdhocFilterEditPopoverSimpleTabContent has 244 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AdhocFilterEditPopoverSimpleTabContent: FC<Props> = props => {
  const {
    onSubjectChange,
    onOperatorChange,
    isOperatorRelevant,

    File index.tsx has 479 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 useSimpleTabFilterProps has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

      export const useSimpleTabFilterProps = (props: Props) => {
        const defaultTimeFilter = useDefaultTimeFilter();
      
        const isOperatorRelevant = (operator: Operators, subject: string) => {
          const column = props.datasource.columns?.find(

      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 useSimpleTabFilterProps has 144 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const useSimpleTabFilterProps = (props: Props) => {
        const defaultTimeFilter = useDefaultTimeFilter();
      
        const isOperatorRelevant = (operator: Operators, subject: string) => {
          const column = props.datasource.columns?.find(

        Function AdhocFilterEditPopoverSimpleTabContent has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        const AdhocFilterEditPopoverSimpleTabContent: FC<Props> = props => {
          const {
            onSubjectChange,
            onOperatorChange,
            isOperatorRelevant,

        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 onSubjectChange has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const onSubjectChange = (id: string) => {
            const option = props.options.find(
              option =>
                ('column_name' in option && option.column_name === id) ||
                ('optionName' in option && option.optionName === id),

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

            const onOperatorChange = (operatorId: Operators) => {
              const currentComparator = props.adhocFilter.comparator;
              let newComparator;
              // convert between list of comparators and individual comparators
              // (e.g. `in ('North America', 'Africa')` to `== 'North America'`)

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

                const refreshComparatorSuggestions = () => {
                  const { datasource } = props;
                  const col = props.adhocFilter.subject;
                  const having = props.adhocFilter.clause === Clauses.Having;
            
            

              Avoid too many return statements within this function.
              Open

                  return (
                    props.adhocFilter.clause !== Clauses.Having ||
                    HAVING_OPERATORS.indexOf(operator) !== -1
                  );

                There are no issues that match your filters.

                Category
                Status