HashtagsXRep/hashtagsxrep

View on GitHub

Showing 50 of 50 total issues

Method extractData has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

  public void extractData() {
    List<Monitor> monitorList = monitorRepository.getActiveMonitors();

    int extractionRequestsCounter = 0;
    boolean stopByBlockSize;

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

RepositoryConfiguration has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

@Configuration
public class RepositoryConfiguration {

  @Value("${twitter.apiKey}")
  private String apiKey;

    Method extractData has 67 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public void extractData() {
        List<Monitor> monitorList = monitorRepository.getActiveMonitors();
    
        int extractionRequestsCounter = 0;
        boolean stopByBlockSize;

      Method find has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

        public void find(String hashtag) {
          int contents = 0;
          boolean stop = false;
          int calls = 0;
          int maxResults = 100;
      Severity: Minor
      Found in src/integrationTest/java/cat/xarxarepublicana/SearchTweetsMain.java - About 2 hrs 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 resolveDraws has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

        private void resolveDraws(List<Proposal> proposalList) {
          if (proposalList != null && proposalList.size() > 1 && proposalList.get(0).getVotes() == proposalList.get(1)
              .getVotes()) {
            int draws = 1;
            Ranking ranking = rankingRepository.loadRanking();

      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

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

        @Override
        public void publishProposalSavedNotice(ProposalSavedNotice notice) {
          try {
            Map<String, Object> model = new HashMap<>();
            model.put("notice", notice);
      src/main/java/cat/xarxarepublicana/hashtagsxrep/infrastructure/repository/telegram/TelegramNoticeRepository.java on lines 40..62

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

      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

        @Override
        public void publishPollClosedNotice(PollClosedNotice notice) {
          try {
            Map<String, Object> model = new HashMap<>();
            model.put("notice", notice);
      src/main/java/cat/xarxarepublicana/hashtagsxrep/infrastructure/repository/telegram/TelegramNoticeRepository.java on lines 64..86

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

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

        public void restoreSecurityContext(HttpServletRequest request, HttpServletResponse response) {
          if (SecurityContextHolder.getContext().getAuthentication() == null) {
            AuthToken authToken = authCookieService.extractAuthToken(request);
            if (authToken != null) {
              AuthenticationUser authenticationUser = 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

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

        public Proposal(
            String pollId,
            String authorId,
            String authorNickname,
            String hashtag,
      src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/extraction/TwitterExtraction.java on lines 22..41
      src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/monitor/Monitor.java on lines 20..39

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

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

        public TwitterExtraction(
            String monitorId,
            String tweetId,
            String userId,
            String type,
      src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/monitor/Monitor.java on lines 20..39
      src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/poll/Proposal.java on lines 17..36

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

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

        public Monitor(
            String id,
            String authorId,
            String authorNickname,
            Boolean active,
      src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/extraction/TwitterExtraction.java on lines 22..41
      src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/poll/Proposal.java on lines 17..36

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

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

        public void find(String hashtag) {
          int contents = 0;
          boolean stop = false;
          int calls = 0;
          int maxResults = 100;
      Severity: Minor
      Found in src/integrationTest/java/cat/xarxarepublicana/SearchTweetsMain.java - About 1 hr to fix

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

        package cat.xarxarepublicana.hashtagsxrep.domain.report;
        
        public class UserContentResume {
        
          private final Integer tweets;
        src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/ranking/HashtagScore.java on lines 1..32

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

        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

        package cat.xarxarepublicana.hashtagsxrep.domain.ranking;
        
        public class HashtagScore {
        
          private final String hashtag;
        src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/report/UserContentResume.java on lines 1..32

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

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

          @RequestMapping("/error")
          public String handleError(HttpServletRequest request) {
            Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
            if (status != null) {
              Integer statusCode = Integer.valueOf(status.toString());

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

          public void restoreSecurityContext(HttpServletRequest request, HttpServletResponse response) {
            if (SecurityContextHolder.getContext().getAuthentication() == null) {
              AuthToken authToken = authCookieService.extractAuthToken(request);
              if (authToken != null) {
                AuthenticationUser authenticationUser = null;

          Method createFromMonitorExtractedTweet has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public TwitterExtraction createFromMonitorExtractedTweet(Monitor monitor, Tweet tweet) {
              final Interaction interaction;
              if (tweet.getQuotedStatus() != null) {
                interaction = new Interaction(TwitterExtraction.TYPE_QUOTE,
                                              tweet.getQuotedStatus().getIdStr(),

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

            package cat.xarxarepublicana.hashtagsxrep.infrastructure.security;
            
            public class AuthToken {
            
              private final String userId;
            src/main/java/cat/xarxarepublicana/hashtagsxrep/domain/notice/ProposalSavedNotice.java on lines 1..26

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

            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

            package cat.xarxarepublicana.hashtagsxrep.domain.notice;
            
            public class ProposalSavedNotice {
            
              private final String authorNickname;
            src/main/java/cat/xarxarepublicana/hashtagsxrep/infrastructure/security/AuthToken.java on lines 1..26

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

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

              private void resolveDraws(List<Proposal> proposalList) {
                if (proposalList != null && proposalList.size() > 1 && proposalList.get(0).getVotes() == proposalList.get(1)
                    .getVotes()) {
                  int draws = 1;
                  Ranking ranking = rankingRepository.loadRanking();
              Severity
              Category
              Status
              Source
              Language