OpenGems/redis_web_manager

View on GitHub

Showing 4 of 4 total issues

Function renderMemory has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function renderMemory(node, data) {
        const labels = data.map(d => humanizeDate(d['date']));
        const memories = data.map(d => d['memory']);
        const used_memory = memories.map(x => parseInt(x['used_memory'], 10));
        const used_memory_rss = memories.map(x => parseInt(x['used_memory_rss'], 10));
Severity: Major
Found in app/assets/javascripts/redis_web_manager/dashboard.js - About 3 hrs to fix

    Function renderCpu has 66 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function renderCpu(node, data) {
            const labels = data.map(d => humanizeDate(d['date']));
            const cpus = data.map(d => d['cpu']);
            const used_cpu_sys = cpus.map(x => parseInt(x['used_cpu_sys'], 10));
            const used_cpu_user = cpus.map(x => parseInt(x['used_cpu_user']));
    Severity: Major
    Found in app/assets/javascripts/redis_web_manager/dashboard.js - About 2 hrs to fix

      Function renderClient has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function renderClient(node, data) {
              const labels = data.map(d => humanizeDate(d['date']));
              const clients = data.map(d => d['client']);
              const connected_clients = clients.map(x => parseInt(x['connected_clients'], 10));
              const blocked_clients = clients.map(x => parseInt(x['blocked_clients'], 10));
      Severity: Minor
      Found in app/assets/javascripts/redis_web_manager/dashboard.js - About 1 hr to fix

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

            def check_attrs
              unless redises.is_a?(::Hash)
                raise(ArgumentError, 'Invalid redises hash, use like that { test: Redis.new }')
              end
              redises.each do |k, v|
        Severity: Minor
        Found in lib/redis_web_manager.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

        Severity
        Category
        Status
        Source
        Language