fdev/bc125csv

View on GitHub

Showing 26 of 26 total issues

Function write has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def write(self, channels):
        # Iterate over all banks
        for bank in range(1, 11):
            bankheader = False
            
Severity: Minor
Found in bc125csv/exporter.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 handler.py has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from __future__ import print_function

import os
import sys
import argparse
Severity: Minor
Found in bc125csv/handler.py - About 2 hrs to fix

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

        def read(self):
            # Parsed channels
            channels = {}
            # Number of encountered errors
            errors = 0
    Severity: Minor
    Found in bc125csv/importer.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

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

        def exit_programming(self):
            result = self.send("EPG")
            if not result or result != "EPG,OK":
                raise ScannerException("Failed to leave programming mode.")
    Severity: Major
    Found in bc125csv/scanner.py and 1 other location - About 1 hr to fix
    bc125csv/scanner.py on lines 137..140

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

    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 enter_programming(self):
            result = self.send("PRG")
            if not result or result != "PRG,OK":
                raise ScannerException("Failed to enter programming mode.")
    Severity: Major
    Found in bc125csv/scanner.py and 1 other location - About 1 hr to fix
    bc125csv/scanner.py on lines 142..145

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

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

        def command_shell(self):
            scanner = self.get_scanner()
    
            if isinstance(scanner, VirtualScanner):
                print("Not all commands are emulated by the virtual scanner device.", 
    Severity: Minor
    Found in bc125csv/handler.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 command_import has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def command_import(self):
            scanner = self.get_scanner()
            fh = self.get_input_handle()
    
            importer = Importer(fh)
    Severity: Minor
    Found in bc125csv/handler.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

        def parse_lockout(self, value):
            """Parses and validates a channel lockout setting."""
            try:
                return self.parse_flag(value)
            except ParseError:
    Severity: Major
    Found in bc125csv/importer.py and 1 other location - About 1 hr to fix
    bc125csv/importer.py on lines 121..126

    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

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

        def get_scanner(self):
            # Virtual scanner requested
            if self.params.noscanner:
                self.print_verbose("Using virtual scanner device.")
                return VirtualScanner()
    Severity: Minor
    Found in bc125csv/handler.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

        def parse_priority(self, value):
            """Parses and validates a channel priority setting."""
            try:
                return self.parse_flag(value)
            except ParseError:
    Severity: Major
    Found in bc125csv/importer.py and 1 other location - About 1 hr to fix
    bc125csv/importer.py on lines 128..133

    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

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

        def parse_tqcode(self, value):
            """Parses a channel CTCSS tone or DCS code."""
            if value is None:
                return 0
    
    
    Severity: Minor
    Found in bc125csv/importer.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, index, name, frequency, modulation="AUTO", tqcode=0, 
    Severity: Major
    Found in bc125csv/scanner.py - About 1 hr to fix

      Function handle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle(self):
              if self.params.version:
                  return self.print_version()
              
              # No command given
      Severity: Minor
      Found in bc125csv/handler.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 command_export has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def command_export(self):
              scanner = self.get_scanner()
              fh = self.get_output_handle()
      
              self.print_verbose("Entering programming mode")
      Severity: Minor
      Found in bc125csv/handler.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 writeread has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def writeread(self, command):
              """Fake the handling of certain commands."""
              # Get model
              if command == "MDL":
                  return "MDL,VIRTUAL"
      Severity: Minor
      Found in bc125csv/scanner.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 self.command_shell()
      Severity: Major
      Found in bc125csv/handler.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return self.command_import()
        Severity: Major
        Found in bc125csv/handler.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return "DCS " + DCS_CODES[self.tqcode - 128]
          Severity: Major
          Found in bc125csv/scanner.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return "CIN,OK"
            Severity: Major
            Found in bc125csv/scanner.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return CTCSS_TONES.index(ctcss) + 64
              Severity: Major
              Found in bc125csv/importer.py - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language