enwords/enwords

View on GitHub

Showing 16 of 16 total issues

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

$(function () {
  'use strict';

  var $nextPage     = $('.next_page');
  var $inputWord    = $('.input-word');
Severity: Major
Found in app/assets/javascripts/training/grammar.js and 1 other location - About 1 day to fix
app/assets/javascripts/training/spelling.js on lines 1..37

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

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

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

$(function () {
  'use strict';

  var $nextPage     = $('.next_page');
  var $inputWord    = $('.input-word');
Severity: Major
Found in app/assets/javascripts/training/spelling.js and 1 other location - About 1 day to fix
app/assets/javascripts/training/grammar.js on lines 1..37

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

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

  function initQtip() {
    $selectedWord.qtip({
      position: {
        my: 'bottom left',
        at: 'top right',
Severity: Major
Found in app/assets/javascripts/translate.js - About 3 hrs to fix

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

      class PhrasalVerbsController < ApplicationController
        before_action :authenticate_user!
    
        def index
          result =
    Severity: Major
    Found in app/controllers/grammar/eng/phrasal_verbs_controller.rb and 1 other location - About 3 hrs to fix
    app/controllers/grammar/eng/idioms_controller.rb on lines 2..34

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

    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

      class IdiomsController < ApplicationController
        before_action :authenticate_user!
    
        def index
          result =
    Severity: Major
    Found in app/controllers/grammar/eng/idioms_controller.rb and 1 other location - About 3 hrs to fix
    app/controllers/grammar/eng/phrasal_verbs_controller.rb on lines 2..34

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

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

            text: function(event, api) {
              $.ajax({
                url: '/api/web/translations',
                data: {
                  word: $(this).text(),
    Severity: Major
    Found in app/assets/javascripts/translate.js - About 2 hrs to fix

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

          def create
            @user = User.new(secure_params)
      
            respond_to do |format|
              if @user.save
      Severity: Minor
      Found in app/controllers/admin/users_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/admin/sentences_controller.rb on lines 18..27

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

      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 create
            @sentence = Sentence.new(sentence_params)
      
            respond_to do |format|
              if @sentence.save
      Severity: Minor
      Found in app/controllers/admin/sentences_controller.rb and 1 other location - About 1 hr to fix
      app/controllers/admin/users_controller.rb on lines 25..34

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

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

        def update_with_password(params, *options)
          current_password = params.delete(:current_password)
      
          if params[:password].blank?
            params.delete(:password)
      Severity: Minor
      Found in app/models/user.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 text has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def text
            result = "*#{word.value}*"
            result << ' '
            result << "_[#{word_transcription}]_ " if word_transcription.present?
      
      
      Severity: Minor
      Found in app/services/sentence/by_word.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 execute has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def execute
            unless word
              tr = yandex_translate
              return tr ? { translation: tr, text: text, youglish: youglish, sound_url: sound_url, from: from, to: to } : nil
            end
      Severity: Minor
      Found in app/services/word/translate.rb - 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

      Method process_word has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_word
            unless word
              return I18n.t('telegram.process_message.only_one_word', locale: :ru) if clean_text.split(' ').size > 1
      
              return I18n.t('telegram.process_message.go_premium', locale: :ru) unless telegram_chat_user.premium?
      Severity: Minor
      Found in app/services/telegram/process_message.rb - 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

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

          def update_trans(trans)
            return unless word && trans
            return if word.data&.dig('trans', to)
      
            data = word.data || {}
      Severity: Minor
      Found in app/services/word/translate.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

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

          def build_get_response(url, params = {})
            uri       = URI(url)
            uri.query = URI.encode_www_form(params)
            response  = Net::HTTP.get_response(uri)
            response  = Net::HTTP.get_response(URI.parse(response.header['location'])) if response.code == '301'
      Severity: Minor
      Found in app/services/api/skyeng.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

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

          def execute
            result =
              if status
                case status
                when 'learning' then learning
      Severity: Minor
      Found in app/services/word/by_status.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

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

          def update_word_status
            return unless telegram_chat
      
            if word && word.language == telegram_chat_user.learning_language
              Word::UpdateState.run(ids: [word.id], to_state: 'learning', user: telegram_chat_user)
      Severity: Minor
      Found in app/services/telegram/process_message.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