IlyaGusev/rulm

View on GitHub
data_processing/create_stackoverflow.py

Summary

Maintainability
D
2 days
Test Coverage

Function check_complete has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def check_complete(self, a_attribs):
        assert a_attribs is not None
        parent_id = a_attribs["ParentId"]
        parent = self.questions[parent_id]
        if parent is None:
Severity: Minor
Found in data_processing/create_stackoverflow.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

Function __call__ has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def __call__(self):
        desc = "Parsing users XML file: {}".format(self.users_path)
        for event, elem in tqdm(etree.iterparse(self.users_path, events=('end',)), desc=desc):
            if elem.tag != "row":
                continue
Severity: Minor
Found in data_processing/create_stackoverflow.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

File create_stackoverflow.py has 269 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Based on https://github.com/EleutherAI/stackexchange-dataset/blob/master/pairer.py

import argparse
import os
import re
Severity: Minor
Found in data_processing/create_stackoverflow.py - About 2 hrs to fix

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

        def check_complete(self, a_attribs):
            assert a_attribs is not None
            parent_id = a_attribs["ParentId"]
            parent = self.questions[parent_id]
            if parent is None:
    Severity: Minor
    Found in data_processing/create_stackoverflow.py - About 1 hr to fix

      Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, posts_path, users_path, comments_path, output_path, min_score=-1000, max_responses=1000):
      Severity: Minor
      Found in data_processing/create_stackoverflow.py - About 45 mins to fix

        Identical blocks of code found in 3 locations. Consider refactoring.
        Open

        def html2text_setup():
            instance = html2text.HTML2Text(bodywidth=0)
            instance.ignore_links = True
            instance.ignore_images = True
            instance.ignore_tables = True
        Severity: Major
        Found in data_processing/create_stackoverflow.py and 2 other locations - About 3 hrs to fix
        data_processing/convert_pikabu.py on lines 25..33
        data_processing/create_habr.py on lines 29..37

        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

                        author = self.users[int(attribs["UserId"])] if attribs["UserId"] else attribs["UserDisplayName"]
        Severity: Major
        Found in data_processing/create_stackoverflow.py and 1 other location - About 1 hr to fix
        data_processing/create_stackoverflow.py on lines 242..242

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

        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

                author = self.users[int(parent["OwnerUserId"])] if parent["OwnerUserId"] else parent["OwnerDisplayName"]
        Severity: Major
        Found in data_processing/create_stackoverflow.py and 1 other location - About 1 hr to fix
        data_processing/create_stackoverflow.py on lines 154..154

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

        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

                record["views"] = int(parent["ViewCount"]) if parent["ViewCount"] is not None else None
        Severity: Major
        Found in data_processing/create_stackoverflow.py and 1 other location - About 1 hr to fix
        data_processing/create_stackoverflow.py on lines 236..236

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

        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

                record["score"] = int(parent["Score"]) if parent["Score"] is not None else None
        Severity: Major
        Found in data_processing/create_stackoverflow.py and 1 other location - About 1 hr to fix
        data_processing/create_stackoverflow.py on lines 241..241

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

        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 is_answer(elem_attribs):
            post_type_id = elem_attribs["PostTypeId"]
            return post_type_id is not None and post_type_id == "2"
        Severity: Minor
        Found in data_processing/create_stackoverflow.py and 1 other location - About 55 mins to fix
        data_processing/create_stackoverflow.py on lines 36..38

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

        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 is_question(elem_attribs):
            post_type_id = elem_attribs["PostTypeId"]
            return post_type_id is not None and post_type_id == "1"
        Severity: Minor
        Found in data_processing/create_stackoverflow.py and 1 other location - About 55 mins to fix
        data_processing/create_stackoverflow.py on lines 41..43

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

        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

        There are no issues that match your filters.

        Category
        Status