phodal/chapi

View on GitHub
chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt

Summary

Maintainability
F
5 days
Test Coverage

File CFullIdentListenerTest.kt has 578 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package chapi.ast.cast

import chapi.domain.core.CodeContainer
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.collect
Severity: Major
Found in chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt - About 1 day to fix

    Class CFullIdentListenerTest has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

    internal class CFullIdentListenerTest {
    
        @Test
        fun allGrammarUnderResources() {
            val content = this::class.java.getResource("/grammar")!!.toURI()
    Severity: Minor
    Found in chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt - About 4 hrs to fix

      Method shouldHandleForMultipleMacroWithId has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Test
          fun shouldHandleForMultipleMacroWithId() {
              val code = """
                  #define TEST_BEGIN(f)                            \
                  static void                                \

        Method shouldHandleForMacroForBrokenCondition has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Test
            fun shouldHandleForMacroForBrokenCondition() {
                val code = """
                    static const ctl_named_node_t stats_mutexes_node[] = {
                    #define OP(mtx) {NAME(#mtx), CHILD(named, stats_mutexes_##mtx)},

          Method shouldSuccessHandleDs has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @Test
              fun shouldSuccessHandleDs() {
                  val code = """
                      // https://stackoverflow.com/questions/12642830/can-i-define-a-function-inside-a-c-structure
                      #include <stdio.h>

            Method allGrammarUnderResources has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                @Test
                fun allGrammarUnderResources() {
                    val content = this::class.java.getResource("/grammar")!!.toURI()
            //        val content = "/Users/phodal/Downloads/redis-unstable/deps/lua"
                    val totalStart = System.currentTimeMillis()

              Method shouldHandleMacroInFunc has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @Test
                  fun shouldHandleMacroInFunc() {
                      val code = """
                          void os_pages_unmap(void *addr, size_t size) {
                              assert(ALIGNMENT_ADDR2BASE(addr, os_page) == addr);

                Method shouldIdentifyFirstFunctionCall has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    @Test
                    fun shouldIdentifyFirstFunctionCall() {
                        val code = """
                            void aX(void);
                            int a1(int param1);

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

                      @Test
                      internal fun shouldIdentifyStructPropertyName() {
                          val code = """
                  struct list_el {
                     int val;
                  chapi-ast-scala/src/test/kotlin/chapi/ast/scalaast/ScalaFullIdentListenerTest.kt on lines 39..52

                  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 249.

                  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

                          val code = """
                              #ifndef HDR_TESTS_H
                              #define HDR_TESTS_H
                              
                              #include "hdr_histogram.h"
                  chapi-ast-kotlin/src/test/kotlin/chapi/ast/kotlinast/KotlinBasicIdentListenerTest.kt on lines 196..218

                  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 152.

                  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

                      @Test
                      internal fun shouldIdentifyForwardDeclaration() {
                          val code = """
                  struct context;
                  
                  
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 155..170

                  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 147.

                  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

                      @Test
                      internal fun shouldIdentifyNestedStruct() {
                          val code = """
                  struct Info{
                      char name[30];
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 217..233

                  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 147.

                  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

                      @Test
                      fun shouldHandleMacroInArray() {
                          val code = """
                              static char log_filename[
                              #ifdef JEMALLOC_PROF
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 596..608

                  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 133.

                  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

                      @Test
                      fun shouldHandleMacroIArrayDefine() {
                          val code = """
                              static char log_filename[
                              #ifdef JEMALLOC_PROF
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 582..594

                  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 133.

                  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

                      @Test
                      internal fun shouldIdentifyStructFunctionPoint() {
                          val code = """
                  struct list_el {
                     int val;
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 143..153

                  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 117.

                  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

                      @Test
                      internal fun shouldIdentifyAnonymousStruct() {
                          val code = """
                  struct {
                     int i;
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 130..141

                  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 117.

                  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

                      @Test
                      fun shouldSupportForAsmBody() {
                          val code = """
                              #define lua_number2int(i,d)   __asm fld d   __asm fistp i
                              """.trimIndent()
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 635..643

                  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 109.

                  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

                      @Test
                      fun shouldSupportMacroStruct() {
                          val code = """
                              #define LUAI_USER_ALIGNMENT_T    union { double u; void *s; long l; }
                              """.trimIndent()
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 625..633

                  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 109.

                  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

                          val code = """
                              #define Protect(x)    { L->savedpc = pc; {x;}; base = L->base; }
                              
                              void hello() {
                                  Protect(luaV_gettable(L, &g, rb, ra));
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 259..272

                  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 93.

                  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

                          val code = """
                              void aX(void);
                              int a1(int param1);
                              int a2(int param1, param2);
                              void a3();
                  chapi-ast-c/src/test/kotlin/chapi/ast/cast/CFullIdentListenerTest.kt on lines 647..658

                  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 93.

                  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

                          val code = """
                              #include <stdio.h>
                              #include <string.h>
                              #include <stdlib.h>
                              #include "redismodule.h"
                  chapi-ast-rust/src/test/kotlin/chapi/ast/rustast/RustFullIdentListenerTest.kt on lines 474..483

                  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 72.

                  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

                  There are no issues that match your filters.

                  Category
                  Status