topic2k/pygcgen

View on GitHub

Showing 48 of 48 total issues

File generator.py has 926 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

from __future__ import division, print_function

import copy
Severity: Major
Found in pygcgen/generator.py - About 2 days to fix

    Generator has 52 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Generator(object):
        """
        A Generator responsible for all logic, related with
        change log generation from ready-to-parse issues.
        """
    Severity: Major
    Found in pygcgen/generator.py - About 7 hrs to fix

      File options_parser.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      # -*- coding: utf-8 -*-
      
      from __future__ import print_function
      
      import argparse
      Severity: Minor
      Found in pygcgen/options_parser.py - About 4 hrs to fix

        File fetcher.py has 310 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        
        from __future__ import absolute_import, division, print_function
        
        import os
        Severity: Minor
        Found in pygcgen/fetcher.py - About 3 hrs to fix

          Function fetch_events_async has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
          Open

              def fetch_events_async(self, issues, tag_name):
                  """
                  Fetch events for all issues and add them to self.events
          
                  :param list issues: all issues
          Severity: Minor
          Found in pygcgen/fetcher.py - About 3 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

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

                          if is_labels:
                              is_lbls = set(l["name"] for l in is_labels)
                              if is_lbls.intersection(set(sect_labels)):
                                  sections_a[section].append(issue)
                                  added_issues.append(issue)
          Severity: Major
          Found in pygcgen/generator.py and 1 other location - About 3 hrs to fix
          pygcgen/generator.py on lines 614..619

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

          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

                          if pr_labels:
                              pr_lbls = set(l["name"] for l in pr_labels)
                              if pr_lbls.intersection(set(sect_labels)):
                                  sections_a[section].append(pr)
                                  added_pull_requests.append(pr)
          Severity: Major
          Found in pygcgen/generator.py and 1 other location - About 3 hrs to fix
          pygcgen/generator.py on lines 598..603

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

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

              def parse_options(self, options):
                  parser = argparse.ArgumentParser(
                      description='Fully automate changelog generation.',
                  )
          
          
          Severity: Major
          Found in pygcgen/options_parser.py - About 2 hrs to fix

            Function fetch_closed_issues_and_pr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch_closed_issues_and_pr(self):
                    """
                    This method fetches all closed issues and separate them to
                    pull requests and pure issues (pull request is kind of issue
                    in term of GitHub).
            Severity: Minor
            Found in pygcgen/fetcher.py - 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

            Cyclomatic complexity is too high in method fetch_closed_issues_and_pr. (11)
            Open

                def fetch_closed_issues_and_pr(self):
                    """
                    This method fetches all closed issues and separate them to
                    pull requests and pure issues (pull request is kind of issue
                    in term of GitHub).
            Severity: Minor
            Found in pygcgen/fetcher.py by radon

            Cyclomatic Complexity

            Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

            Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

            Construct Effect on CC Reasoning
            if +1 An if statement is a single decision.
            elif +1 The elif statement adds another decision.
            else +0 The else statement does not cause a new decision. The decision is at the if.
            for +1 There is a decision at the start of the loop.
            while +1 There is a decision at the while statement.
            except +1 Each except branch adds a new conditional path of execution.
            finally +0 The finally block is unconditionally executed.
            with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
            assert +1 The assert statement internally roughly equals a conditional statement.
            Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
            Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

            Source: http://radon.readthedocs.org/en/latest/intro.html

            Function parse_options has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_options(self, options):
                    parser = argparse.ArgumentParser(
                        description='Fully automate changelog generation.',
                    )
            
            
            Severity: Minor
            Found in pygcgen/options_parser.py - About 1 hr 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 fetch_tags_dates has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch_tags_dates(self):
                    """ Async fetching of all tags dates. """
            
                    if self.options.verbose:
                        print(
            Severity: Minor
            Found in pygcgen/generator.py - About 1 hr 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 filter_merged_pull_requests has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def filter_merged_pull_requests(self, pull_requests):
                    """
                    This method filter only merged PR and fetch missing required
                    attributes for pull requests. Using merged date is more correct
                    than closed date.
            Severity: Minor
            Found in pygcgen/generator.py - About 1 hr 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 detect_actual_closed_dates has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def detect_actual_closed_dates(self, issues, kind):
                    """
                    Find correct closed dates, if issues was closed by commits.
            
                    :param list issues: issues to check
            Severity: Minor
            Found in pygcgen/generator.py - About 1 hr 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 parse_by_sections_for_issues has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_by_sections_for_issues(self, issues, sections_a, issues_a):
                    for section, sect_labels in self.options.sections.items():
                        added_issues = []
                        for issue in issues:
                            is_labels = issue.get('labels')
            Severity: Minor
            Found in pygcgen/generator.py - About 1 hr 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 parse_by_sections_for_pr has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_by_sections_for_pr(self, pull_requests, sections_a):
                    for section, sect_labels in self.options.sections.items():
                        added_pull_requests = []
                        for pr in pull_requests:
                            pr_labels = pr.get('labels')
            Severity: Minor
            Found in pygcgen/generator.py - About 1 hr 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 convert_value has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def convert_value(value, option_name):
                    if option_name in KNOWN_ARRAY_KEYS:
                        val = []
                        for item in regex.finditer(value):
                            val.append(
            Severity: Minor
            Found in pygcgen/optionsfile_parser.py - About 1 hr 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 get_all_tags has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def get_all_tags(self):
                    """
                    Fetch all tags for repository from Github.
            
                    :return: tags in repository
            Severity: Minor
            Found in pygcgen/fetcher.py - About 1 hr 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 fetch_closed_pull_requests has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch_closed_pull_requests(self):
                    """
                    Fetch all pull requests. We need them to detect "merged_at" parameter
            
                    :rtype: list
            Severity: Minor
            Found in pygcgen/fetcher.py - About 1 hr 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 fetch_github_token has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                def fetch_github_token(self):
                    """
                    Fetch GitHub token. First try to use variable provided
                    by --token option, otherwise try to fetch it from git config
                    and last CHANGELOG_GITHUB_TOKEN env variable.
            Severity: Minor
            Found in pygcgen/fetcher.py - About 1 hr 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