yegor256/0rsk

View on GitHub

Showing 26 of 26 total issues

Method notify_all has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def notify_all
  users.fetch.each do |login|
    next unless telechats.wired?(login)
    chat = telechats.chat_of(login)
    fresh = telepings.fresh(login)
Severity: Minor
Found in front/front_telegram.rb - 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

Method query has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

  def query(id, query)
    where = []
    words = []
    unless id.positive?
      query.strip.downcase.split.each do |w|
Severity: Minor
Found in objects/triples.rb - 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

Method query has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def query(id, query)
    where = []
    words = []
    unless id.positive?
      query.strip.downcase.split.each do |w|
Severity: Major
Found in objects/triples.rb - About 2 hrs to fix

    File 0rsk.rb has 252 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    $stdout.sync = true
    
    require 'glogin'
    require 'glogin/codec'
    require 'haml'
    Severity: Minor
    Found in 0rsk.rb - About 2 hrs to fix

      Method reply has 48 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def reply(msg, login)
        case msg
        when %r{^/done$}
          left = tasks(login: login).fetch(limit: 100)
          if left.empty?
      Severity: Minor
      Found in front/front_telegram.rb - About 1 hr to fix

        Method task_list has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def task_list(list)
          if list.count < 8
            [
              'Here is a full list of them:',
              list.map do |t|
        Severity: Minor
        Found in front/front_telegram.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

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

            } else {
              $('#marker').addClass('down').removeClass('up');
              $('#impact option[type="negative"]').attr('hidden', false);
              $('#impact option[type="positive"]').attr('hidden', true);
              $('#impact').val(5);
        Severity: Major
        Found in js/triple.js and 1 other location - About 1 hr to fix
        js/triple.js on lines 66..71

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

        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

            if ($(this).is(':checked')) {
              $('#marker').addClass('up').removeClass('down');
              $('#impact option[type="negative"]').attr('hidden', true);
              $('#impact option[type="positive"]').attr('hidden', false);
              $('#impact').val(5);
        Severity: Major
        Found in js/triple.js and 1 other location - About 1 hr to fix
        js/triple.js on lines 71..76

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

        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 auto has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function auto(kind, uri) {
          "use strict";
          var $input = $("#" + kind);
          $input.on("input", function() {
            $("#" + kind + "_detach").addClass("red");
        Severity: Minor
        Found in js/triple.js - About 1 hr to fix

          Method query has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def query(query)
              Rsk::Query.new(
                @pgsql,
                [
                  'SELECT * FROM (SELECT DISTINCT ON (task.id) task.id, task.plan,',
          Severity: Minor
          Found in objects/tasks.rb - About 1 hr to fix

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

            get '/effects' do
              offset = [(params[:offset] || '0').to_i, 0].max
              limit = (params[:limit] || '25').to_i
              query = params[:q] || ''
              haml :effects, layout: :layout, locals: merged(
            Severity: Major
            Found in 0rsk.rb and 2 other locations - About 1 hr to fix
            0rsk.rb on lines 197..209
            0rsk.rb on lines 225..237

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

            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

            get '/plans' do
              offset = [(params[:offset] || '0').to_i, 0].max
              limit = (params[:limit] || '25').to_i
              query = params[:q] || ''
              haml :plans, layout: :layout, locals: merged(
            Severity: Major
            Found in 0rsk.rb and 2 other locations - About 1 hr to fix
            0rsk.rb on lines 197..209
            0rsk.rb on lines 211..223

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

            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

            get '/risks' do
              offset = [(params[:offset] || '0').to_i, 0].max
              limit = (params[:limit] || '25').to_i
              query = params[:q] || ''
              haml :risks, layout: :layout, locals: merged(
            Severity: Major
            Found in 0rsk.rb and 2 other locations - About 1 hr to fix
            0rsk.rb on lines 211..223
            0rsk.rb on lines 225..237

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

            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

            Method reply has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def reply(msg, login)
              case msg
              when %r{^/done$}
                left = tasks(login: login).fetch(limit: 100)
                if left.empty?
            Severity: Minor
            Found in front/front_telegram.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 task_list has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            def task_list(list)
              if list.count < 8
                [
                  'Here is a full list of them:',
                  list.map do |t|
            Severity: Minor
            Found in front/front_telegram.rb - About 1 hr to fix

              Method notify_all has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def notify_all
                users.fetch.each do |login|
                  next unless telechats.wired?(login)
                  chat = telechats.chat_of(login)
                  fresh = telepings.fresh(login)
              Severity: Minor
              Found in front/front_telegram.rb - About 1 hr to fix

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

                  def delete(id)
                    @pgsql.transaction do |t|
                      triple = fetch(id: id.to_i)[0]
                      raise Rsk::Urror, "Triple ##{id} not found in your project ##{@project}" if triple.nil?
                      if t.exec('SELECT * FROM part WHERE id = $1 AND project = $2', [triple[:cid], @project]).empty?
                Severity: Minor
                Found in objects/triples.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

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

                get '/plans.json' do
                  content_type('application/json')
                  JSON.pretty_generate(
                    plans.fetch(query: params[:query] || '').map do |r|
                      {
                Severity: Major
                Found in front/front_triple.rb and 2 other locations - About 55 mins to fix
                front/front_triple.rb on lines 23..34
                front/front_triple.rb on lines 39..50

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

                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

                get '/causes.json' do
                  content_type('application/json')
                  JSON.pretty_generate(
                    causes.fetch(query: params[:query] || '').map do |r|
                      {
                Severity: Major
                Found in front/front_triple.rb and 2 other locations - About 55 mins to fix
                front/front_triple.rb on lines 39..50
                front/front_triple.rb on lines 72..83

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

                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

                get '/risks.json' do
                  content_type('application/json')
                  JSON.pretty_generate(
                    risks.fetch(query: params[:query] || '').map do |r|
                      {
                Severity: Major
                Found in front/front_triple.rb and 2 other locations - About 55 mins to fix
                front/front_triple.rb on lines 23..34
                front/front_triple.rb on lines 72..83

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

                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

                Severity
                Category
                Status
                Source
                Language