skofgar/mercury

View on GitHub

Showing 821 of 821 total issues

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

    private void abort(String inboxId, String from, String traceId, String tracePath) {
        AsyncInbox holder = (AsyncInbox) inboxes.get(inboxId);
        if (holder != null) {
            holder.close();
            executor.submit(() -> {
system/platform-core/src/main/java/org/platformlambda/core/models/AsyncMultiInbox.java on lines 71..87

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

    private void abort(String inboxId, String from, String traceId, String tracePath) {
        AsyncMultiInbox holder = (AsyncMultiInbox) inboxes.get(inboxId);
        if (holder != null) {
            holder.close();
            executor.submit(() -> {
system/platform-core/src/main/java/org/platformlambda/core/models/AsyncInbox.java on lines 63..79

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

    private void parseXML(Map<String, Map<String, Integer>> childMap,
                          List<List<String>> kvList, Node node, String parent) {

        String parentPath = normalizeParentPath(parent);
        if (node.getNodeType() == Node.TEXT_NODE) {

    Method getDestinations has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        @SuppressWarnings("unchecked")
        private List<String> getDestinations(Map<String, String> headers) {
            String to = headers.get(TO);
            boolean broadcast = headers.containsKey(BROADCAST);
            String id = headers.get(ID);

      Method setup has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private void setup() throws TimeoutException, IOException {
              ServerPersonality.getInstance().setType(ServerPersonality.Type.RESOURCES);
              Utility util = Utility.getInstance();
              AppConfigReader config = AppConfigReader.getInstance();
              Platform platform = Platform.getInstance();

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

                    for (String p : packages) {
                        List<ClassInfo> endpoints = scanner.getAnnotatedClasses(p, Provider.class);
                        for (ClassInfo info  : endpoints) {
                            log.debug("Scanning {}", info.getName());
                            final Class<?> cls;
        system/rest-spring/src/main/java/org/platformlambda/rest/RestLoader.java on lines 71..89

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

        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

                    for (String p : packages) {
                        List<ClassInfo> endpoints = scanner.getAnnotatedClasses(p, Path.class);
                        for (ClassInfo info : endpoints) {
                            log.debug("Scanning {}", info.getName());
                            final Class<?> cls;
        system/rest-spring/src/main/java/org/platformlambda/rest/RestLoader.java on lines 99..117

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

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

            private boolean startService(String name, List<ClassInfo> services, boolean isConnector) {
                if (name == null) {
                    return false;
                }
                final String type = isConnector? CONNECTOR : SERVICE;

          Method getElement has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              @SuppressWarnings("unchecked")
              private Object getElement(String path, Map<String, Object> map) {
                  if (path == null || map == null || map.isEmpty()) return null;
                  if (map.containsKey(path)) {
                      return map.get(path);

            Method send has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public void send(final EventEnvelope event) throws IOException {
                    String dest = event.getTo();
                    if (dest == null) {
                        throw new IllegalArgumentException(MISSING_ROUTING_PATH);
                    }

              Method eventFromMap has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  @SuppressWarnings("unchecked")
                  private EventEnvelope eventFromMap(Map<String, Object> map) {
                      EventEnvelope event = new EventEnvelope();
                      if (map.containsKey(ID)) {
                          event.setId((String) map.get(ID));

                Method sendResponse has a Cognitive Complexity of 15 (exceeds 5 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));
                        }

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

                    public void cleanupDir(File dir, boolean keep) {
                        if (dir != null && dir.exists() && dir.isDirectory()) {
                            File[] files = dir.listFiles();
                            if (files != null) {
                                for (File f: files) {

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

                    public void outgoing(ServiceQueue dest, EventEnvelope event) throws IOException {
                        if (dest != null && event != null) {
                            event.setEndOfRoute();
                            byte[] payload = event.toBytes();
                            EventBus system = Platform.getInstance().getEventSystem();

                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 load has a Cognitive Complexity of 15 (exceeds 5 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()));

                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 createTopic has a Cognitive Complexity of 15 (exceeds 5 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);
                            }

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

                    @SuppressWarnings("unchecked")
                    private List scan(JsonArray array) {
                        List result = new ArrayList();
                        for (JsonElement o: array) {
                            if (o.isJsonNull()) {

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

                    private void deleteTopic(String topic) {
                        if (topicSubstitution) {
                            if (preAllocatedTopics.get(topic) == null) {
                                throw new IllegalArgumentException("Missing topic substitution for "+topic);
                            }

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

                    @Override
                    public void execute(JobExecutionContext context) {
                        JobDataMap parameters = context.getJobDetail().getJobDataMap();
                        ScheduledJob job = MainScheduler.getJob(parameters.getString(MainScheduler.JOB_ID));
                        if (job != 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 topicPartitions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    private int topicPartitions(String topic) throws TibjmsAdminException {
                        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

                Severity
                Category
                Status
                Source
                Language