alibaba/transmittable-thread-local

View on GitHub

Showing 208 of 208 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

            for (Map.Entry<ThreadLocal<Object>, UnaryOperator<Object>> entry : threadLocalHolder.entrySet()) {
                final ThreadLocal<Object> threadLocal = entry.getKey();
                final UnaryOperator<Object> generator = entry.getValue();

                threadLocal2Value.put(threadLocal, generator.apply(threadLocal.get()));
ttl2-compatible/src/main/java/com/alibaba/ttl/TransmittableThreadLocal.java on lines 800..805

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

                        for (Map.Entry<ThreadLocal<Object>, TtlCopier<Object>> entry : threadLocalHolder.entrySet()) {
                            final ThreadLocal<Object> threadLocal = entry.getKey();
                            final TtlCopier<Object> copier = entry.getValue();

                            threadLocal2Value.put(threadLocal, copier.copy(threadLocal.get()));
ttl-core/src/main/java/com/alibaba/ttl3/transmitter/ThreadLocalTransmitRegistry.java on lines 149..154

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 48.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method transform has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public final byte[] transform(@Nullable final ClassLoader loader, @Nullable final String classFile, final Class<?> classBeingRedefined,
                                  final ProtectionDomain protectionDomain, @NonNull final byte[] classFileBuffer) {
Severity: Minor
Found in ttl-agent/src/main/java/com/alibaba/ttl3/agent/TtlTransformer.java - About 35 mins to fix

    Method loadExtensionInstances has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

                ClassLoader classLoader, LinkedHashSet<String> instanceClassNames, Class<T> superType,
                String foundMsgHead, String failLoadMsgHead

      Method transform has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public final byte[] transform(@Nullable final ClassLoader loader, @Nullable final String classFile, final Class<?> classBeingRedefined,
                                        final ProtectionDomain protectionDomain, @NonNull final byte[] classFileBuffer) {

        Method loadExtensionInstances has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                ClassLoader classLoader, LinkedHashSet<String> instanceClassNames, Class<T> superType,
                String foundMsgHead, String failLoadMsgHead

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          package com.alibaba.ttl3.agent.transformlet.internal;
          
          import com.alibaba.ttl3.agent.TtlAgent;
          import com.alibaba.ttl3.agent.transformlet.TtlTransformlet;
          import com.alibaba.ttl3.agent.transformlet.helper.AbstractExecutorTtlTransformlet;
          ttl2-compatible/src/main/java/com/alibaba/ttl/threadpool/agent/transformlet/internal/JdkExecutorTtlTransformlet.java on lines 1..34

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 47.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          package com.alibaba.ttl.threadpool.agent.transformlet.internal;
          
          import com.alibaba.ttl.threadpool.agent.TtlAgent;
          import com.alibaba.ttl.threadpool.agent.transformlet.TtlTransformlet;
          import com.alibaba.ttl.threadpool.agent.transformlet.helper.AbstractExecutorTtlTransformlet;
          ttl-agent/src/main/java/com/alibaba/ttl3/agent/transformlet/internal/JdkExecutorTtlTransformlet.java on lines 1..33

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 47.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          /**
           * check the executor is a TTL executor wrapper or not.
           */
          @Suppress("NOTHING_TO_INLINE")
          inline fun Executor?.isTtlExecutor(): Boolean = TtlExecutors.isTtlExecutor(this)
          ttl-kotlin/src/main/kotlin/com/alibaba/ttl3/kotlin/TtlExtensions.kt on lines 372..379
          ttl-kotlin/src/main/kotlin/com/alibaba/ttl3/kotlin/TtlExtensions.kt on lines 409..416

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          /**
           * check the [ThreadFactory] is `DisableInheritableThreadFactory` or not.
           *
           * @see TtlExecutors.isDisableInheritableThreadFactory
           */
          ttl-kotlin/src/main/kotlin/com/alibaba/ttl3/kotlin/TtlExtensions.kt on lines 335..339
          ttl-kotlin/src/main/kotlin/com/alibaba/ttl3/kotlin/TtlExtensions.kt on lines 409..416

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 3 locations. Consider refactoring.
          Open

          /**
           * check the [ForkJoinWorkerThreadFactory] is `DisableInheritableForkJoinWorkerThreadFactory` or not.
           *
           * @see TtlExecutors.isDisableInheritableForkJoinWorkerThreadFactory
           */
          ttl-kotlin/src/main/kotlin/com/alibaba/ttl3/kotlin/TtlExtensions.kt on lines 335..339
          ttl-kotlin/src/main/kotlin/com/alibaba/ttl3/kotlin/TtlExtensions.kt on lines 372..379

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 66.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method beforeReplay has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              Object beforeReplay() {
                  Set<CrrTransmitCallback> callbacks = new HashSet<>(registeredCrrTransmitCallbackSet);
                  for (CrrTransmitCallback cb : callbacks) {
                      try {
                          cb.beforeReplay();

          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"

          Further reading

          Method getStringOptionValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              @NonNull
              static String getStringOptionValue(
                  @Nullable final Map<String, String> kvs, @NonNull String key,
                  @NonNull String defaultValue
              ) {

          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"

          Further reading

          Method beforeRestore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              Object beforeRestore(Object data) {
                  @SuppressWarnings("unchecked")
                  Set<CrrTransmitCallback> callbacks = (Set<CrrTransmitCallback>) data;
                  for (CrrTransmitCallback cb : callbacks) {
                      try {

          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"

          Further reading

          Method afterRestore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              void afterRestore(Object data) {
                  @SuppressWarnings("unchecked")
                  Set<CrrTransmitCallback> callbacks = (Set<CrrTransmitCallback>) data;
                  for (CrrTransmitCallback cb : callbacks) {
                      try {

          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"

          Further reading

          Method isBooleanOptionSet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              static boolean isBooleanOptionSet(
                      @Nullable final Map<String, String> kvs, @NonNull String key,
                      boolean defaultValueIfKeyAbsent, boolean defaultValueIfValueAbsent
              ) {
                  final String value;
          Severity: Minor
          Found in ttl-agent/src/main/java/com/alibaba/ttl3/agent/TtlAgentHelper.java - About 35 mins to fix

          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"

          Further reading

          Method isBooleanOptionSet has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              static boolean isBooleanOptionSet(
                  @Nullable final Map<String, String> kvs, @NonNull String key,
                  boolean defaultValueIfKeyAbsent, boolean defaultValueIfValueAbsent
              ) {
                  final String value;

          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"

          Further reading

          Method getStringOptionValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              @NonNull
              static String getStringOptionValue(
                      @Nullable final Map<String, String> kvs, @NonNull String key,
                      @NonNull String defaultValue
              ) {
          Severity: Minor
          Found in ttl-agent/src/main/java/com/alibaba/ttl3/agent/TtlAgentHelper.java - About 35 mins to fix

          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"

          Further reading

          Method splitCommaColonStringToKV has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              @NonNull
              static Map<String, String> splitCommaColonStringToKV(@Nullable final String commaColonString) {
                  final Map<String, String> ret = new HashMap<>();
                  if (commaColonString == null || commaColonString.trim().length() == 0) return ret;
          
          
          Severity: Minor
          Found in ttl-agent/src/main/java/com/alibaba/ttl3/agent/TtlAgentHelper.java - About 35 mins to fix

          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"

          Further reading

          Method restore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  public static void restore(@NonNull Object backup) {
                      for (Map.Entry<Transmittee<Object, Object>, Object> entry : ((Snapshot) backup).transmittee2Value.entrySet()) {
                          Transmittee<Object, Object> transmittee = entry.getKey();
                          try {
                              Object transmitteeBackup = entry.getValue();

          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"

          Further reading

          Severity
          Category
          Status
          Source
          Language