Re-enable rule no-else-return (#10861)

This commit is contained in:
Kamil Gabryjelski
2020-09-14 22:00:07 +02:00
committed by GitHub
parent 76275ec410
commit 2d8f4e3aaf
31 changed files with 135 additions and 70 deletions

View File

@@ -60,7 +60,8 @@ function translateToSql(adhocMetric, { useSimple } = {}) {
return `${subject} ${operator} ${isMulti ? "('" : ''}${comparator}${
isMulti ? "')" : ''
}`;
} else if (adhocMetric.expressionType === EXPRESSION_TYPES.SQL) {
}
if (adhocMetric.expressionType === EXPRESSION_TYPES.SQL) {
return adhocMetric.sqlExpression;
}
return '';

View File

@@ -95,7 +95,8 @@ export default class AdhocMetric {
return `${this.aggregate || ''}(${
(this.column && this.column.column_name) || ''
})`;
} else if (this.expressionType === EXPRESSION_TYPES.SQL) {
}
if (this.expressionType === EXPRESSION_TYPES.SQL) {
return this.sqlExpression;
}
return '';
@@ -125,7 +126,8 @@ export default class AdhocMetric {
isValid() {
if (this.expressionType === EXPRESSION_TYPES.SIMPLE) {
return !!(this.column && this.aggregate);
} else if (this.expressionType === EXPRESSION_TYPES.SQL) {
}
if (this.expressionType === EXPRESSION_TYPES.SQL) {
return !!this.sqlExpression;
}
return false;

View File

@@ -60,11 +60,14 @@ const defaultProps = {
function translateOperator(operator) {
if (operator === OPERATORS['==']) {
return 'equals';
} else if (operator === OPERATORS['!=']) {
}
if (operator === OPERATORS['!=']) {
return 'not equal to';
} else if (operator === OPERATORS.LIKE) {
}
if (operator === OPERATORS.LIKE) {
return 'like';
} else if (operator === OPERATORS['LATEST PARTITION']) {
}
if (operator === OPERATORS['LATEST PARTITION']) {
return 'use latest_partition template';
}
return operator;

View File

@@ -142,10 +142,12 @@ class ControlPanelsContainer extends React.Component {
if (!controlItem) {
// When the item is invalid
return null;
} else if (React.isValidElement(controlItem)) {
}
if (React.isValidElement(controlItem)) {
// When the item is a React element
return controlItem;
} else if (controlItem.name && controlItem.config) {
}
if (controlItem.name && controlItem.config) {
return this.renderControl(controlItem);
}
return null;

View File

@@ -133,9 +133,11 @@ export class DisplayQueryButton extends React.PureComponent {
renderQueryModalBody() {
if (this.state.isLoading) {
return <Loading />;
} else if (this.state.error) {
}
if (this.state.error) {
return <pre>{this.state.error}</pre>;
} else if (this.state.query) {
}
if (this.state.query) {
return (
<div>
<CopyToClipboard
@@ -158,9 +160,11 @@ export class DisplayQueryButton extends React.PureComponent {
renderResultsModalBody() {
if (this.state.isLoading) {
return <Loading />;
} else if (this.state.error) {
}
if (this.state.error) {
return <pre>{this.state.error}</pre>;
} else if (this.state.data) {
}
if (this.state.data) {
if (this.state.data.length === 0) {
return 'No data';
}
@@ -212,9 +216,11 @@ export class DisplayQueryButton extends React.PureComponent {
renderSamplesModalBody() {
if (this.state.isLoading) {
return <Loading />;
} else if (this.state.error) {
}
if (this.state.error) {
return <pre>{this.state.error}</pre>;
} else if (this.state.data) {
}
if (this.state.data) {
return this.renderDataTable(this.state.data);
}
return null;

View File

@@ -40,9 +40,11 @@ export default function FilterDefinitionOption({ option }) {
<span className="option-label">{option.saved_metric_name}</span>
</div>
);
} else if (option.column_name) {
}
if (option.column_name) {
return <ColumnOption column={option} showType />;
} else if (option.label) {
}
if (option.label) {
return <AdhocMetricStaticOption adhocMetric={option} showType />;
}
}

View File

@@ -38,9 +38,11 @@ const propTypes = {
function MetricDefinitionOption({ option, addWarningToast }) {
if (option.metric_name) {
return <MetricOption metric={option} showType />;
} else if (option.column_name) {
}
if (option.column_name) {
return <ColumnOption column={option} showType />;
} else if (option.aggregate_name) {
}
if (option.aggregate_name) {
return <AggregateOption aggregate={option} showType />;
}
addWarningToast(

View File

@@ -107,26 +107,32 @@ function getDefaultAggregateForColumn(column) {
const { type } = column;
if (typeof type !== 'string') {
return AGGREGATES.COUNT;
} else if (type === '' || type === 'expression') {
}
if (type === '' || type === 'expression') {
return AGGREGATES.SUM;
} else if (
}
if (
type.match(/.*char.*/i) ||
type.match(/string.*/i) ||
type.match(/.*text.*/i)
) {
return AGGREGATES.COUNT_DISTINCT;
} else if (
}
if (
type.match(/.*int.*/i) ||
type === 'LONG' ||
type === 'DOUBLE' ||
type === 'FLOAT'
) {
return AGGREGATES.SUM;
} else if (type.match(/.*bool.*/i)) {
}
if (type.match(/.*bool.*/i)) {
return AGGREGATES.MAX;
} else if (type.match(/.*time.*/i)) {
}
if (type.match(/.*time.*/i)) {
return AGGREGATES.COUNT;
} else if (type.match(/unknown/i)) {
}
if (type.match(/unknown/i)) {
return AGGREGATES.COUNT;
}
return null;

View File

@@ -119,9 +119,11 @@ export default class SpatialControl extends React.Component {
}
if (this.state.type === spatialTypes.latlong) {
return `${this.state.lonCol} | ${this.state.latCol}`;
} else if (this.state.type === spatialTypes.delimited) {
}
if (this.state.type === spatialTypes.delimited) {
return `${this.state.lonlatCol}`;
} else if (this.state.type === spatialTypes.geohash) {
}
if (this.state.type === spatialTypes.geohash) {
return `${this.state.geohashCol}`;
}
return null;

View File

@@ -100,7 +100,8 @@ function handleMissingChoice(control) {
if (control.multi && value.length > 0) {
alteredControl.value = value.filter(el => choiceValues.indexOf(el) > -1);
return alteredControl;
} else if (!control.multi && choiceValues.indexOf(value) < 0) {
}
if (!control.multi && choiceValues.indexOf(value) < 0) {
alteredControl.value = null;
return alteredControl;
}