mizo0203/hoshiguma-line-bot

View on GitHub

Showing 6 of 16 total issues

Repository has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

public class Repository {

  private static final Logger LOG = Logger.getLogger(Repository.class.getName());
  private final OfyRepository mOfyRepository;
  private final LineRepository mLineRepository;
Severity: Minor
Found in src/main/java/com/mizo0203/hoshiguma/repo/Repository.java - About 2 hrs to fix

    Method onLinePostBack has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      private void onLinePostBack(PostBackEvent event) {
        String[] postBackData = event.getPostBackData().split("\n");
        switch (postBackData[0]) {
          case "data1":
            {
    Severity: Major
    Found in src/main/java/com/mizo0203/hoshiguma/HoshigumaLineBotServlet.java - About 2 hrs to fix

      Function sampleAjax has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function sampleAjax(groupId, userId, displayName) {
          var request = new XMLHttpRequest();
          request.open('POST', '/content', false);
          request.send(JSON.stringify({
              groupId: groupId
      Severity: Minor
      Found in src/main/webapp/liff.js - About 1 hr to fix

        Method post has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          public static void post(URL url, Map<String, String> reqProp, String body, Callback callback) {
            LOG.info("post url:     " + url);
            LOG.info("post reqProp: " + reqProp);
            LOG.info("post body:    " + body);
            HttpURLConnection connection = null;
        Severity: Minor
        Found in src/main/java/com/mizo0203/hoshiguma/util/HttpUtil.java - About 1 hr to fix

          Method onLineWebhook has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            private void onLineWebhook(HttpServletRequest req, HttpServletResponse resp) {
              mRepository = new Repository();
              mUseCase = new UseCase(mRepository);
              try {
                RequestBody requestBody = mRepository.getRequestBody(req);
          Severity: Minor
          Found in src/main/java/com/mizo0203/hoshiguma/HoshigumaLineBotServlet.java - About 25 mins to fix

          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

          Function sampleAjax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function sampleAjax(groupId, userId, displayName) {
              var request = new XMLHttpRequest();
              request.open('POST', '/content', false);
              request.send(JSON.stringify({
                  groupId: groupId
          Severity: Minor
          Found in src/main/webapp/liff.js - About 25 mins to fix

          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