ShogunPanda/pincerna

View on GitHub

Showing 13 of 19 total issues

Function generateTOC has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function generateTOC() {
  if ($('#filecontents').length === 0) return;
  var _toc = $('<ol class="top"></ol>');
  var show = false;
  var toc = _toc;
Severity: Major
Found in docs/js/app.js - About 2 hrs to fix

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

    function searchItem() {
      for (var i = 0; i < searchCache.length / 50; i++) {
        var item = searchCache[searchIndex];
        var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
        var matchString = regexSearchString;
    Severity: Minor
    Found in docs/js/full_list.js - 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 fullListSearch has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function fullListSearch() {
      // generate cache
      searchCache = [];
      $('#full_list li').each(function() {
        var link = $(this).find('.object_link a');
    Severity: Minor
    Found in docs/js/full_list.js - About 1 hr to fix

      Function summaryToggle has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function summaryToggle() {
        $('.summary_toggle').click(function() {
          if (localStorage) {
            localStorage.summaryCollapsed = $(this).text();
          }
      Severity: Minor
      Found in docs/js/app.js - About 1 hr to fix

        Method format_value has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def format_value(value, modifier = nil, precision = 3)
              rounded = round_float(value.scalar.to_f, precision)
        
              if modifier != :raw then
                format = "%0.#{precision}f"
        Severity: Minor
        Found in lib/pincerna/unit_conversion.rb - 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

        Method perform_filtering has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def perform_filtering(query)
              rv = []
              interface_filter ||= query.empty? ? /.+/ : /#{query}/i
        
              execute_command("/usr/sbin/networksetup", "-listnetworkserviceorder").split(/\n\n/).each do |i|
        Severity: Minor
        Found in lib/pincerna/vpn.rb - 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

        Method format_forecast has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def format_forecast(place, image, link, current, forecast, wind, temperature_unit, speed_unit)
        Severity: Major
        Found in lib/pincerna/weather.rb - About 1 hr to fix

          Method process_results has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def process_results(results)
                results.map do |result|
                  title = "#{result[:connected] ? "Disconnect from" : "Connect to"} #{result[:name]}"
                  subtitle = "Action this item to #{result[:connected] ? "disconnect from" : "connect to"} the VPN service."
                  arg = "#{result[:connected] ? "disconnect" : "connect"} service \"#{result[:name]}\""
          Severity: Minor
          Found in lib/pincerna/vpn.rb - 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

          Method get_interfaces_names has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_interfaces_names
                rv = {"lo0" => "Loopback"}
          
                names = execute_command("/usr/sbin/networksetup", "-listallhardwareports").split(/\n\n/)
                names.shift # Discard first whitespace
          Severity: Minor
          Found in lib/pincerna/ip.rb - 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

          Method get_local_addresses has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_local_addresses
                rv = []
                names = get_interfaces_names
          
                # Split by interfaces
          Severity: Minor
          Found in lib/pincerna/ip.rb - 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

          Method handle_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle_request(type, args)
                # Enqueue the request. This will wait to avoid too many requests.
                Server.enqueue_request
          
                # Execute the request, if none were added.
          Severity: Minor
          Found in lib/pincerna/server.rb - 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

          Method perform_filtering has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def perform_filtering(value, from, to, with_rate, multiple)
          Severity: Minor
          Found in lib/pincerna/unit_conversion.rb - About 35 mins to fix

            Method perform_filtering has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def perform_filtering(query)    
                  @interface_filter ||= query.empty? ? /.*/ : /#{query}/i
            
                  # Get local addresses
                  rv = get_local_addresses
            Severity: Minor
            Found in lib/pincerna/ip.rb - 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