skofgar/mercury

View on GitHub

Showing 821 of 821 total issues

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

    private ConfigReader getRestConfig() throws IOException {
        AppConfigReader reader = AppConfigReader.getInstance();
        List<String> paths = Utility.getInstance().split(reader.getProperty("rest.automation.yaml",
                "file:/tmp/config/rest.yaml, classpath:/rest.yaml"), ", ");
        for (String p: paths) {
extensions/simple-scheduler/src/main/java/org/platformlambda/quartz/MainScheduler.java on lines 192..207

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

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

    @Override
    public Object handleEvent(Map<String, String> headers, Object body, int instance) throws IOException {

        PostOffice po = PostOffice.getInstance();
        String route;

    Method getConnection has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static synchronized Connection getConnection(String domain, Properties properties) throws Exception {
            Connection connection = allConnections.get(domain);
            if (connection == null) {
                final ConnectionFactory factory;
                final boolean jndi = "true".equalsIgnoreCase(properties.getProperty(JNDI));

      Method sendEvent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void sendEvent(String topic, int partition, List<Header> headers, byte[] payload) {
              Utility util = Utility.getInstance();
              final String realTopic;
              final int realPartition;
              String virtualTopic = topic + (partition < 0? "" : "." + partition);

        Method handleEvent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @Override
            @SuppressWarnings("unchecked")
            public Object handleEvent(Map<String, String> headers, Object body, int instance) throws Exception {
                if (INFO.equals(headers.get(TYPE))) {
                    Map<String, Object> result = new HashMap<>();

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

                  if (accept == null) {
                      contentType = MediaType.APPLICATION_JSON;
                  } else if (accept.contains(MediaType.TEXT_HTML)) {
                      contentType = MediaType.TEXT_HTML;
                  } else if (accept.contains(MediaType.APPLICATION_XML)) {
          system/rest-spring/src/main/java/org/platformlambda/rest/exception/RestExceptionHandler.java on lines 87..97

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

          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

                  if (accept == null) {
                      contentType = MediaType.APPLICATION_JSON;
                  } else if (accept.contains(MediaType.TEXT_HTML)) {
                      contentType = MediaType.TEXT_HTML;
                  } else if (accept.contains(MediaType.APPLICATION_XML)) {
          system/rest-spring/src/main/java/org/platformlambda/spring/system/HttpErrorHandler.java on lines 109..119

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

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

              public void waitForProvider(String provider, int seconds) throws TimeoutException {
                  if (!hasRoute(provider)) {
                      int waitTime = Math.max(2, seconds);
                      int waitCycle = waitTime / 2;
                      int count = 0;

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

              @SuppressWarnings("unchecked")
              public List<String> search(String route, boolean remoteOnly) {
                  Platform platform = Platform.getInstance();
                  String actualRoute = substituteRouteIfAny(route);
                  if (!remoteOnly && platform.hasRoute(actualRoute)) {

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

              public EventEnvelope setHeader(String key, Object value) {
                  if (key != null) {
                      String v;
                      // null value is transported as an empty string
                      if (value == null) {

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

              @SuppressWarnings("unchecked")
              public AsyncHttpRequest setQueryParameter(String key, Object value) {
                  if (key != null) {
                      if (value instanceof String) {
                          this.queryParams.put(key.toLowerCase(), 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 close has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public void close() {
                  if (!isClosed()) {
                      if (dbEnv != null && !dbEnv.isClosed()) {
                          if (readCounter < writeCounter && writeCounter > MEMORY_BUFFER) {

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

              @SuppressWarnings("unchecked")
              public Object getBody() {
                  if (!encoded) {
                      if (type == null) {
                          setBody(body);

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

                  @Override
                  public void run() {
                      final long INTERVAL = 20 * 1000;
                      final long IDLE = 60 * 1000;
                      long t0 = System.currentTimeMillis();

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

              public void start() throws IOException {
                  final boolean requireInitialization = offset == INITIALIZE;
                  if (requireInitialization) {
                      ServiceLifeCycle initialLoad = new ServiceLifeCycle(topic, partition, INIT_TOKEN);
                      initialLoad.start();

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

              public static synchronized Properties getKafkaProperties(String location) {
                  // default location is cloud.client.properties
                  Properties properties = allProperties.get(location);
                  if (properties == null) {
                      properties = new Properties();

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

              public boolean isZero(String number) {
                  if (number != null && !number.isEmpty()) {
                      if (number.startsWith("0E")) {
                          /*
                           * scientific notation of zero

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

              public void start() throws IOException {
                  final boolean requireInitialization = offset == INITIALIZE;
                  if (requireInitialization) {
                      ServiceLifeCycle initialLoad = new ServiceLifeCycle(topic, partition, INIT_TOKEN);
                      initialLoad.start();

          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

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

                                          try {
                                              po.send(event);
                                              // copying to secondary services if any
                                              if (evt.services.size() > 1) {
                                                  for (String secondary : evt.services) {
          system/platform-core/src/main/java/org/platformlambda/automation/services/ServiceGateway.java on lines 506..521

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

          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

                      try {
                          po.send(event);
                          // copying to secondary services if any
                          if (requestEvent.services.size() > 1) {
                              for (String secondary : requestEvent.services) {
          system/platform-core/src/main/java/org/platformlambda/automation/services/AuthInterceptor.java on lines 82..98

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

          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