skofgar/mercury

View on GitHub

Showing 577 of 821 total issues

Method startConsumers has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    private void startConsumers() throws IOException {
        if (topicPartition != null && topicPartition.contains("-")) {
            AppConfigReader config = AppConfigReader.getInstance();
            Platform platform = Platform.getInstance();
            PostOffice po = PostOffice.getInstance();

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

File ElasticQueue.java has 351 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*

    Copyright 2018-2023 Accenture Technology

    Licensed under the Apache License, Version 2.0 (the "License");

    File CryptoApi.java has 348 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
    
        Copyright 2018-2023 Accenture Technology
    
        Licensed under the Apache License, Version 2.0 (the "License");

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

          @Override
          @SuppressWarnings("unchecked")
          public Object handleEvent(Map<String, String> headers, Object body, int instance) throws IOException {
              PostOffice po = PostOffice.getInstance();
              String rxPath, token, txPath;

        File TopicController.java has 344 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
        
            Copyright 2018-2023 Accenture Technology
        
            Licensed under the Apache License, Version 2.0 (the "License");

          Method run has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
          Open

                  @Override
                  public void run() {
                      long t1 = 0;
                      long t2 = System.currentTimeMillis();
                      while (normal) {

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

              public synchronized void startCloudServices() {
                  if (!Platform.cloudServicesStarted) {
                      // guarantee to execute once
                      Platform.cloudServicesStarted = true;
                      AppConfigReader reader = AppConfigReader.getInstance();

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

              public void process(EventEnvelope event) throws IOException {
                  /*
                   * The original sender is encoded in the extra field as a routing tag.
                   * It's value is in the format: "token_id->reply_to".
                   *

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

              private List<String> getTopics() throws IOException {
                  Utility util = Utility.getInstance();
                  PubSub ps = PubSub.getInstance();
                  List<String> topics = ps.list();
                  if (topics.size() > 1) {

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

              @Override
              public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
                  if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) {
                      HttpServletRequest req = (HttpServletRequest) request;
                      HttpServletResponse res = (HttpServletResponse) response;

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

              private int topicPartitions(String topic) throws Exception {
                  if (topicSubstitution) {
                      int n = 0;
                      while (preAllocatedTopics.containsKey(topic+"."+n)) {
                          n++;

          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

          File PubSubManager.java has 321 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /*
          
              Copyright 2018-2023 Accenture Technology
          
              Licensed under the Apache License, Version 2.0 (the "License");

            Method run has 91 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    @Override
                    public void run() {
                        log.info("RSVP processor started");
                        Runtime.getRuntime().addShutdownHook(new Thread(this::shutdown));
            
            

              Method onStartup has 90 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @Override
                  public void onStartup(ServletContext context) {
              
                      SimpleClassScanner scanner = SimpleClassScanner.getInstance();
                      Set<String> packages = scanner.getPackages(false);

                Method loadHeaderEntry has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                Open

                    @SuppressWarnings("unchecked")
                    private void loadHeaderEntry(Map<String, Object> entry, boolean isRequest) {
                        String id = (String) entry.get(ID);
                        Object go = isRequest? entry.get(REQUEST) : entry.get(RESPONSE);
                        if (go instanceof Map) {

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

                    private String safeXmlKey(String str) {
                        boolean valid = true;
                        for (int i=0; i < str.length(); i++) {
                            char c = str.charAt(i);
                            if (c >= '0' && c <= '9') continue;

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

                    private void handleBytes(Map<String, String> headers, byte[] payload) throws IOException {
                        String route = headers.get(WsEnvelope.ROUTE);
                        PostOffice po = PostOffice.getInstance();
                        WsMetadata md = connections.get(route);
                        if (md != 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

                PubSub has 29 methods (exceeds 20 allowed). Consider refactoring.
                Open

                public class PubSub {
                    private static final Logger log = LoggerFactory.getLogger(PubSub.class);
                    private static final String SYSTEM = "system";
                    private static final ConcurrentMap<String, PubSub> instances = new ConcurrentHashMap<>();
                    private final ConcurrentMap<String, SubscriberDetails> currentSubscribers = new ConcurrentHashMap<>();

                  Method run has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
                  Open

                          @Override
                          public void run() {
                              final AppConfigReader config = AppConfigReader.getInstance();
                              final Utility util = Utility.getInstance();
                              final long timeout = util.str2long(config.getProperty("websocket.idle.timeout", "60"));

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

                      @SuppressWarnings("unchecked")
                      public <T> T readValue(Object fromValue, Class<T> toValueType) {
                          if (fromValue == null || toValueType == null) {
                              return 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

                  Severity
                  Category
                  Status
                  Source
                  Language