Showing 2,441 of 6,157 total issues
Function getSimpleSQLExpression
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const getSimpleSQLExpression = (subject, operator, comparator) => {
const isMulti =
[...MULTI_OPERATORS]
.map(op => OPERATOR_ENUM_TO_OPERATOR_TYPE[op].operation)
.indexOf(operator) >= 0;
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
const { theme } = this.props;
return (
<div className="metrics-select" data-test="adhoc-filter-control">
<HeaderContainer>
Function fetchQueryResults
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function fetchQueryResults(query, displayLimit, timeoutInMs) {
return function (dispatch, getState) {
const { SQLLAB_QUERY_RESULT_TIMEOUT } = getState().common?.conf ?? {};
dispatch(requestQueryResults(query));
Function renderSpatialTab
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
renderSpatialTab() {
const { datasource } = this.state;
const { spatials, all_cols: allCols } = datasource;
return (
<Tabs.TabPane
Function renderSparklineCell
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const renderSparklineCell = (valueField, column, entries) => {
let sparkData;
if (column.timeRatio) {
// Period ratio sparkline
sparkData = [];
Function processHTML
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function processHTML(proxyResponse, response) {
let body = Buffer.from([]);
let originalResponse = proxyResponse;
let uncompress;
const responseEncoding = originalResponse.headers['content-encoding'];
Function generatePageItems
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function generatePageItems(
total: number,
current: number,
width: number,
) {
Function getLayer
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function getLayer(
formData: QueryFormData,
payload: JsonObject,
onAddFilter: () => void,
setTooltip: (tooltip: TooltipProps['tooltip']) => void,
Function filteredMetrics
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const filteredMetrics = useMemo(() => {
if (!searchKeyword) {
return allowedMetrics ?? [];
}
return matchSorter(allowedMetrics, searchKeyword, {
Function useChartEditModal
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const useChartEditModal = (
setCharts: (charts: Array<Chart>) => void,
charts: Array<Chart>,
) => {
const [sliceCurrentlyEditing, setSliceCurrentlyEditing] =
Function copyTextToClipboard
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
new Promise<void>((resolve, reject) => {
const selection: Selection | null = document.getSelection();
if (selection) {
selection.removeAllRanges();
const range = document.createRange();
Function handleOnChange
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
(values: any, options: any) => {
// intercept onChange call to handle the select all case
// if the "select all" option is selected, we want to send all options to the onChange,
// otherwise we want to remove
let newValues = values;
Function render
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
render() {
return (
<>
<CrudButtonWrapper>
{this.props.allowAddItem && (
Function Icon
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const Icon = (props: IconProps) => {
const { fileName, ...iconProps } = props;
const [, setLoaded] = useState(false);
const ImportedSVG = useRef<FC<SVGProps<SVGSVGElement>>>();
const name = fileName.replace('_', '-');
Function onSave
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const onSave = () => {
if (isEditMode) {
// Edit
if (currentCssTemplate?.id) {
const update_id = currentCssTemplate.id;
Function setInScopeStatusOfFilters
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async (dispatch: Dispatch, getState: () => any) => {
const filters = getState().nativeFilters?.filters;
const filtersWithScopes = filterScopes.map(scope => ({
...filters[scope.filterId],
chartsInScope: scope.chartsInScope,
Function validateForm
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export const validateForm = async (
form: FormInstance<NativeFiltersForm>,
currentFilterId: string,
setCurrentFilterId: Function,
) => {
Function disableEmbedded
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const disableEmbedded = useCallback(() => {
Modal.confirm({
title: t('Disable embedding?'),
content: t('This will remove your current embed configuration.'),
okType: 'danger',
Function constructor
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor({
baseUrl = DEFAULT_BASE_URL,
host,
protocol,
headers = {},
Function renderValueConfiguration
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Open
renderValueConfiguration() {
const { annotationType, sourceType, value } = this.state;
let label = '';
let description = '';
if (requiresQuery(sourceType)) {
- 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"