sjsucohort6/amigo-chatbot

View on GitHub
command-processor-service/src/main/java/edu/sjsu/amigo/cp/jobs/MessageProcessorJob.java

Summary

Maintainability
D
1 day
Test Coverage

Method execute has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        try {
            //message = jobdata params.

    Method execute has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        @Override
        public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    
            try {
                //message = jobdata params.

    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 MessageProcessorJob.java has 287 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /*
     * Copyright (c) 2017 San Jose State University.
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal

      Method invoke has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

              public IntentFinder invoke() throws DBException {
                  List<String> contentWordsList = convertMsgToWordsList(content);
                  // Looking up by hardcoded provider aws.
                  // TODO remove hardcoding and fetch all providers (not by ID).
                  List<Provider> providers = providerDAO.fetchById(new ArrayList<String>() {{

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

          private void sendMessageToUser(String userEmail, SlackSession session, String channelId, String message) {
              if (channelId != null && !channelId.trim().isEmpty()) {
                  SlackChannel channel = session.findChannelById(channelId);
                  session.sendMessage(channel, message);
              } else {

      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

              public IntentFinder(ProviderDAO providerDAO, String content, String messageIntent, String commandStr, String dockerImage, String providerName) {
                  this.providerDAO = providerDAO;
                  this.content = content;
                  this.messageIntent = messageIntent;
                  this.commandStr = commandStr;
      msg-common/src/main/java/edu/sjsu/amigo/mp/model/Message.java on lines 81..88

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

      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

      Wrong lexicographical order for 'java.util.Date' import. Should be before 'org.quartz.JobExecutionException'.
      Open

      import java.util.Date;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      '}' at column 17 should be alone on a line.
      Open

                      }});

      Checks the placement of right curly braces ('}') for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue#5945.For right curly brace of enum constant please follow issue#7519.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Wrong lexicographical order for 'java.io.IOException' import. Should be before 'org.quartz.JobExecutionException'.
      Open

      import java.io.IOException;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 105).
      Open

                      // Only process the message if the requestID in the message is unique and seen first time

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      '}' at column 17 should be alone on a line.
      Open

                      }});

      Checks the placement of right curly braces ('}') for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue#5945.For right curly brace of enum constant please follow issue#7519.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 124).
      Open

                      String ackMessage = "No intent found for message. Attempting to execute the message as is on aws provider.";

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      '}' at column 13 should be alone on a line.
      Open

                  }});

      Checks the placement of right curly braces ('}') for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue#5945.For right curly brace of enum constant please follow issue#7519.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Wrong lexicographical order for 'java.text.MessageFormat' import. Should be before 'org.quartz.JobExecutionException'.
      Open

      import java.text.MessageFormat;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Wrong lexicographical order for 'java.util.Arrays' import. Should be before 'org.quartz.JobExecutionException'.
      Open

      import java.util.Arrays;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Wrong lexicographical order for 'java.util.logging.Level' import. Should be before 'org.quartz.JobExecutionException'.
      Open

      import java.util.logging.Level;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 142).
      Open

                  IntentFinder intentFinder = new IntentFinder(providerDAO, content, messageIntent, commandStr, dockerImage, providerName).invoke();

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 130).
      Open

                  edu.sjsu.amigo.http.client.Response<User> userResponse = c.get(BASE_URI + RESOURCE_URI + "/" + userEmail, User.class);

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      '}' at column 13 should be alone on a line.
      Open

                  }});

      Checks the placement of right curly braces ('}') for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue#5945.For right curly brace of enum constant please follow issue#7519.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Abbreviation in name 'requestDAO' must contain no more than '2' consecutive capital letters.
      Open

                  RequestDAO requestDAO = (RequestDAO) dbClient.getDAO(RequestDAO.class);

      Validates abbreviations (consecutive capital letters) length in identifier name,it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.

      allowedAbbreviationLength specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.

      ignoreFinal, ignoreStatic, and ignoreStaticFinalcontrol whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered underignoreStaticFinal only, regardless of the values of ignoreFinaland ignoreStatic. So for example if ignoreStatic is true butignoreStaticFinal is false, then static final variables will not be ignored.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 102).
      Open

                  CommandExecutor executor = CloudProviderFactory.getCloudProviderCmdExecutor(providerName);

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Abbreviation in name 'requestDAO' must contain no more than '2' consecutive capital letters.
      Open

                      RequestDAO requestDAO = (RequestDAO) dbClient.getDAO(RequestDAO.class);

      Validates abbreviations (consecutive capital letters) length in identifier name,it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.

      allowedAbbreviationLength specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.

      ignoreFinal, ignoreStatic, and ignoreStaticFinalcontrol whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered underignoreStaticFinal only, regardless of the values of ignoreFinaland ignoreStatic. So for example if ignoreStatic is true butignoreStaticFinal is false, then static final variables will not be ignored.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 103).
      Open

                      SlackMessage slackMessage = JsonUtils.convertJsonToObject(message, SlackMessage.class);

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Abbreviation in name 'providerDAO' must contain no more than '2' consecutive capital letters.
      Open

              public IntentFinder(ProviderDAO providerDAO, String content, String messageIntent, String commandStr, String dockerImage, String providerName) {

      Validates abbreviations (consecutive capital letters) length in identifier name,it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.

      allowedAbbreviationLength specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.

      ignoreFinal, ignoreStatic, and ignoreStaticFinalcontrol whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered underignoreStaticFinal only, regardless of the values of ignoreFinaland ignoreStatic. So for example if ignoreStatic is true butignoreStaticFinal is false, then static final variables will not be ignored.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      '}' at column 21 should be alone on a line.
      Open

                          }});

      Checks the placement of right curly braces ('}') for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue#5945.For right curly brace of enum constant please follow issue#7519.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 112).
      Open

                  Request request = requestWithResponse(requestId, cmd.toString(), response.getMsg(), Status.SUCCESS);

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 101).
      Open

                  envList.add("AWS_SECRET_ACCESS_KEY=" + user.getAwsCredentials().getAwsSecretAccessKey());

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Abbreviation in name 'providerDAO' must contain no more than '2' consecutive capital letters.
      Open

                  ProviderDAO providerDAO = (ProviderDAO) dbClient.getDAO(ProviderDAO.class);

      Validates abbreviations (consecutive capital letters) length in identifier name,it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.

      allowedAbbreviationLength specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.

      ignoreFinal, ignoreStatic, and ignoreStaticFinalcontrol whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered underignoreStaticFinal only, regardless of the values of ignoreFinaland ignoreStatic. So for example if ignoreStatic is true butignoreStaticFinal is false, then static final variables will not be ignored.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      '}' at column 25 should be alone on a line.
      Open

                              }});

      Checks the placement of right curly braces ('}') for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue#5945.For right curly brace of enum constant please follow issue#7519.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 130).
      Open

                  edu.sjsu.amigo.http.client.Response<User> userResponse = c.get(BASE_URI + RESOURCE_URI + "/ria/" + riaId, User.class);

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 101).
      Open

                  envList.add("AWS_SECRET_ACCESS_KEY=" + user.getAwsCredentials().getAwsSecretAccessKey());

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Extra separation in import group before 'java.io.IOException'
      Open

      import java.io.IOException;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Abbreviation in name 'providerDAO' must contain no more than '2' consecutive capital letters.
      Open

              private ProviderDAO providerDAO;

      Validates abbreviations (consecutive capital letters) length in identifier name,it also allows to enforce camel case naming. Please read more atGoogle Style Guideto get to know how to avoid long abbreviations in names.

      allowedAbbreviationLength specifies how many consecutive capital letters areallowed in the identifier.A value of 3 indicates that up to 4 consecutive capital letters are allowed,one after the other, before a violation is printed. The identifier 'MyTEST' would beallowed, but 'MyTESTS' would not be.A value of 0 indicates that only 1 consecutive capital letter is allowed. Thisis what should be used to enforce strict camel casing. The identifier 'MyTest' wouldbe allowed, but 'MyTEst' would not be.

      ignoreFinal, ignoreStatic, and ignoreStaticFinalcontrol whether variables with the respective modifiers are to be ignored.Note that a variable that is both static and final will always be considered underignoreStaticFinal only, regardless of the values of ignoreFinaland ignoreStatic. So for example if ignoreStatic is true butignoreStaticFinal is false, then static final variables will not be ignored.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 110).
      Open

                          Request request = requestWithResponse(requestId, content, e.getMessage(), Status.FAILURE);

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 106).
      Open

          private Request requestWithResponse(String requestId, String cmd, String responseMsg, Status status) {

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Wrong lexicographical order for 'java.util.List' import. Should be before 'org.quartz.JobExecutionException'.
      Open

      import java.util.List;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      '}' at column 21 should be alone on a line.
      Open

                          }});

      Checks the placement of right curly braces ('}') for code blocks.This check supports if-else, try-catch-finally blocks, while-loops, for-loops,method definitions, class definitions, constructor definitions,instance, static initialization blocks, annotation definitions and enum definitions.For right curly brace of expression blocks of arrays, lambdas and class instancesplease follow issue#5945.For right curly brace of enum constant please follow issue#7519.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 152).
      Open

              public IntentFinder(ProviderDAO providerDAO, String content, String messageIntent, String commandStr, String dockerImage, String providerName) {

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Wrong lexicographical order for 'java.util.ArrayList' import. Should be before 'org.quartz.JobExecutionException'.
      Open

      import java.util.ArrayList;

      Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 110).
      Open

          private void sendMessageToUser(String userEmail, SlackSession session, String channelId, String message) {

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      Line is longer than 100 characters (found 119).
      Open

           * This is a method object of common code for finding intent of the message for either type of bots - slack or RIA.

      Checks for long lines.

      Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

      This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

      There are no issues that match your filters.

      Category
      Status