pouyana/gutenbergtranslator

View on GitHub

Showing 7 of 7 total issues

Method initilize has 10 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initilize(gutenberg,licence,ebook_number,title,author,illustrator,release_date,lang,charset,size)
Severity: Major
Found in app/helpers/text_to_paragraphs.rb - About 1 hr to fix

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

      def dataMiner
        wikidata = Hash.new
        setHasArticle(false)
        if(parsedPage=getParser)
          if parsedPage["entities"].has_key?("-1") and parsedPage["entities"]["success"]="1"
    Severity: Minor
    Found in app/models/wikidata.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

          "Ebook Nr: "        + @ebook_number.to_s + "\n" +
          "Title: "           + @title.to_s + "\n" +
          "Author: "          + @author.to_s + "\n" +
          "Release Date: "    + @release_date.to_s + "\n" +
          "Language: "        + @lang.to_s + "\n" +
    Severity: Major
    Found in app/helpers/rdfreader.rb and 1 other location - About 1 hr to fix
    app/helpers/text_to_paragraphs.rb on lines 22..28

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

    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

          "Gutennberg Info: " + @gutenberg.to_s + "\n" +
          "License:\n"        + @licence.to_s + "\n" +
          "Ebook Nr: "        + @ebook_number.to_s + "\n" +
          "Title: "           + @title.to_s + "\n" +
          "Author: "          + @author.to_s + "\n" +
    Severity: Major
    Found in app/helpers/text_to_paragraphs.rb and 1 other location - About 1 hr to fix
    app/helpers/rdfreader.rb on lines 23..29

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

    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 initilize has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def initilize(ebook_number,title,author,release_date,lang,size ,downloads)
    Severity: Major
    Found in app/helpers/rdfreader.rb - About 50 mins to fix

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

        def self.bookresolver(bookid)
          result = false
          text = false
          book=Book.find(bookid)
          combination=["",0,8]
      Severity: Minor
      Found in app/models/book.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 search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.search(search)
          if search
            if search[:number]
              find(:all, :conditions => ['number LIKE ?', "%#{search[:search]}%"])
            elsif search[:title]
      Severity: Minor
      Found in app/models/book.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

      Severity
      Category
      Status
      Source
      Language