SpeciesFileGroup/taxonworks

View on GitHub
app/models/source/bibtex.rb

Summary

Maintainability
F
3 days
Test Coverage

File bibtex.rb has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'citeproc'
require 'csl/styles'
require 'namecase'

# Bibtex - Subclass of Source that represents most references.
Severity: Minor
Found in app/models/source/bibtex.rb - About 6 hrs to fix

    Class Bibtex has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Source::Bibtex < Source
    
      attr_accessor :authors_to_create
    
      include Shared::OriginRelationship
    Severity: Minor
    Found in app/models/source/bibtex.rb - About 5 hrs to fix

      Method to_bibtex has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

        def to_bibtex
          b = BibTeX::Entry.new(bibtex_type: bibtex_type)
      
          ::BIBTEX_FIELDS.each do |f|
            if (!self.send(f).blank?) && !(f == :bibtex_type)
      Severity: Minor
      Found in app/models/source/bibtex.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 set_cached has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def set_cached
          if errors.empty?
            attributes_to_update = {}
      
            attributes_to_update[:author] = get_bibtex_names('author') if authors.reload.size > 0
      Severity: Minor
      Found in app/models/source/bibtex.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 has too many lines. [27/25]
      Open

        def create_related_people_and_roles
          return false if !self.valid? ||
            self.new_record? ||
            (self.author.blank? && self.editor.blank?) ||
            self.roles.count > 0
      Severity: Minor
      Found in app/models/source/bibtex.rb by rubocop

      This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

      Method to_bibtex has 39 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def to_bibtex
          b = BibTeX::Entry.new(bibtex_type: bibtex_type)
      
          ::BIBTEX_FIELDS.each do |f|
            if (!self.send(f).blank?) && !(f == :bibtex_type)
      Severity: Minor
      Found in app/models/source/bibtex.rb - About 1 hr to fix

        Method create_related_people_and_roles has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create_related_people_and_roles
            return false if !self.valid? ||
              self.new_record? ||
              (self.author.blank? && self.editor.blank?) ||
              self.roles.count > 0
        Severity: Minor
        Found in app/models/source/bibtex.rb - About 1 hr to fix

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

            def create_related_people_and_roles
              return false if !self.valid? ||
                self.new_record? ||
                (self.author.blank? && self.editor.blank?) ||
                self.roles.count > 0
          Severity: Minor
          Found in app/models/source/bibtex.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 validate_year_suffix has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def validate_year_suffix
              a = get_author
              unless year_suffix.blank? || year.blank? || a.blank?
                if new_record?
                  s = Source.where(author: a, year: year, year_suffix: year_suffix).first
          Severity: Minor
          Found in app/models/source/bibtex.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 year= has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def year=(value)
              if value.class == String
                value =~ /\A(\d\d\d\d)([a-zA-Z]*)\z/
                write_attribute(:year, $1.to_i) if $1
                write_attribute(:year_suffix, $2) if $2
          Severity: Minor
          Found in app/models/source/bibtex.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 namecase_bibtex_entry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def namecase_bibtex_entry(bibtex_entry)
              bibtex_entry.parse_names
              bibtex_entry.names.each do |n|
                n.first = NameCase(n.first) if n.first
                n.last = NameCase(n.last) if n.last
          Severity: Minor
          Found in app/models/source/bibtex.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 new_from_bibtex has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.new_from_bibtex(bibtex_entry = nil)
              return false if !bibtex_entry.kind_of?(::BibTeX::Entry)
          
              s = Source::Bibtex.new(bibtex_type: bibtex_entry.type.to_s)
          
          
          Severity: Minor
          Found in app/models/source/bibtex.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 authority_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def authority_name(reload = true)
              reload ? authors.reload : authors.load
              if !authors.any? # no normalized people, use string, !! not .any? because of in-memory setting?!
                if author.blank?
                  return nil
          Severity: Minor
          Found in app/models/source/bibtex.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 issn= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def issn=(value)
              write_attribute(:issn, value)
              unless value.blank?
                tw_issn = self.identifiers.where(type: 'Identifier::Global::Issn').first
                unless tw_issn.nil? || tw_issn.identifier != value
          Severity: Minor
          Found in app/models/source/bibtex.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 check_has_field has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

            def check_has_field
              valid = false
              TW_REQUIRED_FIELDS.each do |i|
                if !self[i].blank?
                  valid = true
          Severity: Minor
          Found in app/models/source/bibtex.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

          Use find_by instead of where.first.
          Open

                  s = Source.where(author: a, year: year, year_suffix: year_suffix).first
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop is used to identify usages of where.first and change them to use find_by instead.

          Example:

          # bad
          User.where(name: 'Bruce').first
          User.where(name: 'Bruce').take
          
          # good
          User.find_by(name: 'Bruce')

          Use find_by instead of where.first.
          Open

                if tw_isbn = self.identifiers.where(type: 'Identifier::Global::Isbn').first
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop is used to identify usages of where.first and change them to use find_by instead.

          Example:

          # bad
          User.where(name: 'Bruce').first
          User.where(name: 'Bruce').take
          
          # good
          User.find_by(name: 'Bruce')

          Use find_by instead of where.first.
          Open

                if tw_doi = self.identifiers.where(type: 'Identifier::Global::Doi').first
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop is used to identify usages of where.first and change them to use find_by instead.

          Example:

          # bad
          User.where(name: 'Bruce').first
          User.where(name: 'Bruce').take
          
          # good
          User.find_by(name: 'Bruce')

          Use stated_year.present? instead of !stated_year.blank?.
          Open

              if: -> { !month.blank? || !stated_year.blank? },
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use author.presence instead of author.blank? ? nil : author.
          Open

                author.blank? ? nil : author
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks code that can be written more easily using Object#presence defined by Active Support.

          Example:

          # bad
          a.present? ? a : nil
          
          # bad
          !a.present? ? nil : a
          
          # bad
          a.blank? ? nil : a
          
          # bad
          !a.blank? ? a : nil
          
          # good
          a.presence

          Example:

          # bad
          a.present? ? a : b
          
          # bad
          !a.present? ? b : a
          
          # bad
          a.blank? ? b : a
          
          # bad
          !a.blank? ? a : b
          
          # good
          a.presence || b

          Use month.present? instead of !month.blank?.
          Open

              if: -> { !month.blank? || !stated_year.blank? },
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use find_by instead of where.first.
          Open

                tw_issn = self.identifiers.where(type: 'Identifier::Global::Issn').first
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop is used to identify usages of where.first and change them to use find_by instead.

          Example:

          # bad
          User.where(name: 'Bruce').first
          User.where(name: 'Bruce').take
          
          # good
          User.find_by(name: 'Bruce')

          Specify an :inverse_of option.
          Open

            has_many :editor_roles, -> { order('roles.position ASC') }, class_name: 'SourceEditor',
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop looks for has(one|many) and belongsto associations where Active Record can't automatically determine the inverse association because of a scope or the options used. Using the blog with order scope example below, traversing the a Blog's association in both directions with blog.posts.first.blog would cause the blog to be loaded from the database twice.

          :inverse_of must be manually specified for Active Record to use the associated object in memory, or set to false to opt-out. Note that setting nil does not stop Active Record from trying to determine the inverse automatically, and is not considered a valid value for this.

          Example:

          # good
          class Blog < ApplicationRecord
            has_many :posts
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end

          Example:

          # bad
          class Blog < ApplicationRecord
            has_many :posts, -> { order(published_at: :desc) }
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          class Blog < ApplicationRecord
            has_many(:posts,
                     -> { order(published_at: :desc) },
                     inverse_of: :blog)
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          class Blog < ApplicationRecord
            with_options inverse_of: :blog do
              has_many :posts, -> { order(published_at: :desc) }
            end
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          # When you don't want to use the inverse association.
          class Blog < ApplicationRecord
            has_many(:posts,
                     -> { order(published_at: :desc) },
                     inverse_of: false)
          end

          Example:

          # bad
          class Picture < ApplicationRecord
            belongs_to :imageable, polymorphic: true
          end
          
          class Employee < ApplicationRecord
            has_many :pictures, as: :imageable
          end
          
          class Product < ApplicationRecord
            has_many :pictures, as: :imageable
          end
          
          # good
          class Picture < ApplicationRecord
            belongs_to :imageable, polymorphic: true
          end
          
          class Employee < ApplicationRecord
            has_many :pictures, as: :imageable, inverse_of: :imageable
          end
          
          class Product < ApplicationRecord
            has_many :pictures, as: :imageable, inverse_of: :imageable
          end

          Example:

          # bad
          # However, RuboCop can not detect this pattern...
          class Physician < ApplicationRecord
            has_many :appointments
            has_many :patients, through: :appointments
          end
          
          class Appointment < ApplicationRecord
            belongs_to :physician
            belongs_to :patient
          end
          
          class Patient < ApplicationRecord
            has_many :appointments
            has_many :physicians, through: :appointments
          end
          
          # good
          class Physician < ApplicationRecord
            has_many :appointments
            has_many :patients, through: :appointments
          end
          
          class Appointment < ApplicationRecord
            belongs_to :physician, inverse_of: :appointments
            belongs_to :patient, inverse_of: :appointments
          end
          
          class Patient < ApplicationRecord
            has_many :appointments
            has_many :physicians, through: :appointments
          end

          @see https://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

          Specify an :inverse_of option.
          Open

            has_many :author_roles, -> { order('roles.position ASC') }, class_name: 'SourceAuthor',
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop looks for has(one|many) and belongsto associations where Active Record can't automatically determine the inverse association because of a scope or the options used. Using the blog with order scope example below, traversing the a Blog's association in both directions with blog.posts.first.blog would cause the blog to be loaded from the database twice.

          :inverse_of must be manually specified for Active Record to use the associated object in memory, or set to false to opt-out. Note that setting nil does not stop Active Record from trying to determine the inverse automatically, and is not considered a valid value for this.

          Example:

          # good
          class Blog < ApplicationRecord
            has_many :posts
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end

          Example:

          # bad
          class Blog < ApplicationRecord
            has_many :posts, -> { order(published_at: :desc) }
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          class Blog < ApplicationRecord
            has_many(:posts,
                     -> { order(published_at: :desc) },
                     inverse_of: :blog)
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          class Blog < ApplicationRecord
            with_options inverse_of: :blog do
              has_many :posts, -> { order(published_at: :desc) }
            end
          end
          
          class Post < ApplicationRecord
            belongs_to :blog
          end
          
          # good
          # When you don't want to use the inverse association.
          class Blog < ApplicationRecord
            has_many(:posts,
                     -> { order(published_at: :desc) },
                     inverse_of: false)
          end

          Example:

          # bad
          class Picture < ApplicationRecord
            belongs_to :imageable, polymorphic: true
          end
          
          class Employee < ApplicationRecord
            has_many :pictures, as: :imageable
          end
          
          class Product < ApplicationRecord
            has_many :pictures, as: :imageable
          end
          
          # good
          class Picture < ApplicationRecord
            belongs_to :imageable, polymorphic: true
          end
          
          class Employee < ApplicationRecord
            has_many :pictures, as: :imageable, inverse_of: :imageable
          end
          
          class Product < ApplicationRecord
            has_many :pictures, as: :imageable, inverse_of: :imageable
          end

          Example:

          # bad
          # However, RuboCop can not detect this pattern...
          class Physician < ApplicationRecord
            has_many :appointments
            has_many :patients, through: :appointments
          end
          
          class Appointment < ApplicationRecord
            belongs_to :physician
            belongs_to :patient
          end
          
          class Patient < ApplicationRecord
            has_many :appointments
            has_many :physicians, through: :appointments
          end
          
          # good
          class Physician < ApplicationRecord
            has_many :appointments
            has_many :patients, through: :appointments
          end
          
          class Appointment < ApplicationRecord
            belongs_to :physician, inverse_of: :appointments
            belongs_to :patient, inverse_of: :appointments
          end
          
          class Patient < ApplicationRecord
            has_many :appointments
            has_many :physicians, through: :appointments
          end

          @see https://guides.rubyonrails.org/association_basics.html#bi-directional-associations @see https://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#module-ActiveRecord::Associations::ClassMethods-label-Setting+Inverses

          Use self.note.present? instead of !self.note.blank?.
          Open

              if !self.note.blank? && self.new_record?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if value.present? instead of unless value.blank?.
          Open

              unless value.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use concatenated_notes_string.present? instead of !concatenated_notes_string.blank?.
          Open

              b[:note] = concatenated_notes_string if !concatenated_notes_string.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

                write_attribute(:year, value)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use author.present? instead of !author.blank?.
          Open

              return true if !author.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

                write_attribute(:year_suffix, $2) if $2
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:month, v)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use self.send(f).present? instead of !self.send(f).blank?.
          Open

                if (!self.send(f).blank?) && !(f == :bibtex_type)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:isbn, value)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Prefer self[:attr] over read_attribute(:attr).
          Open

                read_attribute(:cached_nomenclature_date)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Avoid using update_columns because it skips validations.
          Open

                update_columns(attributes_to_update)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of methods which skip validations which are listed in https://guides.rubyonrails.org/active_record_validations.html#skipping-validations

          Methods may be ignored from this rule by configuring a Whitelist.

          Example:

          # bad
          Article.first.decrement!(:view_count)
          DiscussionBoard.decrement_counter(:post_count, 5)
          Article.first.increment!(:view_count)
          DiscussionBoard.increment_counter(:post_count, 5)
          person.toggle :active
          product.touch
          Billing.update_all("category = 'authorized', author = 'David'")
          user.update_attribute(:website, 'example.com')
          user.update_columns(last_request_at: Time.current)
          Post.update_counters 5, comment_count: -1, action_count: 1
          
          # good
          user.update(website: 'example.com')
          FileUtils.touch('file')

          Example: Whitelist: ["touch"]

          # bad
          DiscussionBoard.decrement_counter(:post_count, 5)
          DiscussionBoard.increment_counter(:post_count, 5)
          person.toggle :active
          
          # good
          user.touch

          Prefer self[:attr] over read_attribute(:attr).
          Open

              read_attribute(:journal)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use if value.present? instead of unless value.blank?.
          Open

              unless value.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use if value.present? instead of unless value.blank?.
          Open

              unless value.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

                write_attribute(:year, $1.to_i) if $1
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use if self.url.present? instead of unless self.url.blank?.
          Open

              URI(self.url) unless self.url.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

                write_attribute(:year, value) if self.year.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:note, value)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use year_suffix.present? instead of !year_suffix.blank?.
          Open

              b.year = year_with_suffix if !year_suffix.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Use self[i].present? instead of !self[i].blank?.
          Open

                if !self[i].blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:doi, value)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use if verbatim_keywords.present? instead of unless verbatim_keywords.blank?.
          Open

              b[:keywords] = verbatim_keywords     unless verbatim_keywords.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] over read_attribute(:attr).
          Open

              [read_attribute(:journal), (serial.blank? ? nil : serial.name)].compact.first
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          Use pages.present? instead of !pages.blank?.
          Open

                if bibtex_type == 'book' && !pages.blank?
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for code that can be written with simpler conditionals using Object#present? defined by Active Support.

          Interaction with Style/UnlessElse: The configuration of NotBlank will not produce an offense in the context of unless else if Style/UnlessElse is inabled. This is to prevent interference between the auto-correction of the two cops.

          Example: NotNilAndNotEmpty: true (default)

          # Converts usages of `!nil? && !empty?` to `present?`
          
          # bad
          !foo.nil? && !foo.empty?
          
          # bad
          foo != nil && !foo.empty?
          
          # good
          foo.present?

          Example: NotBlank: true (default)

          # Converts usages of `!blank?` to `present?`
          
          # bad
          !foo.blank?
          
          # bad
          not foo.blank?
          
          # good
          foo.present?

          Example: UnlessBlank: true (default)

          # Converts usages of `unless blank?` to `if present?`
          
          # bad
          something unless foo.blank?
          
          # good
          something if foo.present?

          Prefer self[:attr] = val over write_attribute(:attr, val).
          Open

              write_attribute(:issn, value)
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of the read_attribute or write_attribute methods and recommends square brackets instead.

          If an attribute is missing from the instance (for example, when initialized by a partial select) then read_attribute will return nil, but square brackets will raise an ActiveModel::MissingAttributeError.

          Explicitly raising an error in this situation is preferable, and that is why rubocop recommends using square brackets.

          Example:

          # bad
          x = read_attribute(:attr)
          write_attribute(:attr, val)
          
          # good
          x = self[:attr]
          self[:attr] = val

          TODO found
          Open

              #TODO This test for auth doesn't work with a new record.
          Severity: Minor
          Found in app/models/source/bibtex.rb by fixme

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

            def doi=(value)
              write_attribute(:doi, value)
              unless value.blank?
                if tw_doi = self.identifiers.where(type: 'Identifier::Global::Doi').first
                  if tw_doi.identifier != value
          Severity: Minor
          Found in app/models/source/bibtex.rb and 1 other location - About 45 mins to fix
          app/models/source/bibtex.rb on lines 563..572

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

          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 isbn=(value)
              write_attribute(:isbn, value)
              unless value.blank?
                if tw_isbn = self.identifiers.where(type: 'Identifier::Global::Isbn').first
                  if tw_isbn.identifier != value
          Severity: Minor
          Found in app/models/source/bibtex.rb and 1 other location - About 45 mins to fix
          app/models/source/bibtex.rb on lines 584..593

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

          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

              unless serial.nil?
                b[:journal] = serial.name
                issns  = serial.identifiers.where(type: 'Identifier::Global::Issn')
                unless issns.empty?
                  b[:issn] = issns.first.identifier # assuming the serial has only 1 ISSN
          Severity: Minor
          Found in app/models/source/bibtex.rb and 1 other location - About 15 mins to fix
          app/models/source/bibtex.rb on lines 720..724

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

          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

              unless serial.nil?
                b[:journal] = serial.name
                issns = serial.identifiers.where(type: 'Identifier::Global::Issn')
                unless issns.empty?
                  b[:issn] = issns.first.identifier # assuming the serial has only 1 ISSN
          Severity: Minor
          Found in app/models/source/bibtex.rb and 1 other location - About 15 mins to fix
          app/models/source/bibtex.rb on lines 712..716

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

          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

          Freeze mutable objects assigned to constants.
          Open

            GRAPH_ENTRY_POINTS = [:origin_relationships]
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

          Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.

          Example: EnforcedStyle: literals (default)

          # bad
          CONST = [1, 2, 3]
          
          # good
          CONST = [1, 2, 3].freeze
          
          # good
          CONST = <

          Example: EnforcedStyle: strict

          # bad
          CONST = Something.new
          
          # bad
          CONST = Struct.new do
            def foo
              puts 1
            end
          end
          
          # good
          CONST = Something.new.freeze
          
          # good
          CONST = Struct.new do
            def foo
              puts 1
            end
          end.freeze

          Freeze mutable objects assigned to constants.
          Open

            BIBTEX_REQUIRED_FIELDS = {
              article: [:author, :title, :journal, :year],
              book: [:author, :editor, :title, :publisher, :year],
              booklet: [:title],
              conference: [:author, :title, :booktitle, :year],
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).

          Strict mode can be used to freeze all constants, rather than just literals. Strict mode is considered an experimental feature. It has not been updated with an exhaustive list of all methods that will produce frozen objects so there is a decent chance of getting some false positives. Luckily, there is no harm in freezing an already frozen object.

          Example: EnforcedStyle: literals (default)

          # bad
          CONST = [1, 2, 3]
          
          # good
          CONST = [1, 2, 3].freeze
          
          # good
          CONST = <

          Example: EnforcedStyle: strict

          # bad
          CONST = Something.new
          
          # bad
          CONST = Struct.new do
            def foo
              puts 1
            end
          end
          
          # good
          CONST = Something.new.freeze
          
          # good
          CONST = Struct.new do
            def foo
              puts 1
            end
          end.freeze

          Re-enable Metrics/MethodLength cop with # rubocop:enable after disabling it.
          Open

            # rubocop:disable Metrics/MethodLength
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          Do not use Time.now without zone. Use one of Time.zone.now, Time.current, Time.now.in_time_zone, Time.now.utc, Time.now.getlocal, Time.now.xmlschema, Time.now.iso8601, Time.now.jisx0301, Time.now.rfc3339, Time.now.httpdate, Time.now.to_i, Time.now.to_f instead.
          Open

              min_year: 1000, max_year: Time.now.year + 2,
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of Time methods without zone.

          Built on top of Ruby on Rails style guide (https://github.com/rubocop-hq/rails-style-guide#time) and the article http://danilenko.org/2012/7/6/rails_timezones/

          Two styles are supported for this cop. When EnforcedStyle is 'strict' then only use of Time.zone is allowed.

          When EnforcedStyle is 'flexible' then it's also allowed to use Time.intimezone.

          Example: EnforcedStyle: strict

          # `strict` means that `Time` should be used with `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # bad
          Time.current
          Time.at(timestamp).in_time_zone
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')

          Example: EnforcedStyle: flexible (default)

          # `flexible` allows usage of `in_time_zone` instead of `zone`.
          
          # bad
          Time.now
          Time.parse('2015-03-02 19:05:37')
          
          # good
          Time.zone.now
          Time.zone.parse('2015-03-02 19:05:37')
          
          # good
          Time.current
          Time.at(timestamp).in_time_zone

          Prefer the new style validations validates :column, presence: value over validates_presence_of.
          Open

            validates_presence_of :year,
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of old-style attribute validation macros.

          Example:

          # bad
          validates_acceptance_of :foo
          validates_confirmation_of :foo
          validates_exclusion_of :foo
          validates_format_of :foo
          validates_inclusion_of :foo
          validates_length_of :foo
          validates_numericality_of :foo
          validates_presence_of :foo
          validates_absence_of :foo
          validates_size_of :foo
          validates_uniqueness_of :foo
          
          # good
          validates :foo, acceptance: true
          validates :foo, confirmation: true
          validates :foo, exclusion: true
          validates :foo, format: true
          validates :foo, inclusion: true
          validates :foo, length: true
          validates :foo, numericality: true
          validates :foo, presence: true
          validates :foo, absence: true
          validates :foo, size: true
          validates :foo, uniqueness: true

          Prefer the new style validations validates :column, presence: value over validates_presence_of.
          Open

            validates_presence_of :month,
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of old-style attribute validation macros.

          Example:

          # bad
          validates_acceptance_of :foo
          validates_confirmation_of :foo
          validates_exclusion_of :foo
          validates_format_of :foo
          validates_inclusion_of :foo
          validates_length_of :foo
          validates_numericality_of :foo
          validates_presence_of :foo
          validates_absence_of :foo
          validates_size_of :foo
          validates_uniqueness_of :foo
          
          # good
          validates :foo, acceptance: true
          validates :foo, confirmation: true
          validates :foo, exclusion: true
          validates :foo, format: true
          validates :foo, inclusion: true
          validates :foo, length: true
          validates :foo, numericality: true
          validates :foo, presence: true
          validates :foo, absence: true
          validates :foo, size: true
          validates :foo, uniqueness: true

          Prefer the new style validations validates :column, inclusion: value over validates_inclusion_of.
          Open

            validates_inclusion_of :month,
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of old-style attribute validation macros.

          Example:

          # bad
          validates_acceptance_of :foo
          validates_confirmation_of :foo
          validates_exclusion_of :foo
          validates_format_of :foo
          validates_inclusion_of :foo
          validates_length_of :foo
          validates_numericality_of :foo
          validates_presence_of :foo
          validates_absence_of :foo
          validates_size_of :foo
          validates_uniqueness_of :foo
          
          # good
          validates :foo, acceptance: true
          validates :foo, confirmation: true
          validates :foo, exclusion: true
          validates :foo, format: true
          validates :foo, inclusion: true
          validates :foo, length: true
          validates :foo, numericality: true
          validates :foo, presence: true
          validates :foo, absence: true
          validates :foo, size: true
          validates :foo, uniqueness: true

          Prefer the new style validations validates :column, inclusion: value over validates_inclusion_of.
          Open

            validates_inclusion_of :bibtex_type,
          Severity: Minor
          Found in app/models/source/bibtex.rb by rubocop

          This cop checks for the use of old-style attribute validation macros.

          Example:

          # bad
          validates_acceptance_of :foo
          validates_confirmation_of :foo
          validates_exclusion_of :foo
          validates_format_of :foo
          validates_inclusion_of :foo
          validates_length_of :foo
          validates_numericality_of :foo
          validates_presence_of :foo
          validates_absence_of :foo
          validates_size_of :foo
          validates_uniqueness_of :foo
          
          # good
          validates :foo, acceptance: true
          validates :foo, confirmation: true
          validates :foo, exclusion: true
          validates :foo, format: true
          validates :foo, inclusion: true
          validates :foo, length: true
          validates :foo, numericality: true
          validates :foo, presence: true
          validates :foo, absence: true
          validates :foo, size: true
          validates :foo, uniqueness: true

          There are no issues that match your filters.

          Category
          Status