edgewall/trac

View on GitHub

Showing 1,048 of 1,370 total issues

Function insert has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def insert(self, when=None):
        """Add ticket to database.
        """
        assert not self.exists, 'Cannot insert an existing ticket'

Severity: Minor
Found in trac/ticket/model.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 main has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    parser = argparse.ArgumentParser(description="""\
        If no flags are given, both jinja and html checks will be performed.

        An alternative usage is to run the tool via make, i.e. `make jinja`,
Severity: Minor
Found in contrib/jinjachecker.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 main has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def main():
    args = sys.argv[1:]
    if not args:
        sys.stderr.write('Usage: %s algorithm files...\n' % sys.argv[0])
        return 2
Severity: Minor
Found in contrib/checksum.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 history_relative_rev has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def history_relative_rev(self, sha, rel_pos):

        def get_history_relative_rev(sha, rel_pos):
            rev_dict = self.get_commits()

Severity: Minor
Found in tracopt/versioncontrol/git/PyGIT.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_repositories has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def get_repositories(self):
        """Retrieve repositories specified in a `projects_list` file."""
        if not self.projects_list:
            return

Severity: Minor
Found in tracopt/versioncontrol/git/git_fs.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 _cat_file_reader has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _cat_file_reader(self, kind, sha):
        with self.__cat_file_pipe_lock:
            if self.__cat_file_pipe is None:
                self.__cat_file_pipe = self.repo.cat_file_batch()

Severity: Minor
Found in tracopt/versioncontrol/git/PyGIT.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 do_upgrade has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def do_upgrade(env, ver, cursor):
    """
    1. Zero-pad Subversion revision numbers in the cache.
    2. Remove wiki-macros directory.
    """
Severity: Minor
Found in trac/upgrades/db26.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 shortrev has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def shortrev(self, rev, min_len=7):

        def get_shortrev(rev, min_len):
            """try to shorten sha id"""
            #try to emulate the following:
Severity: Minor
Found in tracopt/versioncontrol/git/PyGIT.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 _check_quickjump has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _check_quickjump(self, req, noquickjump, kwd):
        """Look for search shortcuts"""
        # Source quickjump  FIXME: delegate to ISearchSource.search_quickjump
        quickjump_href = None
        if kwd[0] == '/':
Severity: Minor
Found in trac/search/web_ui.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 request has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function request() {
      if (!updating) {
        var new_values = form.serializeArray();
        if (values_changed(new_values)) {
          values = new_values;
Severity: Minor
Found in trac/htdocs/js/auto_preview.js - About 1 hr to fix

    Function paintLogGraph has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      $.paintLogGraph = function(graph, canvas) {
        var ctx = canvas.getContext('2d');
        ctx.scale(-canvas.width / graph.columns,
                  canvas.height / graph.vertices.length);
        ctx.translate(-graph.columns + 0.5, 0.5)
    Severity: Minor
    Found in trac/htdocs/js/log_graph.js - About 1 hr to fix

      Function __init__ has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, env, report=None, constraints=None, cols=None,
                       order=None, desc=0, group=None, groupdesc=0, verbose=0,
                       rows=None, page=None, max=None, format=None):
              self.env = env
              self.id = report  # if not None, it's the corresponding saved query
      Severity: Minor
      Found in trac/ticket/query.py - About 1 hr to fix

        Function process_request has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def process_request(self, req):
                presel = req.args.get('preselected')
                if presel and (presel + '/').startswith(req.href.browser() + '/'):
                    req.redirect(presel)
        
        
        Severity: Minor
        Found in trac/versioncontrol/web_ui/browser.py - About 1 hr to fix

          Function _do_send has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def _do_send(self, transport, event, message, cc_addrs, bcc_addrs):
                  notify_sys = NotificationSystem(self.env)
                  smtp_from = notify_sys.smtp_from
                  smtp_from_name = notify_sys.smtp_from_name or self.env.project_name
                  smtp_replyto = notify_sys.smtp_replyto
          Severity: Minor
          Found in trac/notification/mail.py - About 1 hr to fix

            Function parse_args has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def parse_args(args=None):
                parser = argparse.ArgumentParser()
            
                class _AuthAction(argparse.Action):
            
            
            Severity: Minor
            Found in trac/web/standalone.py - About 1 hr to fix

              Function _render_ics has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def _render_ics(self, req, milestones):
                      req.send_response(200)
                      req.send_header('Content-Type', 'text/calendar;charset=utf-8')
                      buf = io.StringIO()
              
              
              Severity: Minor
              Found in trac/ticket/roadmap.py - About 1 hr to fix

                Function code_block_directive has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def code_block_directive(name, arguments, options, content, lineno,
                Severity: Major
                Found in trac/mimeview/rst.py - About 1 hr to fix

                  Function trac_directive has 9 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def trac_directive(name, arguments, options, content, lineno,
                  Severity: Major
                  Found in trac/mimeview/rst.py - About 1 hr to fix

                    Function enableExpandDir has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      window.enableExpandDir = function(parent_tr, rows, qargs, autoexpand) {
                        // the ancestors folder ids are present in the parent_tr class attribute
                        var ancestor_folderids = [];
                    
                        if (parent_tr) // rows are logical children of the parent_tr row
                    Severity: Minor
                    Found in trac/htdocs/js/expand_dir.js - About 1 hr to fix

                      Function encloseSelection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function encloseSelection(prefix, suffix) {
                            textarea.focus();
                            var start, end, sel, scrollPos, subst;
                            if (document.selection != undefined) {
                              sel = document.selection.createRange().text;
                      Severity: Minor
                      Found in trac/htdocs/js/wikitoolbar.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language