skofgar/mercury

View on GitHub

Showing 821 of 821 total issues

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

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

        @Override
        public Object handleEvent(Map<String, String> headers, Object body, int instance) throws IOException {
            if (body instanceof EventEnvelope) {
                EventEnvelope input = (EventEnvelope) body;
                PostOffice po = PostOffice.getInstance();

      Method submit has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected void submit(String type, HttpServletRequest request, HttpServletResponse response) throws IOException {
              final String myOrigin = Platform.getInstance().getOrigin();
              final String appOrigin = request.getHeader(APP_INSTANCE);
              if (appOrigin == null) {
                  if (protectEndpoint && !isIntranetAddress(request)) {

        Method removeExpiredFiles has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            private void removeExpiredFiles() {
                /*
                 * The temporary download directory is used as a buffer to relay incoming files from HTTP requests.
                 * They are removed immediately after relay.
                 *

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

            public AssignedRoute getRouteInfo(String method, String url) {
                Utility util = Utility.getInstance();
                StringBuilder sb = new StringBuilder();
                List<String> input = util.split(url, "/");
                for (String p: input) {

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

            public Date str2date(String str, boolean throwException) {
                if (isDigits(str)) {
                    return new Date(Long.parseLong(str));
                }
                /*

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

            public EventEnvelope request(final EventEnvelope event, long timeout) throws IOException, TimeoutException, AppException {
                if (event == null) {
                    throw new IllegalArgumentException(MISSING_EVENT);
                }
                String dest = event.getTo();

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

            public String getEnvVariable(String ref) {
                long threadId = Thread.currentThread().getId();
                List<String> observed = TEMP_CONFIG.getOrDefault(threadId, new ArrayList<>());
                if (ref != null && ref.startsWith("${") && ref.endsWith("}")) {
                    String key = ref.substring(2, ref.length()-1).trim();

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

            public List<String> split(String str, String chars, boolean empty) {
                List<String> rv = new ArrayList<>();
                if (str == null || chars == null) return rv;
                StringBuilder sb = new StringBuilder();
                boolean found;

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

            public String filteredServiceName(String name) {
                String str = name.toLowerCase();
                boolean dot = true;
                StringBuilder sb = new StringBuilder();
                for (int i=0; i < str.length(); i++) {

        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 16 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            public Object handleEvent(Map<String, String> headers, Object body, int instance)
                    throws AppException, TimeoutException {
                String type = headers.getOrDefault(TYPE, INFO);
                Platform platform = Platform.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 unpack has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            @SuppressWarnings("unchecked")
            public Object unpack(byte[] bytes) throws IOException  {
                Object result = unpack(bytes, 0, bytes.length);
                if (result instanceof Map) {
                    // is this an encoded payload

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

            private TypedPayload encodeList(List<Object> objects, boolean binary) {
                boolean primitive = false;
                String pojoInside = null;
                List<Object> list = new ArrayList<>();
                for (Object o: objects) {

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

            @Override
            public void unsubscribe(String topic, int partition) throws IOException {
                String topicPartition = (topic + (partition < 0? "" : "." + partition)).toLowerCase();
                Platform platform = Platform.getInstance();
                if (platform.hasRoute(topicPartition) && subscribers.containsKey(topicPartition)) {
        connectors/adapters/hazelcast/hazelcast-connector/src/main/java/org/platformlambda/hazelcast/services/PubSubManager.java on lines 219..236
        connectors/adapters/tibco/tibco-connector/src/main/java/org/platformlambda/tibco/services/PubSubManager.java on lines 256..273

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

        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
            public void unsubscribe(String topic, int partition) throws IOException {
                String topicPartition = (topic + (partition < 0? "" : "." + partition)).toLowerCase();
                Platform platform = Platform.getInstance();
                if (platform.hasRoute(topicPartition) && subscribers.containsKey(topicPartition)) {
        connectors/adapters/activemq/activemq-connector/src/main/java/org/platformlambda/activemq/services/PubSubManager.java on lines 274..291
        connectors/adapters/tibco/tibco-connector/src/main/java/org/platformlambda/tibco/services/PubSubManager.java on lines 256..273

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

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

            @SuppressWarnings("unchecked")
            private List<String> getVirtualTopics(Map<String, Object> connections) {
                Map<String, String> topics = TopicController.getAssignedTopics();
                Map<String, List<String>> members = new HashMap<>();
                for (String t: topics.keySet()) {

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

            @Override
            public void unsubscribe(String topic, int partition) throws IOException {
                String topicPartition = (topic + (partition < 0? "" : "." + partition)).toLowerCase();
                Platform platform = Platform.getInstance();
                if (platform.hasRoute(topicPartition) && subscribers.containsKey(topicPartition)) {
        connectors/adapters/activemq/activemq-connector/src/main/java/org/platformlambda/activemq/services/PubSubManager.java on lines 274..291
        connectors/adapters/hazelcast/hazelcast-connector/src/main/java/org/platformlambda/hazelcast/services/PubSubManager.java on lines 219..236

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

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

            public static Map<String, String> getTopicSubstitution() throws IOException {
                if (topicReplacements == null) {
                    Utility util = Utility.getInstance();
                    Map<String, String> result = new HashMap<>();
                    AppConfigReader config = 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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

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

        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 16 (exceeds 5 allowed). Consider refactoring.
        Open

            @Override
            @SuppressWarnings("unchecked")
            public Object handleEvent(Map<String, String> headers, Object body, int instance) throws Exception {
                PostOffice po = PostOffice.getInstance();
                String myOrigin = Platform.getInstance().getOrigin();

        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