alibaba/transmittable-thread-local

View on GitHub

Showing 86 of 208 total issues

Method parseLine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static int parseLine(URL url, BufferedReader reader, int lineNum, LinkedHashSet<String> names) throws IOException {
        String line = reader.readLine();
        if (line == null) {
            return -1;
        }

    Method findInChain has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            @Nullable
            private Reference<K, V> findInChain(Reference<K, V> ref, @Nullable Object key, int hash) {
                Reference<K, V> currRef = ref;
                while (currRef != null) {
                    if (currRef.getHash() == hash) {

    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 doTask has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            @Nullable
            public <T> T doTask(final int hash, @Nullable final Object key, final Task<T> task) {
                boolean resize = task.hasOption(TaskOption.RESIZE);
                if (task.hasOption(TaskOption.RESTRUCTURE_BEFORE)) {
                    restructureIfNecessary(resize);

      Method transform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public final byte[] transform(@Nullable final ClassLoader loader, @Nullable final String classFile, final Class<?> classBeingRedefined,
                                        final ProtectionDomain protectionDomain, @NonNull final byte[] classFileBuffer) {
              try {
                  // Lambda has no class file, no need to transform, just return.

      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 transform has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          @Override
          public final byte[] transform(@Nullable final ClassLoader loader, @Nullable final String classFile, final Class<?> classBeingRedefined,
                                        final ProtectionDomain protectionDomain, @NonNull final byte[] classFileBuffer) {
              try {
                  // Lambda has no class file, no need to transform, just return.
      Severity: Minor
      Found in ttl-agent/src/main/java/com/alibaba/ttl3/agent/TtlTransformer.java - About 55 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 updateConstructorDisableInheritable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private void updateConstructorDisableInheritable(@NonNull final CtClass clazz) throws NotFoundException, CannotCompileException {
              for (CtConstructor constructor : clazz.getDeclaredConstructors()) {
                  final CtClass[] parameterTypes = constructor.getParameterTypes();
                  final StringBuilder insertCode = new StringBuilder();
                  for (int i = 0; i < parameterTypes.length; i++) {

      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 updateConstructorDisableInheritable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private void updateConstructorDisableInheritable(@NonNull final CtClass clazz) throws NotFoundException, CannotCompileException {
              for (CtConstructor constructor : clazz.getDeclaredConstructors()) {
                  final CtClass[] parameterTypes = constructor.getParameterTypes();
                  final StringBuilder insertCode = new StringBuilder();
                  for (int i = 0; i < parameterTypes.length; i++) {

      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 updateConstructorDisableInheritable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private void updateConstructorDisableInheritable(@NonNull final CtClass clazz) throws NotFoundException, CannotCompileException {
              for (CtConstructor constructor : clazz.getDeclaredConstructors()) {
                  final CtClass[] parameterTypes = constructor.getParameterTypes();
                  final StringBuilder insertCode = new StringBuilder();
                  for (int i = 0; i < parameterTypes.length; i++) {

      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 updateConstructorDisableInheritable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private void updateConstructorDisableInheritable(@NonNull final CtClass clazz) throws NotFoundException, CannotCompileException {
              for (CtConstructor constructor : clazz.getDeclaredConstructors()) {
                  final CtClass[] parameterTypes = constructor.getParameterTypes();
                  final StringBuilder insertCode = new StringBuilder();
                  for (int i = 0; i < parameterTypes.length; i++) {

      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 doExecuteCallback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          private static void doExecuteCallback(boolean isBefore) {
              // copy TTL Instances to avoid `ConcurrentModificationException`
              // even adjust TTL instances in biz lifecycle callbacks(beforeExecute/afterExecute)
              WeakHashMap<TransmittableThreadLocal<Object>, ?> ttlInstances = new WeakHashMap<TransmittableThreadLocal<Object>, Object>(holder.get());
      
      

      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 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 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 loadExtensionInstances has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

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

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

                  Object afterReplay(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 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 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 loadExtensionInstances has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  static <T> Map<ClassLoader, Set<T>> loadExtensionInstances(
                      ClassLoader classLoader, LinkedHashSet<String> instanceClassNames, Class<T> superType,
                      String foundMsgHead, String failLoadMsgHead
                  ) {
                      Map<ClassLoader, Set<T>> ret = new HashMap<>();

              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

              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

              Severity
              Category
              Status
              Source
              Language