Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix redundant Checkstyle #1896

Merged
merged 21 commits into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
163df9f
add redundant
seagle-yuan Jun 3, 2022
db21536
Merge branch 'master' into checkstyle-redundant
seagle-yuan Jun 5, 2022
02f0207
add redundant check
seagle-yuan Jun 5, 2022
bfdf11a
merge line
seagle-yuan Jun 5, 2022
12b91c1
update alignment
seagle-yuan Jun 6, 2022
2de645d
Merge branch 'master' into checkstyle-redundant
seagle-yuan Jun 13, 2022
92a4bf0
delete duplicates check MissingSwitchDefault
seagle-yuan Jun 15, 2022
f437554
Merge branch 'apache:master' into checkstyle-redundant
seagle-yuan Jun 15, 2022
f6240a5
Merge branch 'checkstyle-redundant' of https://github.com/seagle-yuan…
seagle-yuan Jun 15, 2022
d3d7c79
update wrap line
seagle-yuan Jun 15, 2022
ff82af0
update code style
seagle-yuan Jun 17, 2022
432cc04
Merge branch 'master' into checkstyle-redundant
seagle-yuan Jul 6, 2022
74193f2
Merge branch 'apache:master' into checkstyle-redundant
seagle-yuan Jul 6, 2022
f96a617
Merge branch 'checkstyle-redundant' of https://github.com/seagle-yuan…
seagle-yuan Jul 6, 2022
765bd85
Merge branch 'apache:master' into checkstyle-redundant
seagle-yuan Aug 3, 2022
1447e1e
Merge branch 'master' into checkstyle-redundant
seagle-yuan Aug 3, 2022
341a18a
Merge branch 'checkstyle-redundant' of https://github.com/seagle-yuan…
seagle-yuan Sep 9, 2022
c1e2d4c
merge dev
seagle-yuan Oct 12, 2022
6ab5ab6
merge master
seagle-yuan Oct 12, 2022
8cda2a0
merge master
seagle-yuan Oct 12, 2022
868ee2f
Merge branch 'apache:master' into checkstyle-redundant
seagle-yuan Oct 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class CypherAPI extends GremlinQueryAPI {

private static final Logger LOG = Log.logger(CypherAPI.class);


@GET
@Timed
@CompressInterceptor.Compress(buffer = (1024 * 40))
Expand Down Expand Up @@ -63,11 +62,11 @@ private Response queryByCypher(String graph,
LOG.debug("translated gremlin is {}", gremlin);

String auth = headers.getHeaderString(HttpHeaders.AUTHORIZATION);
String request = "{"
+ "\"gremlin\":\"" + gremlin + "\","
+ "\"bindings\":{},"
+ "\"language\":\"gremlin-groovy\","
+ "\"aliases\":{\"g\":\"__g_" + graph + "\"}}";
String request = "{" +
"\"gremlin\":\"" + gremlin + "\"," +
"\"bindings\":{}," +
"\"language\":\"gremlin-groovy\"," +
"\"aliases\":{\"g\":\"__g_" + graph + "\"}}";

Response response = this.client().doPostRequest(auth, request);
return transformResponseIfNeeded(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

package com.baidu.hugegraph.api.gremlin;

import java.util.Map;
import java.util.Set;

import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
Expand All @@ -30,22 +27,15 @@
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;

import com.baidu.hugegraph.api.API;
import com.baidu.hugegraph.api.filter.CompressInterceptor.Compress;
import com.baidu.hugegraph.config.HugeConfig;
import com.baidu.hugegraph.config.ServerOptions;
import com.baidu.hugegraph.exception.HugeGremlinException;
import com.baidu.hugegraph.metrics.MetricsUtil;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.annotation.Timed;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import jakarta.inject.Provider;
import jakarta.inject.Singleton;

@Path("gremlin")
Expand All @@ -58,7 +48,6 @@ public class GremlinAPI extends GremlinQueryAPI {
private static final Histogram GREMLIN_OUTPUT_HISTOGRAM =
MetricsUtil.registerHistogram(GremlinAPI.class, "gremlin-output");


@POST
@Timed
@Compress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public String get(@Context GraphManager manager,
double similarity;
try (JaccardSimilarTraverser traverser =
new JaccardSimilarTraverser(g)) {
similarity = traverser.jaccardSimilarity(sourceId, targetId, dir,
edgeLabel, maxDegree);
similarity = traverser.jaccardSimilarity(sourceId, targetId, dir,
edgeLabel, maxDegree);
}
return JsonUtil.toJson(ImmutableMap.of("jaccard_similarity",
similarity));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,33 @@

public interface HugeAuthenticator extends Authenticator {

public static final String KEY_USERNAME =
CredentialGraphTokens.PROPERTY_USERNAME;
public static final String KEY_PASSWORD =
CredentialGraphTokens.PROPERTY_PASSWORD;
public static final String KEY_TOKEN = "token";
public static final String KEY_ROLE = "role";
public static final String KEY_ADDRESS = "address";
public static final String KEY_PATH = "path";
String KEY_USERNAME = CredentialGraphTokens.PROPERTY_USERNAME;
String KEY_PASSWORD = CredentialGraphTokens.PROPERTY_PASSWORD;
String KEY_TOKEN = "token";
String KEY_ROLE = "role";
String KEY_ADDRESS = "address";
String KEY_PATH = "path";

public static final String USER_SYSTEM = "system";
public static final String USER_ADMIN = "admin";
public static final String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME;
String USER_SYSTEM = "system";
String USER_ADMIN = "admin";
String USER_ANONY = AuthenticatedUser.ANONYMOUS_USERNAME;

public static final RolePermission ROLE_NONE = RolePermission.none();
public static final RolePermission ROLE_ADMIN = RolePermission.admin();
RolePermission ROLE_NONE = RolePermission.none();
RolePermission ROLE_ADMIN = RolePermission.admin();

public static final String VAR_PREFIX = "$";
public static final String KEY_OWNER = VAR_PREFIX + "owner";
public static final String KEY_DYNAMIC = VAR_PREFIX + "dynamic";
public static final String KEY_ACTION = VAR_PREFIX + "action";
String VAR_PREFIX = "$";
String KEY_OWNER = VAR_PREFIX + "owner";
String KEY_DYNAMIC = VAR_PREFIX + "dynamic";
String KEY_ACTION = VAR_PREFIX + "action";

public void setup(HugeConfig config);
void setup(HugeConfig config);

public UserWithRole authenticate(String username, String password,
String token);
UserWithRole authenticate(String username, String password, String token);

public AuthManager authManager();
AuthManager authManager();

@Override
public default void setup(final Map<String, Object> config) {
default void setup(final Map<String, Object> config) {
E.checkState(config != null,
"Must provide a 'config' in the 'authentication'");
String path = (String) config.get("tokens");
Expand All @@ -83,7 +80,7 @@ public default void setup(final Map<String, Object> config) {
}

@Override
public default User authenticate(final Map<String, String> credentials)
default User authenticate(final Map<String, String> credentials)
seagle-yuan marked this conversation as resolved.
Show resolved Hide resolved
throws AuthenticationException {
HugeGraphAuthProxy.resetContext();

Expand Down Expand Up @@ -115,21 +112,21 @@ public default User authenticate(final Map<String, String> credentials)
}

@Override
public default boolean requireAuthentication() {
default boolean requireAuthentication() {
return true;
}

public default boolean verifyRole(RolePermission role) {
default boolean verifyRole(RolePermission role) {
if (role == ROLE_NONE || role == null) {
return false;
} else {
return true;
}
}

public void initAdminUser(String password) throws Exception;
void initAdminUser(String password) throws Exception;

public static HugeAuthenticator loadAuthenticator(HugeConfig conf) {
static HugeAuthenticator loadAuthenticator(HugeConfig conf) {
String authClass = conf.get(ServerOptions.AUTHENTICATOR);
if (authClass.isEmpty()) {
return null;
Expand All @@ -150,7 +147,7 @@ public static HugeAuthenticator loadAuthenticator(HugeConfig conf) {
return authenticator;
}

public static class User extends AuthenticatedUser {
class User extends AuthenticatedUser {

public static final User ADMIN = new User(USER_ADMIN, ROLE_ADMIN);
public static final User ANONYMOUS = new User(USER_ANONY, ROLE_ADMIN);
Expand Down Expand Up @@ -255,7 +252,7 @@ public static class UserJson {
}
}

public static class RolePerm {
class RolePerm {

@JsonProperty("roles") // graph -> action -> resource
private Map<String, Map<HugePermission, Object>> roles;
Expand Down Expand Up @@ -395,7 +392,7 @@ public static boolean match(Object role, RolePermission grant,
}
}

public static class RequiredPerm {
class RequiredPerm {

@JsonProperty("owner")
private String owner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1764,17 +1764,17 @@ public String toString() {
private static final ThreadLocal<Context> CONTEXTS =
new InheritableThreadLocal<>();

protected static final Context setContext(Context context) {
protected static Context setContext(Context context) {
Context old = CONTEXTS.get();
CONTEXTS.set(context);
return old;
}

protected static final void resetContext() {
protected static void resetContext() {
CONTEXTS.remove();
}

protected static final Context getContext() {
protected static Context getContext() {
// Return task context first
String taskContext = TaskManager.getContext();
User user = User.fromJson(taskContext);
Expand All @@ -1785,15 +1785,15 @@ protected static final Context getContext() {
return CONTEXTS.get();
}

protected static final String getContextString() {
protected static String getContextString() {
Context context = getContext();
if (context == null) {
return null;
}
return context.user().toJson();
}

protected static final void logUser(User user, String path) {
protected static void logUser(User user, String path) {
LOG.info("User '{}' login from client [{}] with path '{}'",
user.username(), user.client(), path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}
}

private void sendError(ChannelHandlerContext ctx, Object msg) {
private void sendError(ChannelHandlerContext context, Object msg) {
// Close the connection as soon as the error message is sent.
ctx.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, UNAUTHORIZED))
.addListener(ChannelFutureListener.CLOSE);
context.writeAndFlush(new DefaultFullHttpResponse(HTTP_1_1, UNAUTHORIZED))
.addListener(ChannelFutureListener.CLOSE);
ReferenceCountUtil.release(msg);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

public interface Checkable {

public void checkCreate(boolean isBatch);
void checkCreate(boolean isBatch);

public default void checkUpdate() {
default void checkUpdate() {
this.checkCreate(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,65 +42,61 @@

public interface Serializer {

public String writeMap(Map<?, ?> map);
String writeMap(Map<?, ?> map);

public String writeList(String label, Collection<?> list);
String writeList(String label, Collection<?> list);

public String writePropertyKey(PropertyKey propertyKey);
String writePropertyKey(PropertyKey propertyKey);

public String writePropertyKeys(List<PropertyKey> propertyKeys);
String writePropertyKeys(List<PropertyKey> propertyKeys);

public String writeVertexLabel(VertexLabel vertexLabel);
String writeVertexLabel(VertexLabel vertexLabel);

public String writeVertexLabels(List<VertexLabel> vertexLabels);
String writeVertexLabels(List<VertexLabel> vertexLabels);

public String writeEdgeLabel(EdgeLabel edgeLabel);
String writeEdgeLabel(EdgeLabel edgeLabel);

public String writeEdgeLabels(List<EdgeLabel> edgeLabels);
String writeEdgeLabels(List<EdgeLabel> edgeLabels);

public String writeIndexlabel(IndexLabel indexLabel);
String writeIndexlabel(IndexLabel indexLabel);

public String writeIndexlabels(List<IndexLabel> indexLabels);
String writeIndexlabels(List<IndexLabel> indexLabels);

public String writeTaskWithSchema(SchemaElement.TaskWithSchema tws);
String writeTaskWithSchema(SchemaElement.TaskWithSchema tws);

public String writeVertex(Vertex v);
String writeVertex(Vertex v);

public String writeVertices(Iterator<Vertex> vertices, boolean paging);
String writeVertices(Iterator<Vertex> vertices, boolean paging);

public String writeEdge(Edge e);
String writeEdge(Edge e);

public String writeEdges(Iterator<Edge> edges, boolean paging);
String writeEdges(Iterator<Edge> edges, boolean paging);

public String writeIds(List<Id> ids);
String writeIds(List<Id> ids);

public String writeAuthElement(AuthElement elem);
String writeAuthElement(AuthElement elem);

public <V extends AuthElement> String writeAuthElements(String label,
List<V> users);
<V extends AuthElement> String writeAuthElements(String label, List<V> users);

public String writePaths(String name, Collection<HugeTraverser.Path> paths,
String writePaths(String name, Collection<HugeTraverser.Path> paths,
seagle-yuan marked this conversation as resolved.
Show resolved Hide resolved
boolean withCrossPoint, Iterator<Vertex> vertices);

public default String writePaths(String name,
default String writePaths(String name,
Collection<HugeTraverser.Path> paths,
boolean withCrossPoint) {
return this.writePaths(name, paths, withCrossPoint, null);
}

public String writeCrosspoints(CrosspointsPaths paths,
String writeCrosspoints(CrosspointsPaths paths,
Iterator<Vertex> iterator, boolean withPath);

public String writeSimilars(SimilarsMap similars,
Iterator<Vertex> vertices);
String writeSimilars(SimilarsMap similars, Iterator<Vertex> vertices);

public String writeWeightedPath(NodeWithWeight path,
Iterator<Vertex> vertices);
String writeWeightedPath(NodeWithWeight path, Iterator<Vertex> vertices);

public String writeWeightedPaths(WeightedPaths paths,
Iterator<Vertex> vertices);
String writeWeightedPaths(WeightedPaths paths, Iterator<Vertex> vertices);

public String writeNodesWithPath(String name, List<Id> nodes, long size,
String writeNodesWithPath(String name, List<Id> nodes, long size,
Collection<HugeTraverser.Path> paths,
Iterator<Vertex> vertices);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@

public interface Analyzer {

public Set<String> segment(String text);
Set<String> segment(String text);
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@

public interface Transaction {

public void commit() throws BackendException;
void commit() throws BackendException;

public void commitIfGtSize(int size) throws BackendException;
void commitIfGtSize(int size) throws BackendException;

public void rollback() throws BackendException;
void rollback() throws BackendException;

public boolean autoCommit();
boolean autoCommit();

public void close();
void close();
}
Loading