aLkRicha/insta_browser

View on GitHub

Showing 9 of 9 total issues

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

    def likes_increment(self):
        params = [self.account_id]
        self.db.execute(INSERT_UPDATE_LIKES_QUERY, params)
        self.db_log('query: {}, params: {}'.format(''.join(INSERT_UPDATE_LIKES_QUERY.splitlines()), params))
        self.db.commit()
Severity: Major
Found in insta_browser/db/browser_db.py and 1 other location - About 3 hrs to fix
insta_browser/db/browser_db.py on lines 116..120

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

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

    def follows_increment(self):
        params = [self.account_id]
        self.db.execute(INSERT_UPDATE_FOLLOWS_QUERY, params)
        self.db_log('query: {}, params: {}'.format(''.join(INSERT_UPDATE_FOLLOWS_QUERY.splitlines()), params))
        self.db.commit()
Severity: Major
Found in insta_browser/db/browser_db.py and 1 other location - About 3 hrs to fix
insta_browser/db/browser_db.py on lines 110..114

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

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

    def process(self, exclude, login):
        """
        liking pre-processed posts. Moving to each post with ActionChains

        :param exclude:
Severity: Minor
Found in insta_browser/processors/feed_processor.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, debug=False, chrome=False, cookie_path=None, log_path=None, db_path=None,
Severity: Major
Found in insta_browser/browser.py - About 50 mins to fix

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

        def go_through_posts(self, count):
            self.count = count
            time.sleep(.5)
            self.post_already_liked = 0
            progress = tqdm.tqdm(range(self.count))
    Severity: Minor
    Found in insta_browser/processors/not_feed_processor.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 auth_with_credentials has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def auth_with_credentials(browser, logger, login, password, cookie_path=tempfile.gettempdir()):
    Severity: Minor
    Found in insta_browser/auth.py - About 35 mins to fix

      Function __do_i_need_to_follow_this_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __do_i_need_to_follow_this_user(self) -> bool:
              """
              Check if i need to follow current user
              :return: bool
              """
      Severity: Minor
      Found in insta_browser/processors/base_processor.py - About 35 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 __is_last_post_in_feed_not_liked has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __is_last_post_in_feed_not_liked(self):
              """
              Check last five posts if they are not liked
      
              :return: False if one of five posts wasn't liked, True if all five were liked
      Severity: Minor
      Found in insta_browser/processors/feed_processor.py - About 35 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 follow_user has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def follow_user(self) -> bool:
              """
              Follow user if need and could
              :return: bool
              """
      Severity: Minor
      Found in insta_browser/processors/base_processor.py - About 25 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