Skip to content

Commit

Permalink
Change Inspection Profile to set "Method is identical to its super me…
Browse files Browse the repository at this point in the history
…thod" as error (apache#16976)

* Make IntelliJ's MethodIsIdenticalToSuperMethod an error

* Change codebase to follow new IntelliJ inspection

* Restore non-short-circuit boolean expressions to pass tests
  • Loading branch information
GWphua authored and edgar2020 committed Sep 5, 2024
1 parent b25bb4c commit cbb45ff
Show file tree
Hide file tree
Showing 17 changed files with 1 addition and 172 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Druid.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,11 @@
package org.apache.druid.indexing.common.task.batch.parallel;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableSet;
import org.apache.druid.indexing.common.task.TaskResource;
import org.apache.druid.server.security.Action;
import org.apache.druid.server.security.Resource;
import org.apache.druid.server.security.ResourceAction;
import org.apache.druid.server.security.ResourceType;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class LegacySinglePhaseSubTask extends SinglePhaseSubTask
{
Expand Down Expand Up @@ -66,16 +57,4 @@ public String getType()
return SinglePhaseSubTask.OLD_TYPE_NAME;
}

@Nonnull
@JsonIgnore
@Override
public Set<ResourceAction> getInputSourceResources()
{
return getIngestionSchema().getIOConfig().getInputSource() != null ?
getIngestionSchema().getIOConfig().getInputSource().getTypes()
.stream()
.map(i -> new ResourceAction(new Resource(i, ResourceType.EXTERNAL), Action.READ))
.collect(Collectors.toSet()) :
ImmutableSet.of();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@

package org.apache.druid.testing.tools;

import com.fasterxml.jackson.databind.Module;
import com.google.inject.Binder;
import org.apache.druid.initialization.DruidModule;

import java.util.Collections;
import java.util.List;

/**
* Super-simple "client" for the custom node role which defines
* the node role so that REST APIs and the system tables are
Expand All @@ -40,9 +36,4 @@ public void configure(Binder binder)
// NodeRoles.addRole(binder, CliCustomNodeRole.NODE_ROLE);
}

@Override
public List<? extends Module> getJacksonModules()
{
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,13 @@

package org.apache.druid.testing.tools;

import com.fasterxml.jackson.databind.Module;
import com.google.inject.Binder;
import org.apache.druid.guice.ExpressionModule;
import org.apache.druid.initialization.DruidModule;
import org.apache.druid.sql.guice.SqlBindings;

import java.util.Collections;
import java.util.List;

public class SleepModule implements DruidModule
{
@Override
public List<? extends Module> getJacksonModules()
{
return Collections.emptyList();
}

@Override
public void configure(Binder binder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,6 @@ class LongExpr extends ConstantExpr<Long>
super(ExpressionType.LONG, Preconditions.checkNotNull(value, "value"));
}

@Override
public String toString()
{
return String.valueOf(value);
}

@Override
protected ExprEval realEval()
{
Expand Down Expand Up @@ -329,12 +323,6 @@ class DoubleExpr extends ConstantExpr<Double>
super(ExpressionType.DOUBLE, Preconditions.checkNotNull(value, "value"));
}

@Override
public String toString()
{
return String.valueOf(value);
}

@Override
protected ExprEval realEval()
{
Expand Down
45 changes: 0 additions & 45 deletions processing/src/main/java/org/apache/druid/math/expr/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,6 @@ ExprEval doApply(ExprEval arrayExpr, ExprEval scalarExpr)
*/
abstract class ArraysMergeFunction extends ArraysFunction
{
@Override
public Set<Expr> getArrayInputs(List<Expr> args)
{
return ImmutableSet.copyOf(args);
}

@Override
public boolean hasArrayOutput()
Expand Down Expand Up @@ -1183,16 +1178,6 @@ public String name()
return NAME;
}

@Nullable
@Override
public ExpressionType getOutputType(Expr.InputBindingInspector inspector, List<Expr> args)
{
return ExpressionTypeConversion.function(
args.get(0).getOutputType(inspector),
args.get(1).getOutputType(inspector)
);
}

@Override
public boolean canVectorize(Expr.InputBindingInspector inspector, List<Expr> args)
{
Expand Down Expand Up @@ -2315,18 +2300,6 @@ public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
return ExprEval.ofLongBoolean(!super.apply(args, bindings).asBoolean());
}

@Override
public void validateArguments(List<Expr> args)
{
validationHelperCheckArgumentCount(args, 2);
}

@Nullable
@Override
public ExpressionType getOutputType(Expr.InputBindingInspector inspector, List<Expr> args)
{
return ExpressionType.LONG;
}
}

