vorot93/obozrenie

View on GitHub

Showing 48 of 48 total issues

File gtk.py has 587 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# This source file is part of Obozrenie
# Copyright 2015 Artem Vorotnikov

# For more information, see https://github.com/obozrenie/obozrenie
Severity: Major
Found in obozrenie/gtk.py - About 1 day to fix

    Function search_table has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

    def search_table(table, level, value):
        if level == 0:
            for i in range(len(table)):
                if table[i] == value:
                    return i
    Severity: Minor
    Found in obozrenie/helpers.py - About 1 day 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 server_filter_func has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        def server_filter_func(self, model: Gtk.TreeModel, treeiter: Gtk.TreeIter, *args) -> bool:
            """Tests if row matches filter settings"""
            filter_criteria = self.filter_criteria
            server_list_model_format_index = self.server_list_model_format.index
            result = None
    Severity: Minor
    Found in obozrenie/gtk.py - About 6 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 adapt_server_list has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    def adapt_server_list(qstat_string, game, game_name, qstat_master_type, qstat_server_type, server_game_name, server_game_type):
        server_table = []
    
        server_table_dict = json.loads(json.dumps(xmltodict.parse(qstat_string)))
        server_table_dict['qstat']['server'] = helpers.enforce_array(server_table_dict['qstat']['server'])  # Enforce server array even if n=1
    Severity: Minor
    Found in obozrenie/adapters/qstat.py - About 5 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 adapt_server_entry has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    def adapt_server_entry(qstat_entry, game):
        """Parses server entry returned by QStat"""
        color_code_pattern = '[\\^](.)'
    
        debug_message = None
    Severity: Minor
    Found in obozrenie/adapters/qstat.py - About 5 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 core.py has 388 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python3
    # This source file is part of Obozrenie
    # Copyright 2015 Artem Vorotnikov
    
    # For more information, see https://github.com/obozrenie/obozrenie
    Severity: Minor
    Found in obozrenie/core.py - About 5 hrs to fix

      GUIActions has 30 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class GUIActions:
      
          """Responses to events from GUI"""
      
          def __init__(self, app, builder, core_library):
      Severity: Minor
      Found in obozrenie/gtk.py - About 3 hrs to fix

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

            def stat_master_target(self, game: str, callback=None) -> None:
                """Separate update thread. Strictly per-game."""
                game_info = self.game_table.get_game_info(game)
                game_settings = self.game_table.get_game_settings(game)
                game_name = game_info["name"]
        Severity: Minor
        Found in obozrenie/core.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 set_widget_value has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

        def set_widget_value(widget, value, treeview_colnum=0):
            """Applies setting to widget."""
            if value == 'None':
                value = None
            if isinstance(widget, Gtk.Adjustment):
        Severity: Minor
        Found in obozrenie/gtk_helpers.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 load has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def load(self, callback_postgenload=None):
                """Loads configuration."""
                default_common_settings_table = helpers.load_table(
                    self.default_common_settings_path)
                default_game_settings_table = helpers.load_table(
        Severity: Minor
        Found in obozrenie/core.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

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

                if len(host) > 1:
                    host = ":".join(host[0:-1])
                else:
                    host = ":".join(host)
        Severity: Major
        Found in obozrenie/ping.py and 1 other location - About 1 hr to fix
        obozrenie/ping.py on lines 50..53

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

        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

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

                if len(host) > 1:
                    host = ":".join(host[0:-1])
                else:
                    host = ":".join(host)
        Severity: Major
        Found in obozrenie/ping.py and 1 other location - About 1 hr to fix
        obozrenie/ping.py on lines 34..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 45.

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

        def get_widget_value(widget):
            """Fetches widget setting."""
            value = None
            if isinstance(widget, Gtk.Adjustment):
                value = widget.get_property("value")
        Severity: Minor
        Found in obozrenie/gtk_helpers.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 update_settings_table has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def update_settings_table(self, *args):
                for group in self.widget_table:
                    for option in self.widget_table[group]:
                        # Define variables
                        widget_name = self.widget_table[group][option]["gtk_widget_name"]
        Severity: Minor
        Found in obozrenie/gtk.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 stat_master has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def stat_master(game: str, game_info: dict, master_list: list):
            hosts_array = []
        
            qstat_stdin_object = ""
        
        
        Severity: Minor
        Found in obozrenie/adapters/qstat.py - About 1 hr to fix

          Function dict_to_list has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def dict_to_list(dict_table, key_list):
              list_table = []
          
              if dict_table is not None:
                  for entry in dict_table:
          Severity: Minor
          Found in obozrenie/helpers.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 stat_master has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def stat_master(game: str, game_info: dict, master_list: list):
              hosts_array = []
          
              qstat_stdin_object = ""
          
          
          Severity: Minor
          Found in obozrenie/adapters/qstat.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_icon_dict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          def get_icon_dict(key_list, icon_type, icon_formats, icon_dir, width, height, error_msg=None):
              """Loads icon pixbufs into memory for later usage"""
              icon_dict = {}
              for entry in key_list:
                  try:
          Severity: Minor
          Found in obozrenie/gtk_helpers.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 create_game_table has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_game_table(self, gameconfig_object) -> helpers.ThreadSafeDict:
                  """
                  Loads game list into a table.
                  """
                  game_table = helpers.ThreadSafeDict()
          Severity: Minor
          Found in obozrenie/core.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 hl2_launch_pattern has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def hl2_launch_pattern(game: str, path: str, game_settings: dict, host: str, port: str, password: str, **kwargs) -> list:
          Severity: Major
          Found in obozrenie/launch.py - About 50 mins to fix
            Severity
            Category
            Status
            Source
            Language