laviua/komock

View on GitHub

Showing 28 of 28 total issues

Method register has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    override fun register(properties: ProxyConfigProperties) {
        val httpServerProp: HttpServerProperties = properties.httpServer

        val router = if (httpServerProp.ssl.enabled) {
            SecuredMockServer(httpServerProp)

    Method register has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        override fun register(properties: ConsulAgentProperties) {
            val clientRegistrar = ConsulClient(properties.consulHost, properties.consulPort)
            log.debug("Found: ${properties.services.size} consul services")
            for (consulService in properties.services) {
                if (consulService.enabled) {

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

              val httpClient = HttpClients.custom()
                      .setSSLContext(SSLContextBuilder().loadTrustMaterial(null) { _, _ -> true }.build())
                      .setSSLHostnameVerifier(NoopHostnameVerifier())
                      .build()
      komock-core/src/main/kotlin/ua/com/lavi/komock/http/handler/callback/CallbackHandlerImpl.kt on lines 34..37

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

      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

              try {
                  router.start()
              } catch (e: BindException) {
                  log.warn(e.message + ": ${httpServerProp.host}, port: ${httpServerProp.port}", e)
                  return
      komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/http/HttpServerRegistrar.kt on lines 41..46
      komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/spring/SpringConfigRegistrar.kt on lines 42..47

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

      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

              try {
                  mockServer.start()
              } catch (e: BindException) {
                  log.warn(e.message + ": ${properties.host}, port: ${properties.port}", e)
                  return
      komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/proxy/ProxyForwarder.kt on lines 48..53
      komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/spring/SpringConfigRegistrar.kt on lines 42..47

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

      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

              try {
                  router.start()
              } catch (e: BindException) {
                  log.warn(e.message + ": ${httpServerProp.host}, port: ${httpServerProp.port}", e)
                  return
      komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/http/HttpServerRegistrar.kt on lines 41..46
      komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/proxy/ProxyForwarder.kt on lines 48..53

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

      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

                      val httpClient = HttpClients.custom()
                              .setSSLContext(SSLContextBuilder().loadTrustMaterial(null) { _, _ -> true }.build())
                              .setSSLHostnameVerifier(NoopHostnameVerifier())
                              .build()
      komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/proxy/ProxyForwarder.kt on lines 55..58

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

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

          override fun register(properties: SpringConfigProperties) {
              val httpServerProp: HttpServerProperties = properties.httpServer
      
              val router = if (httpServerProp.ssl.enabled) {
                  SecuredMockServer(httpServerProp)

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

                anyRequest.config = RequestConfig.custom()
                        .setConnectTimeout(callbackProperties.connectTimeout)
                        .setConnectionRequestTimeout(callbackProperties.connectionRequestTimeout)
                        .setSocketTimeout(callbackProperties.socketTimeout)
                        .build()
        komock-core/src/main/kotlin/ua/com/lavi/komock/registrar/proxy/ProxyForwarder.kt on lines 124..128

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

        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

                anyRequest.config = RequestConfig.custom()
                        .setConnectTimeout(properties.connectTimeout)
                        .setConnectionRequestTimeout(properties.connectionRequestTimeout)
                        .setSocketTimeout(properties.socketTimeout)
                        .build()
        komock-core/src/main/kotlin/ua/com/lavi/komock/http/handler/callback/CallbackHandlerImpl.kt on lines 60..64

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

        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

            override fun addVirtualHosts(virtualHosts: List<String>) {
                getContextHandler().addVirtualHosts(virtualHosts.toTypedArray())
                log.info("Added virtual hosts: $virtualHosts")
            }
        komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/AbstractMockServer.kt on lines 103..106

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

        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

            override fun deleteVirtualHosts(virtualHosts: List<String>) {
                getContextHandler().removeVirtualHosts(virtualHosts.toTypedArray())
                log.info("Removed virtual hosts: $virtualHosts")
            }
        komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/AbstractMockServer.kt on lines 98..101

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

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

            fun addRoute(url: String,
                         httpMethod: HttpMethod,
                         responseHandler: ResponseHandler,
                         beforeResponseHandler: BeforeResponseHandler,
                         afterResponseHandler: AfterResponseHandler,

          Method addRoute has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              override fun addRoute(url: String,
                                    httpMethod: HttpMethod,
                                    responseHandler: ResponseHandler,
                                    beforeRouteHandler: BeforeResponseHandler,
                                    afterRouteHandler: AfterResponseHandler,

            Method addRoute has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                fun addRoute(url: String, httpMethod: HttpMethod, responseHandler: ResponseHandler, beforeRouteHandler: BeforeResponseHandler, afterRouteHandler: AfterResponseHandler, callbackHandler: CallbackHandler)
            Severity: Minor
            Found in komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/MockServer.kt - About 45 mins to fix

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

                  fun addRoute(url: String,
                               httpMethod: HttpMethod,
                               responseHandler: ResponseHandler,
                               beforeResponseHandler: BeforeResponseHandler,
                               afterResponseHandler: AfterResponseHandler,
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/AbstractMockServer.kt on lines 155..160
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/MockServer.kt on lines 70..70

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

              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

                  override fun addRoute(url: String,
                                        httpMethod: HttpMethod,
                                        responseHandler: ResponseHandler,
                                        beforeRouteHandler: BeforeResponseHandler,
                                        afterRouteHandler: AfterResponseHandler,
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/MockServer.kt on lines 70..70
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/handler/RoutingTable.kt on lines 21..26

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

              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

                  fun addRoute(url: String, httpMethod: HttpMethod, responseHandler: ResponseHandler, beforeRouteHandler: BeforeResponseHandler, afterRouteHandler: AfterResponseHandler, callbackHandler: CallbackHandler)
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/AbstractMockServer.kt on lines 155..160
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/handler/RoutingTable.kt on lines 21..26

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

              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 3 locations. Consider refactoring.
              Open

                  override fun doHandle(
                          target: String,
                          jettyRequest: org.eclipse.jetty.server.Request,
                          httpServletRequest: HttpServletRequest,
                          httpServletResponse: HttpServletResponse) {
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/handler/AbstractHttpHandler.kt on lines 24..28
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/handler/CaptureHttpHandler.kt on lines 23..26

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

              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 3 locations. Consider refactoring.
              Open

                  override fun doHandle(target: String,
                                        jettyRequest: org.eclipse.jetty.server.Request,
                                        httpServletRequest: HttpServletRequest,
                                        httpServletResponse: HttpServletResponse) {
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/handler/AbstractHttpHandler.kt on lines 24..28
              komock-core/src/main/kotlin/ua/com/lavi/komock/http/server/handler/HttpHandler.kt on lines 12..16

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

              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

              Severity
              Category
              Status
              Source
              Language