CORE-POS/IS4C

View on GitHub
pos/is4c-nf/scale-drivers/drivers/NewMagellan/HidSharp/Platform/Linux/LinuxHidDevice.cs

Summary

Maintainability
C
1 day
Test Coverage

Method GetInfo has a Cognitive Complexity of 52 (exceeds 20 allowed). Consider refactoring.
Open

        internal unsafe bool GetInfo()
        {
            IntPtr udev = NativeMethods.udev_new();
            if (IntPtr.Zero != udev)
            {

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

Method GetInfo has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        internal unsafe bool GetInfo()
        {
            IntPtr udev = NativeMethods.udev_new();
            if (IntPtr.Zero != udev)
            {

    Avoid deeply nested control flow statements.
    Open

                                        if (TryParseReportDescriptor(device, out parser, out _reportDescriptor))
                                        {
                                            // Follow the Windows convention: No Report ID? Report ID is 0.
                                            // So, it's always one byte above the parser's result.
                                            _maxInput = parser.InputReportMaxLength; if (_maxInput > 0) { _maxInput++; }

      Avoid too many return statements within this method.
      Open

                      if (NativeMethods.ioctl(handle, NativeMethods.HIDIOCGRDESC, ref desc) < 0) { return false; }

        Avoid too many return statements within this method.
        Open

                        parser.Parse(desc.value); reportDescriptor = desc.value; return true;

          There are no issues that match your filters.

          Category
          Status