/**
Expand Down Expand Up @@ -3399,18 +3372,6 @@ public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
return ExprEval.ofArray(arrayType, out);
}

@Override
public Set<Expr> getScalarInputs(List<Expr> args)
{
return ImmutableSet.copyOf(args);
}

@Override
public Set<Expr> getArrayInputs(List<Expr> args)
{
return Collections.emptySet();
}

@Override
public boolean hasArrayOutput()
{
Expand Down Expand Up @@ -3544,12 +3505,6 @@ public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
return ExprEval.ofStringArray(arrayString.split(split != null ? split : ""));
}

@Override
public Set<Expr> getScalarInputs(List<Expr> args)
{
return ImmutableSet.copyOf(args);
}

@Override
public boolean hasArrayOutput()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.druid.query.aggregation;

import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector;

import java.nio.ByteBuffer;

/**
Expand Down Expand Up @@ -71,9 +69,4 @@ public void close()
// no resources to cleanup
}

@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

package org.apache.druid.query.aggregation;

import org.apache.druid.query.monomorphicprocessing.RuntimeShapeInspector;

import java.nio.ByteBuffer;

public final class NoopBufferAggregator implements BufferAggregator
Expand Down Expand Up @@ -75,9 +73,4 @@ public void close()
{
}

@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.Collections;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.function.ToIntFunction;

public class BufferHashGrouper<KeyType> extends AbstractBufferHashGrouper<KeyType>
{
Expand Down Expand Up @@ -128,12 +127,6 @@ public boolean isInitialized()
return initialized;
}

@Override
public ToIntFunction<KeyType> hashFunction()
{
return Groupers::hashObject;
}

@Override
public void newBucketHook(int bucketOffset)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,12 +1815,6 @@ private class ArrayStringRowBasedKeySerdeHelper extends DictionaryBuildingSingle
);
}

@Override
public int getKeyBufferValueSize()
{
return Integer.BYTES;
}

@Override
public BufferComparator getBufferComparator()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,6 @@ public int getCardinality()
return counter;
}

@Override
public void remove()
{
throw new UnsupportedOperationException("remove");
}
}

public static class IdLookupArrayIterator implements Iterator<int[]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,6 @@ protected T writeTranslate(Pair<Integer, PeekingIterator<T>> smallest, int count
return value;
}

@Override
public void remove()
{
throw new UnsupportedOperationException("remove");
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ public int getCardinality()
return counter;
}

@Override
public void remove()
{
throw new UnsupportedOperationException("remove");
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,6 @@ public ValueMatcher makeValueMatcher(DruidPredicateFactory predicateFactory)
return DimensionSelectorUtils.makeValueMatcherGeneric(this, predicateFactory);
}

@Nullable
@Override
public Object getObject()
{
return defaultGetObject();
}

@Override
public Class classOfObject()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@ public void close() throws IOException
};
}

@Override
public boolean isCacheable()
{
return false;
}

@Override
public void close()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1423,13 +1423,6 @@ public long getLong()
return Numbers.tryParseLong(o, 0L);
}

@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
inspector.visit("baseSelector", baseSelector);
inspector.visit("parts", parts);
}

@Override
public boolean isNull()
{
Expand Down Expand Up @@ -1461,11 +1454,6 @@ public Object getObject()
return null;
}

@Override
public Class<?> classOfObject()
{
return Object.class;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.druid.catalog.model.CatalogUtils;
import org.apache.druid.catalog.model.ColumnSpec;
import org.apache.druid.catalog.model.Columns;
import org.apache.druid.catalog.model.ModelProperties;
Expand Down Expand Up @@ -78,12 +77,6 @@ public SegmentGranularityFieldDefn()
super(SEGMENT_GRANULARITY_PROPERTY);
}

@Override
public void validate(Object value, ObjectMapper jsonMapper)
{
String gran = decode(value, jsonMapper);
CatalogUtils.validateGranularity(gran);
}
}

public static class HiddenColumnsDefn extends StringListPropertyDefn
Expand Down

0 comments on commit cbb45ff

Please sign in to comment.