superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx
Function AdhocFilterEditPopoverSimpleTabContent
has 246 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const AdhocFilterEditPopoverSimpleTabContent: React.FC<Props> = props => {
const {
onSubjectChange,
onOperatorChange,
isOperatorRelevant,
File index.tsx
has 481 lines of code (exceeds 250 allowed). Consider refactoring. Open
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
Open
export const useSimpleTabFilterProps = (props: Props) => {
const defaultTimeFilter = useDefaultTimeFilter();
const isOperatorRelevant = (operator: Operators, subject: string) => {
const column = props.datasource.columns?.find(
- Read upRead up
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
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
Open
const AdhocFilterEditPopoverSimpleTabContent: React.FC<Props> = props => {
const {
onSubjectChange,
onOperatorChange,
isOperatorRelevant,
- Read upRead up
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
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
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
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
Open
return (
props.adhocFilter.clause !== Clauses.Having ||
HAVING_OPERATORS.indexOf(operator) !== -1
);