Birdie0/qna_maker

View on GitHub

Showing 8 of 8 total issues

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

      case response.code
      when 204
        nil
      when 400
        raise BadArgumentError, response.parse['error']['message'].join(' ')
Severity: Major
Found in lib/qna_maker/endpoints/update_alterations.rb and 4 other locations - About 1 hr to fix
lib/qna_maker/endpoints/delete_kb.rb on lines 13..27
lib/qna_maker/endpoints/delete_kb.rb on lines 45..59
lib/qna_maker/endpoints/publish_kb.rb on lines 13..27
lib/qna_maker/endpoints/update_kb.rb on lines 24..38

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

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 5 locations. Consider refactoring.
Open

      case response.code
      when 204
        nil
      when 400
        raise BadArgumentError, response.parse['error']['message'].join(' ')
Severity: Major
Found in lib/qna_maker/endpoints/delete_kb.rb and 4 other locations - About 1 hr to fix
lib/qna_maker/endpoints/delete_kb.rb on lines 45..59
lib/qna_maker/endpoints/publish_kb.rb on lines 13..27
lib/qna_maker/endpoints/update_alterations.rb on lines 18..32
lib/qna_maker/endpoints/update_kb.rb on lines 24..38

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

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 5 locations. Consider refactoring.
Open

      case response.code
      when 204
        nil
      when 400
        raise BadArgumentError, response.parse['error']['message'].join(' ')
Severity: Major
Found in lib/qna_maker/endpoints/delete_kb.rb and 4 other locations - About 1 hr to fix
lib/qna_maker/endpoints/delete_kb.rb on lines 13..27
lib/qna_maker/endpoints/publish_kb.rb on lines 13..27
lib/qna_maker/endpoints/update_alterations.rb on lines 18..32
lib/qna_maker/endpoints/update_kb.rb on lines 24..38

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

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 5 locations. Consider refactoring.
Open

      case response.code
      when 204
        nil
      when 400
        raise BadArgumentError, response.parse['error']['message'].join(' ')
Severity: Major
Found in lib/qna_maker/endpoints/update_kb.rb and 4 other locations - About 1 hr to fix
lib/qna_maker/endpoints/delete_kb.rb on lines 13..27
lib/qna_maker/endpoints/delete_kb.rb on lines 45..59
lib/qna_maker/endpoints/publish_kb.rb on lines 13..27
lib/qna_maker/endpoints/update_alterations.rb on lines 18..32

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

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 5 locations. Consider refactoring.
Open

      case response.code
      when 204
        nil
      when 400
        raise BadArgumentError, response.parse['error']['message'].join(' ')
Severity: Major
Found in lib/qna_maker/endpoints/publish_kb.rb and 4 other locations - About 1 hr to fix
lib/qna_maker/endpoints/delete_kb.rb on lines 13..27
lib/qna_maker/endpoints/delete_kb.rb on lines 45..59
lib/qna_maker/endpoints/update_alterations.rb on lines 18..32
lib/qna_maker/endpoints/update_kb.rb on lines 24..38

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

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

    def train_kb(feedback_records = [])
      feedback_records = feedback_records.map do |record|
        { userId: record[0],
          userQuestion: record[1],
          kbQuestion: record[2],
Severity: Minor
Found in lib/qna_maker/endpoints/train_kb.rb - About 1 hr to fix

    Method generate_answer has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def generate_answer(question, top = 1)
          response = @http.post(
            "#{BASE_URL}/#{@knowledgebase_id}/generateAnswer",
            json: { question: question, top: top }
          )
    Severity: Minor
    Found in lib/qna_maker/endpoints/generate_answer.rb - About 1 hr to fix

      Method update_kb has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def update_kb(add: [], delete: [], add_urls: [])
            response = @http.patch(
              "#{BASE_URL}/#{@knowledgebase_id}",
              json: {
                add: {
      Severity: Minor
      Found in lib/qna_maker/endpoints/update_kb.rb - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language