Telefonica/toolium

View on GitHub

Showing 17 of 34 total issues

File dataset.py has 697 lines of code (exceeds 420 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
"""
Copyright 2022 Telefónica Investigación y Desarrollo, S.A.U.
This file is part of Toolium.

Severity: Major
Found in toolium/utils/dataset.py - About 1 day to fix

    Function get_steps_from_feature_description has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
    Open

        def get_steps_from_feature_description(self, description):
            """
            get all steps defined in the feature description associated to each action
            :param description: feature description
            """
    Severity: Minor
    Found in toolium/behave/env_utils.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 _find_web_element has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
    Open

        def _find_web_element(self):
            """Find WebElement using element locator and save it in _web_element attribute"""
            if not self._web_element or not self.driver_wrapper.config.getboolean_optional('Driver', 'save_web_element'):
                # check context for mobile webviews
                if self.driver_wrapper.config.getboolean_optional('Driver', 'automatic_context_selection'):
    Severity: Minor
    Found in toolium/pageelements/page_element.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

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

                if not os.path.isabs(cls.output_directory):
                    # If output directory is relative, we use the same path as config directory
                    cls.output_directory = os.path.join(os.path.dirname(cls.config_directory), cls.output_directory)
    Severity: Major
    Found in toolium/driver_wrappers_pool.py and 1 other location - About 1 hr to fix
    toolium/driver_wrappers_pool.py on lines 294..297

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

    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

                if not os.path.isabs(cls.visual_baseline_directory):
                    # If baseline directory is relative, we use the same path as config directory
                    cls.visual_baseline_directory = os.path.join(os.path.dirname(cls.config_directory),
                                                                 cls.visual_baseline_directory)
    Severity: Major
    Found in toolium/driver_wrappers_pool.py and 1 other location - About 1 hr to fix
    toolium/driver_wrappers_pool.py on lines 284..286

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

    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_translation_by_poeditor_reference has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

    def get_translation_by_poeditor_reference(reference, poeditor_terms):
        """
        Return the translation(s) for the given POEditor reference from the given terms in poeditor_terms.
    
        :param reference: POEditor reference
    Severity: Minor
    Found in toolium/utils/dataset.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

        def click(self):
            """Click the element
    
            :returns: page element instance
            """
    Severity: Major
    Found in toolium/pageelements/input_text_page_element.py and 1 other location - About 1 hr to fix
    toolium/pageelements/button_page_element.py on lines 36..46

    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

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

        def click(self):
            """Click the element
    
            :returns: page element instance
            """
    Severity: Major
    Found in toolium/pageelements/button_page_element.py and 1 other location - About 1 hr to fix
    toolium/pageelements/input_text_page_element.py on lines 60..70

    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

    Function save_all_webdriver_or_ggr_logs has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
    Open

        def save_all_webdriver_or_ggr_logs(cls, test_name, test_passed, ggr=False):
            """Get all webdriver or GGR logs of each driver and write them to log files
    
            :param test_name: test that has generated these logs
            :param test_passed: True if the test has passed
    Severity: Minor
    Found in toolium/driver_wrappers_pool.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 change_jira_status has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
    Open

    def change_jira_status(test_key, test_status, test_comment, test_attachments):
        """Update test status in Jira
    
        :param test_key: test case key in Jira
        :param test_status: test case status
    Severity: Minor
    Found in toolium/jira.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 get_remote_node has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
    Open

        def get_remote_node(self):
            """Return the remote node that it's executing the actual test session
    
            :returns: tuple with server type (local, grid, ggr, selenium) and remote node name
            """
    Severity: Minor
    Found in toolium/utils/driver_utils.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 assert_screenshot has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
    Open

        def assert_screenshot(self, element, filename, file_suffix=None, threshold=0, exclude_elements=[]):
            """Assert that a screenshot of an element is the same as a screenshot on disk, within a given threshold
    
            :param element: either a WebElement, PageElement or element locator as a tuple (locator_type, locator_value).
                            If None, a full screenshot is taken.
    Severity: Minor
    Found in toolium/visual_test.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 download_videos has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
    Open

        def download_videos(cls, name, test_passed=True, maintain_default=False):
            """Download saved videos if video is enabled or if test fails
    
            :param name: destination file name
            :param test_passed: True if the test has passed
    Severity: Minor
    Found in toolium/driver_wrappers_pool.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 load_poeditor_texts has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

    def load_poeditor_texts():
        """
        Download POEditor texts and save in output folder if the config exists or use previously downloaded texts
        """
        if get_poeditor_api_token():
    Severity: Minor
    Found in toolium/utils/poeditor.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

    Function exclude_elements has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

        def exclude_elements(self, img, web_elements):
            """Modify image hiding elements with a black rectangle
    
            :param img: image object
            :param web_elements: WebElement objects to be excluded
    Severity: Minor
    Found in toolium/visual_test.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

    Function is_the_session_still_active has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

        def is_the_session_still_active(self):
            """
            Is the GGR session still active? Associated to a browser and the sessionId
            Example of GGR status:
            {
    Severity: Minor
    Found in toolium/selenoid.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

    Function add_jira_status has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
    Open

    def add_jira_status(test_key, test_status, test_comment):
        """Save test status and comments to update Jira later
    
        :param test_key: test case key in Jira
        :param test_status: test case status
    Severity: Minor
    Found in toolium/jira.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