icoz/habraparse

View on GitHub

Showing 8 of 39 total issues

Function save_all_favs_for_user has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def save_all_favs_for_user(username, out_dir, save_in_html=True, with_comments=False, save_by_name=False, limit=None,
                           project='h'):
    filetype = 'pdf'
    if save_in_html:
        filetype = 'html'
Severity: Minor
Found in habraparse.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

Function _parseUserpage has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def _parseUserpage(self):
        # print(self._doc)
        # check for BAN
        val = self._doc.xpath("//div[@class='main']/h1")
        if val and val[0].text.strip() == "Доступ закрыт":
Severity: Minor
Found in habr/user.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

Function _parseTopic has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def _parseTopic(self):
        '''
        returns info
        '''
        self.post = dict()
Severity: Minor
Found in habr/topic.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

Function _parseUserpage has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def _parseUserpage(self):
        # print(self._doc)
        # check for BAN
        val = self._doc.xpath("//div[@class='main']/h1")
        if val and val[0].text.strip() == "Доступ закрыт":
Severity: Minor
Found in habr/user.py - About 1 hr to fix

    Function _parseTopic has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def _parseTopic(self):
            '''
            returns info
            '''
            self.post = dict()
    Severity: Minor
    Found in habr/topic.py - About 1 hr to fix

      Function create_url_list has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_url_list(username, filename, project='h'):
          '''
          Generates url list for favorites
          :param username:
          :param filename:
      Severity: Minor
      Found in habraparse.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 save_all_favs_for_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def save_all_favs_for_user(username, out_dir, save_in_html=True, with_comments=False, save_by_name=False, limit=None,
      Severity: Major
      Found in habraparse.py - About 50 mins to fix

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

        def main():
            # {prog} save_posts [--gt|--mm] [-c --save-html --limit=N] <username> <out_dir>
            params = """Usage:
                {prog} save_favs_list [--gt] <username> <out_file>
                {prog} save_favs [--gt] [-cn --save-html --limit=N] <username> <out_dir>
        Severity: Minor
        Found in habraparse.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