webcomics/dosage

View on GitHub

Showing 85 of 223 total issues

File b.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: MIT
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2020 Tobias Gruetzmacher
# Copyright (C) 2019-2020 Daniel Ring
Severity: Minor
Found in dosagelib/plugins/b.py - About 2 hrs to fix

    Function display_version has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def display_version(verbose):
        """Display application name, version, copyright and license."""
        print(configuration.App)
        print("Using Python {} ({}) on {}".format(platform.python_version(),
            platform.python_implementation(), platform.platform()))
    Severity: Minor
    Found in dosagelib/cmd.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_download_dir has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_download_dir(self, basepath):
            """Try to find the corect download directory, ignoring case
            differences."""
            path = basepath
            for part in self.name.split('/'):
    Severity: Minor
    Found in dosagelib/scraper.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 getStrips has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def getStrips(self, maxstrips=None):
            """Get comic strips."""
            if maxstrips:
                word = u"strip" if maxstrips == 1 else "strips"
                msg = u'Retrieving %d %s' % (maxstrips, word)
    Severity: Minor
    Found in dosagelib/scraper.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 namer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def namer(self, imageUrl, pageUrl):
            # Strip date from filenames
            filename = imageUrl.rsplit('/', 1)[-1]
            if not 'ultrarosa' in pageUrl:
                if filename[4] == '-' and filename[7] == '-':
    Severity: Minor
    Found in dosagelib/plugins/kemonocafe.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 find has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def find(self, comic, multiple_allowed=False):
            """Get a list comic scraper objects.
    
            Can return more than one entry if multiple_allowed is True, else it raises
            a ValueError if multiple modules match. The match is a case insensitive
    Severity: Minor
    Found in dosagelib/scraper.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 __init__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, flavor_id="", exit_code=-1):
            """Create an exclusive lockfile or exit with an error and the given
            exit code."""
            self.initialized = False
            scriptname = os.path.splitext(os.path.realpath(sys.argv[0]))[0]
    Severity: Minor
    Found in dosagelib/singleton.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 fetchUrls has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def fetchUrls(self, url, data, urlSearch):
            """Search all entries for given XPath in a HTML page."""
            searchUrls = []
            for match, search in self._matchPattern(data, urlSearch):
                searchUrl = None
    Severity: Minor
    Found in dosagelib/scraper.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 __init__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, stream=None):
            """Initialize context and indentation."""
            self.context = None
            self.level = 0
            self.timestamps = False
    Severity: Minor
    Found in dosagelib/output.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 saveComicStrip has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def saveComicStrip(self, strip):
            """Save a comic strip which can consist of multiple images."""
            allskipped = True
            for image in strip.getImages():
                try:
    Severity: Minor
    Found in dosagelib/director.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 getComics has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def getComics(options):
        """Retrieve comics."""
        threads = []
        jobs = ComicQueue()
    
    
    Severity: Minor
    Found in dosagelib/director.py - About 55 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 language has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def language(self):
            """
            Return language of the comic as a human-readable language name instead
            of a 2-character ISO639-1 code.
            """
    Severity: Minor
    Found in dosagelib/scraper.py - About 55 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 fetchUrls has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def fetchUrls(self, url, data, urlSearch):
            """Search all entries for given URL pattern(s) in a HTML page."""
            searchUrls = []
            searches = makeSequence(urlSearch)
            for search in searches:
    Severity: Minor
    Found in dosagelib/scraper.py - About 55 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 get_tagged_scraper_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_tagged_scraper_name(scraperobj, limit=None, reasons=None):
        """Get comic scraper name."""
        tags = []
        if scraperobj.adult:
            tags.append(TAG_ADULT)
    Severity: Minor
    Found in dosagelib/cmd.py - About 45 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, name, sub, first, last=None, adult=False, nav=None):
    Severity: Minor
    Found in dosagelib/plugins/rickgriffinstudios.py - About 45 mins to fix

      Function fetchText has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetchText(self, url, data, textSearch, optional):
              """Search text entry for given text XPath in a HTML page."""
              if not textSearch:
                  return None
              text = []
      Severity: Minor
      Found in dosagelib/scraper.py - About 45 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 urlopen has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def urlopen(url, session, referrer=None, max_content_bytes=None,
      Severity: Minor
      Found in dosagelib/util.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if scraperobj not in scrapers:
                                scrapers.add(scraperobj)
                                yield scraperobj
        
        
        Severity: Major
        Found in dosagelib/director.py - About 45 mins to fix

          Function __del__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def __del__(self):
                  """Remove the lock file."""
                  if not self.initialized:
                      return
                  try:
          Severity: Minor
          Found in dosagelib/singleton.py - About 45 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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def run(options):
              """Execute comic commands."""
              set_output_info(options)
              # ensure only one instance of dosage is running
              if not options.allow_multiple:
          Severity: Minor
          Found in dosagelib/cmd.py - About 45 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