tobyqin/xmind2testlink

View on GitHub

Showing 16 of 16 total issues

Function xmind_to_suite_v2 has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

def xmind_to_suite_v2(xmind_file):
    def parse_testcase_list(cases_dict, parent=None):
        if __.is_testcase_topic(cases_dict):
            yield __.parse_testcase(cases_dict, parent)

Severity: Minor
Found in xmind2testlink/xmind_parser.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 _is_v2_by_guess has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def _is_v2_by_guess(d):
    """if any sub topic from testcase node mark with priority, this can be guessed as v2 xmind. """
    for suite_node in d['topics']:
        for testcase_node in suite_node['topics']:
            sub_topics = testcase_node['topics']
Severity: Minor
Found in xmind2testlink/sharedparser.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 index has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def index(download_xml=None):
    g.invalid_files = []
    g.error = None
    g.download_xml = download_xml
    g.filename = None
Severity: Minor
Found in web/application.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

Avoid deeply nested control flow statements.
Open

                    if _is_v2_by_marker(_, maker_prefix='priority'):
                        return True
                    else:
                        temp_topics.extend(_['topics'])
                    sub_topics = temp_topics
Severity: Major
Found in xmind2testlink/sharedparser.py - About 45 mins to fix

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

            if self.sub_suites:
                for s in self.sub_suites:
                    me['sub_suites'].append(s.to_dict())
    Severity: Minor
    Found in xmind2testlink/datatype.py and 2 other locations - About 35 mins to fix
    xmind2testlink/datatype.py on lines 17..19
    xmind2testlink/datatype.py on lines 40..42

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

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

    def build_step_xml(testcase, testcase_element):
        if testcase.steps:
            steps_element = SubElement(testcase_element, Tags.steps)
    
            for step in testcase.steps:
    Severity: Minor
    Found in xmind2testlink/testlink_parser.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

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

            if self.steps:
                for s in self.steps:
                    me['steps'].append(s.to_dict())
    Severity: Minor
    Found in xmind2testlink/datatype.py and 2 other locations - About 35 mins to fix
    xmind2testlink/datatype.py on lines 13..15
    xmind2testlink/datatype.py on lines 17..19

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

    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 3 locations. Consider refactoring.
    Open

            if self.testcase_list:
                for t in self.testcase_list:
                    me['testcase_list'].append(t.to_dict())
    Severity: Minor
    Found in xmind2testlink/datatype.py and 2 other locations - About 35 mins to fix
    xmind2testlink/datatype.py on lines 13..15
    xmind2testlink/datatype.py on lines 40..42

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

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

    def build_testcase_precondition(nodes):
        values = (n['comment'] for n in nodes if n.get('comment', None))
        values = list(_filter_empty_comments(values))
    
        if not values:  # try to get from callout
    Severity: Minor
    Found in xmind2testlink/sharedparser.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

    Avoid too many return statements within this function.
    Open

            return render_template('index.html', download_xml=g.download_xml, records=list(get_records()))
    Severity: Major
    Found in web/application.py - About 30 mins to fix

      Function _is_v2_by_marker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def _is_v2_by_marker(d, maker_prefix='star'):
          """check if a node have a star maker"""
          if isinstance(d['makers'], list):
              for m in d['makers']:
                  if m.startswith(maker_prefix):
      Severity: Minor
      Found in xmind2testlink/sharedparser.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 _filter_empty_comments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def _filter_empty_comments(comment_values):
          """comment value like: [[{content:comment1},{content:comment2}],[...]]"""
          for comments in comment_values:
              for comment in comments:
                  if comment.get('content'):
      Severity: Minor
      Found in xmind2testlink/sharedparser.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 delete_records has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def delete_records(keep=20):
          """Clean up files on server and mark the record as deleted"""
          sql = "SELECT * from records where is_deleted<>1 ORDER BY id desc LIMIT -1 offset {}".format(keep)
          assert isinstance(g.db, sqlite3.Connection)
          c = g.db.cursor()
      Severity: Minor
      Found in web/application.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 get_priority has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_priority(d):
          if isinstance(d['makers'], list):
              for m in d['makers']:
                  if m.startswith('priority'):
                      return int(m[-1])
      Severity: Minor
      Found in xmind2testlink/sharedparser.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 main has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          if len(sys.argv) > 1 and sys.argv[1].endswith('.xmind'):
              xmind = sys.argv[1]
      
              if len(sys.argv) == 3 and sys.argv[2] == '-json':
      Severity: Minor
      Found in xmind2testlink/main.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 to_dict has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_dict(self):
              me = {'name': self.name,
                    'details': self.details,
                    'testcase_list': [],
                    'sub_suites': []}
      Severity: Minor
      Found in xmind2testlink/datatype.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