skofgar/mercury

View on GitHub

Showing 821 of 821 total issues

Method validServiceName has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public boolean validServiceName(String str) {
        if (str == null || str.length() == 0) return false;
        if (str.startsWith(".") || str.startsWith("_") || str.startsWith("-")
                || str.contains("..")
                || str.endsWith(".") || str.endsWith("_") || str.endsWith("-")) return false;

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

    @Override
    public void publish(String topic, int partition, Map<String, String> headers, Object body) throws IOException {
        ConnectorConfig.validateTopicName(topic);
        Utility util = Utility.getInstance();
        Map<String, String> eventHeaders = headers == null? new HashMap<>() : headers;

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

    private boolean hasRsvpRights() {
        Utility util = Utility.getInstance();
        long now = System.currentTimeMillis();
        String me = Platform.getInstance().getOrigin();
        // remove expired bids

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

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

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

    public static void clearStalledConnection() {
        List<String> pendingList = new ArrayList<>(pendingConnections.keySet());
        long now = System.currentTimeMillis();
        for (String route: pendingList) {
            WsMetadata md = connections.get(route);

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

    private String getHeaderCase(String header) {
        StringBuilder sb = new StringBuilder();
        List<String> parts = Utility.getInstance().split(header, "-");
        for (String p: parts) {
            sb.append(p.substring(0, 1).toUpperCase());
system/platform-core/src/main/java/org/platformlambda/automation/util/SimpleHttpUtility.java on lines 84..95

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

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

    public int bytes2int(byte[] b) {
        if (b == null || b.length != 4) return -1;
        int val = 0;
        for (int i=0 ; i < 4; ++i) {
            val *= 256L ;
system/platform-core/src/main/java/org/platformlambda/core/util/Utility.java on lines 544..555

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

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

    public String getHeaderCase(String header) {
        StringBuilder sb = new StringBuilder();
        List<String> parts = Utility.getInstance().split(header, "-");
        for (String p: parts) {
            sb.append(p.substring(0, 1).toUpperCase());
system/platform-core/src/main/java/org/platformlambda/automation/services/ServiceGateway.java on lines 578..589

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

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

    public long bytes2long(byte[] b) {
        if (b == null || b.length != 8) return -1;
        long val = 0;
        for (int i=0 ; i < 8; ++i) {
            val *= 256L ;
system/platform-core/src/main/java/org/platformlambda/core/util/Utility.java on lines 499..510

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

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

    public void sendResponse(String type, String requestId, HttpServerRequest request, int status, String message) {
        ServiceGateway.closeContext(requestId);
        String accept = request.getHeader(ACCEPT);
        if (accept == null) {
            accept = "?";

    Method load has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @SuppressWarnings("unchecked")
        public void load(String path) throws IOException {
            InputStream in = null;
            if (path.startsWith(CLASSPATH)) {
                in = ConfigReader.class.getResourceAsStream(path.substring(CLASSPATH.length()));

      Method createTopic has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void createTopic(String topic, int partitions) throws IOException {
              if (topicSubstitution) {
                  if (preAllocatedTopics.get(topic) == null) {
                      throw new IllegalArgumentException("Missing topic substitution for "+topic);
                  }

        Method getEnv has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private Map<String, Object> getEnv() {
                Map<String, Object> result = new HashMap<>();
                Utility util = Utility.getInstance();
                AppConfigReader reader = AppConfigReader.getInstance();
                List<String> envVars = util.split(reader.getProperty(SHOW_ENV, ""), ", ");

          Method start has 42 lines of code (exceeds 25 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();

            Method start has 42 lines of code (exceeds 25 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();

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

                  private void suspendResume(String requestId, HttpServerRequest request) {
                      PostOffice po = PostOffice.getInstance();
                      SimpleHttpUtility httpUtil = SimpleHttpUtility.getInstance();
                      String origin = request.getHeader(APP_INSTANCE);
                      if (origin == null) {

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

                    public static void sendResponse(HttpServletResponse response, int status, String message, String uri, String accept)
                            throws IOException {
                        if (template == null) {
                            template = util.stream2str(HttpErrorHandler.class.getResourceAsStream(TEMPLATE));
                        }

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

                      @Override
                      public Object handleEvent(Map<String, String> headers, Object body, int instance) throws Exception {
                          if (headers.containsKey(TYPE)) {
                              if (LIST.equals(headers.get(TYPE))) {
                                  return listTopics();

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

                        @Override
                        public Object handleEvent(Map<String, String> headers, Object body, int instance) throws Exception {
                            if (headers.containsKey(TYPE)) {
                                if (LIST.equals(headers.get(TYPE))) {
                                    return listTopics();

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

                          private ConfigReader getConfig() throws IOException {
                              AppConfigReader reader = AppConfigReader.getInstance();
                              List<String> paths = Utility.getInstance().split(reader.getProperty("cron.yaml",
                                      "file:/tmp/config/cron.yaml, classpath:/cron.yaml"), ", ");
                              for (String p: paths) {
                      system/platform-core/src/main/java/org/platformlambda/core/system/AppStarter.java on lines 300..315

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language