mizo0203/hoshiguma-line-bot

View on GitHub

Showing 16 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

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

          private String getChannelAccessToken() {
            KeyEntity keyEntity = mOfyRepository.loadKeyEntity("ChannelAccessToken");
        
            if (keyEntity == null) {
              keyEntity = new KeyEntity();
        Severity: Major
        Found in src/main/java/com/mizo0203/hoshiguma/repo/Repository.java and 1 other location - About 1 hr to fix
        src/main/java/com/mizo0203/hoshiguma/repo/Repository.java on lines 119..134

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

        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

          private String getChannelSecret() {
            KeyEntity keyEntity = mOfyRepository.loadKeyEntity("ChannelSecret");
        
            if (keyEntity == null) {
              keyEntity = new KeyEntity();
        Severity: Major
        Found in src/main/java/com/mizo0203/hoshiguma/repo/Repository.java and 1 other location - About 1 hr to fix
        src/main/java/com/mizo0203/hoshiguma/repo/Repository.java on lines 102..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 85.

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

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

          /* Copyright 2016 Google Inc.
           *
           * Licensed under the Apache License, Version 2.0 (the "License");
           * you may not use this file except in compliance with the License.
           * You may obtain a copy of the License at
          src/main/java/com/mizo0203/hoshiguma/push_task/CloseTaskServlet.java on lines 1..41

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

          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

          /* Copyright 2016 Google Inc.
           *
           * Licensed under the Apache License, Version 2.0 (the "License");
           * you may not use this file except in compliance with the License.
           * You may obtain a copy of the License at
          src/main/java/com/mizo0203/hoshiguma/push_task/ReminderTaskServlet.java on lines 1..41

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

          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

              try {
                URL url = new URL(MESSAGING_API_REPLY_MESSAGE_URL_STR);
                Map<String, String> reqProp = new HashMap<>();
                reqProp.put("Content-Type", "application/json");
                reqProp.put("Authorization", "Bearer " + channelAccessToken);
          src/main/java/com/mizo0203/hoshiguma/repo/LineRepository.java on lines 88..96

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

          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

              try {
                URL url = new URL(MESSAGING_API_PUSH_MESSAGE_URL_STR);
                Map<String, String> reqProp = new HashMap<>();
                reqProp.put("Content-Type", "application/json");
                reqProp.put("Authorization", "Bearer " + channelAccessToken);
          src/main/java/com/mizo0203/hoshiguma/repo/LineRepository.java on lines 60..68

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

          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

            public void addMemberCandidateDate(SourceData source, Date candidateDate) {
              LineTalkRoomConfig config = getOrCreateLineTalkRoomConfig(source.getSourceId());
              SortedSet<Date> member_candidate_dates =
                  config.member_candidate_dates.computeIfAbsent(source.getUserId(), k -> new TreeSet<>());
              member_candidate_dates.add(candidateDate);
          Severity: Minor
          Found in src/main/java/com/mizo0203/hoshiguma/repo/Repository.java and 1 other location - About 45 mins to fix
          src/main/java/com/mizo0203/hoshiguma/repo/Repository.java on lines 189..195

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

          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

            public void removeMemberCandidateDate(SourceData source, Date candidateDate) {
              LineTalkRoomConfig config = getOrCreateLineTalkRoomConfig(source.getSourceId());
              SortedSet<Date> member_candidate_dates =
                  config.member_candidate_dates.computeIfAbsent(source.getUserId(), k -> new TreeSet<>());
              member_candidate_dates.remove(candidateDate);
          Severity: Minor
          Found in src/main/java/com/mizo0203/hoshiguma/repo/Repository.java and 1 other location - About 45 mins to fix
          src/main/java/com/mizo0203/hoshiguma/repo/Repository.java on lines 181..187

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

          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

              for (int i = 0; i < ret.length; i++) {
                ret[i] = mTranslator.formatDate(candidateDates[i]);
              }
          Severity: Minor
          Found in src/main/java/com/mizo0203/hoshiguma/repo/Repository.java and 1 other location - About 30 mins to fix
          src/main/java/com/mizo0203/hoshiguma/repo/Repository.java on lines 78..80

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

          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

              for (int i = 0; i < ret.length; i++) {
                ret[i] = mTranslator.formatDate(candidateDates[i]);
              }
          Severity: Minor
          Found in src/main/java/com/mizo0203/hoshiguma/repo/Repository.java and 1 other location - About 30 mins to fix
          src/main/java/com/mizo0203/hoshiguma/repo/Repository.java on lines 216..218

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

          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

          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

          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

          Severity
          Category
          Status
          Source
          Language