deeplearning4j/deeplearning4j

View on GitHub
libnd4j/auto_vectorization/auto_vect.py

Summary

Maintainability
F
5 days
Test Coverage

File auto_vect.py has 549 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'''
@author : Abdelrauf rauf@konduit.ai
'''
#  /* ******************************************************************************
#   *
Severity: Major
Found in libnd4j/auto_vectorization/auto_vect.py - About 1 day to fix

    Function obtain_info_from has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def obtain_info_from(input_):
        info_ = dict()
        parser_storage = dict() #can be used for parsing multi-lines
        if HAS_FSAVE ==True or stdin_parser is None:
            #just print progress
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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 generate_report has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_report(output_name,info_ ,only_body = False, unique_id_prefix='',fsave_format = False , function_list = None):
        '''
          Generate Auto-Vectorization Report in html format
        '''
        temp_str =''
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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 consume_processed_new has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def consume_processed_new(list_Queue , c_index):
        
        info_ = dict()
        func_list = dict()
        last_func_index = 0 
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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 process_gzip_json_new has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def process_gzip_json_new(json_gz_fname,list_Queue):
        gz_name = Path(json_gz_fname).stem
        #print("::--open and process {0}".format(gz_name))
        queue_count = len(list_Queue)
        #print(queue_count)
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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 generate_inverted_index has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_inverted_index(output_name, info_ , function_list ):
        temp_str =''  
        output_name = output_name.replace(".html","_inverted_index")
        rev_index = Json_reverse()
        rev_index.functions =[get_cxx_filt_result(k) for k,v in sorted(function_list.items(), key=lambda x: x[1])]
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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_content has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_content(k, v,  unique_id_prefix = '', fsave_format=False):
        inner_str=''
        content = ''
        inc_id = 0
        for fk,fv in sorted(v.infos.items()):
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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 add_fsave has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_fsave(self, line_pos,success, msg, function ,inline_fns=''):
            v = self.add_line_fsave(line_pos)
            if success and "loop vectorized" in msg:
                v.optimized +=1
                self.total_opted +=1
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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 general_stdin_parser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def general_stdin_parser(std_success_msg, std_fail_msg , std_line_regex_str):
        '''
        General Parser from success and error message and line regex extractor
        Parameters:
        std_line_regex_str: it should match group(1) to file, group(2) to line_number and group(3) to message
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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_global_options has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def init_global_options(args):
        global stdin_parser
        global HAS_FSAVE
        global BASE_URL
        global FSAVE_INVERTED_INDEX
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.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 generate_report has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def generate_report(output_name,info_ ,only_body = False, unique_id_prefix='',fsave_format = False , function_list = None):
    Severity: Minor
    Found in libnd4j/auto_vectorization/auto_vect.py - About 45 mins to fix

      Function add_fsave has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def add_fsave(self, line_pos,success, msg, function ,inline_fns=''):
      Severity: Minor
      Found in libnd4j/auto_vectorization/auto_vect.py - About 35 mins to fix

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

            def add_line(self, line_pos):
                if line_pos not in self.infos:
                    v = info()
                    v.optimized = 0
                    v.missed = 0
        Severity: Major
        Found in libnd4j/auto_vectorization/auto_vect.py and 1 other location - About 4 hrs to fix
        libnd4j/auto_vectorization/auto_vect.py on lines 215..224

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

        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 add_line_fsave(self, line_pos):
                if line_pos not in self.infos:
                    v = info()
                    v.optimized = 0
                    v.missed = 0
        Severity: Major
        Found in libnd4j/auto_vectorization/auto_vect.py and 1 other location - About 4 hrs to fix
        libnd4j/auto_vectorization/auto_vect.py on lines 203..212

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

        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

                for line in input_:
                    if cmake_build_progress.match(line):
                        #actually we redirect only, stderr so this should not happen
                        print("__"+line.strip())
                    elif "error" in line or "Error" in line:
        Severity: Major
        Found in libnd4j/auto_vectorization/auto_vect.py and 1 other location - About 2 hrs to fix
        libnd4j/auto_vectorization/auto_vect.py on lines 377..389

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

        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 x is not None:
                    if x.file_name in info_:
                        #ignore col_number
                        info_[x.file_name].add(x.line_pos, x.msg, x.success, x.miss)
                        info_[x.file_name].external = x.external_source
        Severity: Major
        Found in libnd4j/auto_vectorization/auto_vect.py and 1 other location - About 2 hrs to fix
        libnd4j/auto_vectorization/auto_vect.py on lines 368..373

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

        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

            for i in range(len(new_list)-1,0,-1):
                new_list[i] = new_list[i] - new_list[i-1] 
        Severity: Major
        Found in libnd4j/auto_vectorization/auto_vect.py and 1 other location - About 2 hrs to fix
        libnd4j/auto_vectorization/inverted_index.py on lines 29..30

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

        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

            rev_index.messages = [k for k,v in sorted(message_list.items(), key=lambda x: x[1])]
        Severity: Minor
        Found in libnd4j/auto_vectorization/auto_vect.py and 1 other location - About 30 mins to fix
        libnd4j/auto_vectorization/auto_vect.py on lines 572..572

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

        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

            rev_index.functions =[get_cxx_filt_result(k) for k,v in sorted(function_list.items(), key=lambda x: x[1])]
        Severity: Minor
        Found in libnd4j/auto_vectorization/auto_vect.py and 1 other location - About 30 mins to fix
        libnd4j/auto_vectorization/auto_vect.py on lines 592..592

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

        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