Skip to content

Commit

Permalink
Set up more strict code styles and fix existing issues (#4337)
Browse files Browse the repository at this point in the history
Motivation:

Review code styles with some bots automatically.

Modifications:

Set up ReviewDog in GitHub Action to review code style.

Add more check rules to checkstyle plugin.

Result:

Obvious code styles can be reviewed and commented automatically.
  • Loading branch information
kezhenxu94 committed Feb 11, 2020
1 parent fa526e5 commit 5b255ba
Show file tree
Hide file tree
Showing 2,712 changed files with 19,839 additions and 19,957 deletions.
Expand Up @@ -16,17 +16,15 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.log4j.v1.x;

import org.apache.log4j.helpers.PatternConverter;
import org.apache.log4j.spi.LoggingEvent;

/**
* Default implementation outputs "TID: N/A".
* But, if in sky-walking agent active mode, output will become the real ids.
* Default implementation outputs "TID: N/A". But, if in sky-walking agent active mode, output will become the real
* ids.
* <p>
* Created by wusheng on 2016/12/7.
*/

public class TraceIdPatternConverter extends PatternConverter {
Expand Down
Expand Up @@ -16,7 +16,6 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.log4j.v1.x;

import org.apache.log4j.PatternLayout;
Expand All @@ -25,8 +24,6 @@
/**
* The log4j extend pattern. By using this pattern, if sky-walking agent is also active, {@link
* PatternParser#finalizeConverter(char)} method will be override dynamic. <p>
*
* @author wusheng
*/
public class TraceIdPatternLayout extends PatternLayout {
@Override
Expand Down
Expand Up @@ -16,15 +16,13 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.log4j.v1.x;

import org.apache.log4j.helpers.PatternParser;

/**
* Base on '%T', use {@link TraceIdPatternConverter} to convert the '%t' to traceId.
* <p>
* Created by wusheng on 2016/12/7.
*/
public class TraceIdPatternParser extends PatternParser {
public TraceIdPatternParser(String pattern) {
Expand Down
Expand Up @@ -16,16 +16,12 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.log4j.v2.x;

/**
* Created by wusheng on 2016/12/11.
*/
public class Log4j2OutputAppender {
/**
* As default, append "TID: N/A" to the output message,
* if sky-walking agent in active mode, append the real traceId in the recent Context, if existed, or empty String.
* As default, append "TID: N/A" to the output message, if sky-walking agent in active mode, append the real traceId
* in the recent Context, if existed, or empty String.
*
* @param toAppendTo origin output message.
*/
Expand Down
Expand Up @@ -16,7 +16,6 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.log4j.v2.x;

import org.apache.logging.log4j.core.LogEvent;
Expand All @@ -25,12 +24,9 @@
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;

/**
* {@link TraceIdConverter} is a log4j2 plugin, by annotation as {@link Plugin}.
* It convert the pattern key: traceId.
* Use '%traceId' in log4j2's config.
* '%traceId' will output as TID:xxxx
* {@link TraceIdConverter} is a log4j2 plugin, by annotation as {@link Plugin}. It convert the pattern key: traceId.
* Use '%traceId' in log4j2's config. '%traceId' will output as TID:xxxx
* <p>
* Created by wusheng on 2016/12/7.
*/
@Plugin(name = "TraceIdConverter", category = "Converter")
@ConverterKeys({"traceId"})
Expand All @@ -39,7 +35,7 @@ public class TraceIdConverter extends LogEventPatternConverter {
/**
* Constructs an instance of LoggingEventPatternConverter.
*
* @param name name of converter.
* @param name name of converter.
* @param style CSS style for output.
*/
protected TraceIdConverter(String name, String style) {
Expand Down
Expand Up @@ -16,19 +16,15 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.logback.v1.x;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;

/**
* Created by wusheng on 2016/12/7.
*/
public class LogbackPatternConverter extends ClassicConverter {
/**
* As default, return "TID: N/A" to the output message,
* if sky-walking agent in active mode, return the real traceId in the recent Context, if existed.
* As default, return "TID: N/A" to the output message, if sky-walking agent in active mode, return the real traceId
* in the recent Context, if existed.
*
* @param iLoggingEvent the event
* @return the traceId: N/A, empty String, or the real traceId.
Expand Down
Expand Up @@ -16,17 +16,14 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.logback.v1.x;

import ch.qos.logback.classic.PatternLayout;

/**
* Based on the logback-compoenent convert register mechanism,
* register {@link LogbackPatternConverter} as a new convert, match to "tid".
* You can use "%tid" in logback config file, "Pattern" section.
* Based on the logback-compoenent convert register mechanism, register {@link LogbackPatternConverter} as a new
* convert, match to "tid". You can use "%tid" in logback config file, "Pattern" section.
* <p>
* Created by wusheng on 2016/12/7.
*/
public class TraceIdPatternLogbackLayout extends PatternLayout {
static {
Expand Down
Expand Up @@ -27,9 +27,6 @@
import net.logstash.logback.composite.JsonWritingUtils;
import net.logstash.logback.fieldnames.LogstashFieldNames;

/**
* @author wuxingye
*/
public class TraceIdJsonProvider extends AbstractFieldJsonProvider<ILoggingEvent> implements FieldNamesAware<LogstashFieldNames> {

public static final String TRACING_ID = "TID";
Expand Down
Expand Up @@ -16,20 +16,17 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc;

import ch.qos.logback.classic.pattern.MDCConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.util.OptionHelper;

/**
* @author zhangkewei
*/
public class LogbackMDCPatternConverter extends MDCConverter {
private static final String CONVERT_KEY = "tid";
private static final String CONVERT_KEY = "tid";

private boolean convert4TID = false;

@Override
public void start() {
super.start();
Expand All @@ -38,6 +35,7 @@ public void start() {
convert4TID = true;
}
}

@Override
public String convert(ILoggingEvent iLoggingEvent) {
return convert4TID ? convertTID(iLoggingEvent) : super.convert(iLoggingEvent);
Expand Down
Expand Up @@ -16,14 +16,12 @@
*
*/


package org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc;

import ch.qos.logback.classic.PatternLayout;

/**
* Override "X",SuperClass run before Subclass.
* @author zhangkewei
*/
public class TraceIdMDCPatternLogbackLayout extends PatternLayout {
static {
Expand Down
Expand Up @@ -16,7 +16,6 @@
*
*/


package org.apache.skywalking.apm.toolkit.opentracing;

import io.opentracing.SpanContext;
Expand All @@ -25,9 +24,6 @@
import java.util.HashMap;
import java.util.Map;

/**
* Created by wusheng on 2016/12/21.
*/
public class ByteBufferContext implements SpanContext {
static final Charset CHARSET = Charset.forName("UTF-8");

Expand Down
Expand Up @@ -16,7 +16,6 @@
*
*/


package org.apache.skywalking.apm.toolkit.opentracing;

import java.lang.annotation.ElementType;
Expand All @@ -25,12 +24,13 @@
import java.lang.annotation.Target;

/**
* The <code>NeedSnifferActivation</code> annotation is flag for reader and maintainers,
* which represents this method should be activated/intercepted in sniffer.
*
* @author wusheng
* The <code>NeedSnifferActivation</code> annotation is flag for reader and maintainers, which represents this method
* should be activated/intercepted in sniffer.
*/
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
@Target({
ElementType.METHOD,
ElementType.CONSTRUCTOR
})
@Retention(RetentionPolicy.SOURCE)
public @interface NeedSnifferActivation {
String value() default "What should interceptor do?";
Expand Down
Expand Up @@ -16,18 +16,15 @@
*
*/


package org.apache.skywalking.apm.toolkit.opentracing;

import io.opentracing.ActiveSpan;
import io.opentracing.SpanContext;
import java.util.Map;

/**
* The <code>SkywalkingActiveSpan</code> is an extension of {@link SkywalkingSpan},
* but because of Java inheritance restrict, only can do with a facade mode.
*
* @author wusheng
* The <code>SkywalkingActiveSpan</code> is an extension of {@link SkywalkingSpan}, but because of Java inheritance
* restrict, only can do with a facade mode.
*/
public class SkywalkingActiveSpan implements ActiveSpan {
private SkywalkingSpan span;
Expand Down
Expand Up @@ -16,7 +16,6 @@
*
*/


package org.apache.skywalking.apm.toolkit.opentracing;

import io.opentracing.SpanContext;
Expand All @@ -25,8 +24,6 @@

/**
* Skywalking tracer context based on {@link ThreadLocal} auto mechanism.
*
* @author wusheng
*/
public class SkywalkingContext implements SpanContext {
public static final SkywalkingContext INSTANCE = new SkywalkingContext();
Expand Down
Expand Up @@ -16,22 +16,16 @@
*
*/


package org.apache.skywalking.apm.toolkit.opentracing;

import io.opentracing.ActiveSpan;

/**
* @author wusheng
*/
public class SkywalkingContinuation implements ActiveSpan.Continuation {
@NeedSnifferActivation("1. ContextManager#capture" +
"2. set ContextSnapshot to the dynamic field")
@NeedSnifferActivation("1. ContextManager#capture" + "2. set ContextSnapshot to the dynamic field")
public SkywalkingContinuation() {
}

@NeedSnifferActivation("1. get ContextSnapshot from the dynamic field" +
"2. ContextManager#continued")
@NeedSnifferActivation("1. get ContextSnapshot from the dynamic field" + "2. ContextManager#continued")
@Override
public ActiveSpan activate() {
SkywalkingSpanBuilder builder = new SkywalkingSpanBuilder("Thread/" + Thread.currentThread().getName());
Expand Down
Expand Up @@ -16,31 +16,22 @@
*
*/


package org.apache.skywalking.apm.toolkit.opentracing;

import io.opentracing.Span;
import io.opentracing.SpanContext;
import java.util.HashMap;
import java.util.Map;

/**
* @author wusheng
*/
public class SkywalkingSpan implements Span {
@NeedSnifferActivation(
"1.ContextManager#createSpan (Entry,Exit,Local based on builder)." +
"2.set the span reference to the dynamic field of enhanced SkywalkingSpan") SkywalkingSpan(
SkywalkingSpanBuilder builder) {
@NeedSnifferActivation("1.ContextManager#createSpan (Entry,Exit,Local based on builder)." + "2.set the span reference to the dynamic field of enhanced SkywalkingSpan")
SkywalkingSpan(SkywalkingSpanBuilder builder) {
}

/**
* Create a shell span for {@link SkywalkingTracer#activeSpan()}
*
* @param tracer
*/
@NeedSnifferActivation(
"1. set the span reference to the dynamic field of enhanced SkywalkingSpan")
@NeedSnifferActivation("1. set the span reference to the dynamic field of enhanced SkywalkingSpan")
public SkywalkingSpan(SkywalkingTracer tracer) {

}
Expand All @@ -59,12 +50,8 @@ public Span log(long timestampMicroseconds, Map<String, ?> fields) {

/**
* Stop the active span
*
* @param finishMicros
*/
@NeedSnifferActivation(
"1.ContextManager#stopSpan(AbstractSpan span)" +
"2. The parameter of stop methed is from the dynamic field of enhanced SkywalkingSpan")
@NeedSnifferActivation("1.ContextManager#stopSpan(AbstractSpan span)" + "2. The parameter of stop methed is from the dynamic field of enhanced SkywalkingSpan")
@Override
public void finish(long finishMicros) {

Expand All @@ -87,18 +74,19 @@ public SpanContext context() {
return SkywalkingContext.INSTANCE;
}

@NeedSnifferActivation(
"1. ContextManager#activeSpan()" +
"2. SkywalkingSpan#setTag(String, String)")
@Override public Span setTag(String key, String value) {
@NeedSnifferActivation("1. ContextManager#activeSpan()" + "2. SkywalkingSpan#setTag(String, String)")
@Override
public Span setTag(String key, String value) {
return this;
}

@Override public Span setTag(String key, boolean value) {
@Override
public Span setTag(String key, boolean value) {
return setTag(key, String.valueOf(value));
}

@Override public Span setTag(String key, Number value) {
@Override
public Span setTag(String key, Number value) {
return setTag(key, String.valueOf(value));
}

Expand Down

0 comments on commit 5b255ba

Please sign in to comment.