Showing 1,155 of 1,155 total issues
Method create
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
respond_to do |format|
begin
Agent.transaction do
@family = params[:family]
Method update
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@errors = []
error = Struct.new(:id, :msg, :v)
params[:system_configurations].each do |id, value|
begin
Function _hideKeypad
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
_hideKeypad: function(field, duration) {
var inst = this._curInst;
if (!inst || (field && inst != $.data(field, PROP_NAME))) {
return;
}
Method get_manifestation_list_tsv_csv
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.get_manifestation_list_tsv_csv(manifestation_ids, selected_column = [])
csv_sep = SystemConfiguration.get("set_output_format_type") ? "\t" : ","
bom = "\xEF\xBB\xBF"
bom.force_encoding("UTF-8")
data = ""
Method generate_manifestation_list
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.generate_manifestation_list(solr_search, output_type, current_user, search_condition_summary, cols=[], threshold = nil, &block)
solr_search.build {
paginate :page => 1, :per_page => Manifestation.count
}
Method common_field
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def common_field
source = @manifestation.catalog.nacsis_identifier if @manifestation.catalog
if source == 'NACSIS' || source == 'NDL' || source.nil?
source = 'ORG'
Method volg_group
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def volg_group # book only
results = []
identifier_type = IdentifierType.where(:name => 'isbn').first
manifestations = @manifestation.series_statement.try(:manifestations)
if manifestations
Method update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
check_can_access_purchase_request
if @user
@purchase_request = @user.purchase_requests.find(params[:id])
Method update
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def update
@relationship_family = @series_statement_relationship.relationship_family
before_relationship_series_statement_ids = @series_statement_relationship.relationship_family.series_statements.map(&:id)
SeriesStatementRelationship.transaction do
@series_statement_relationship.update_attributes!(params[:series_statement_relationship])
Method create_pdf_item_identifier_list
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_pdf_item_identifier_list(start_number, end_number)
dir_base = "#{Rails.root}/private/system/barcode_list/#{self.id}/original/"
FileUtils.mkdir_p(dir_base) unless FileTest.exist?(dir_base)
filename = "barcode.pdf"
Method adhoc_text_field_query
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def adhoc_text_field_query(qwords, model, fields, nest = true, op = :default)
model_string_fields = {}
Sunspot::Setup.for(model).fields.each do |sunspot_field|
next unless sunspot_field.type.is_a?(Sunspot::Type::StringType)
model_string_fields[sunspot_field.name] = sunspot_field.indexed_name
Method set_attributes
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def set_attributes(record, datas, sheet, opts)
opts.each do |attr_name, (field_key, *convs)|
set_nil_when_blank = false
allow_overwrite = true
value = sheet.field_data(datas, field_key)
Method index
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@bookstores = Bookstore.all
@bookstore_id = params[:bookstore_id]
@ordered_start_at = params[:ordered_start_at]
@ordered_end_at = params[:ordered_end_at]
Method prepare_options
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_options
@subject_types = SubjectType.all
@carrier_types = CarrierType.all
@sub_carrier_types = SubCarrierType.all
@manifestation_types = ManifestationType.all#ManifestationType.series
Method add_output_column_spec
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_output_column_spec(fields, field_ext, field_names, for_join, for_separate, spec_hash = OUTPUT_COLUMN_SPEC)
fields = [fields].flatten.map(&:to_s)
unknown = fields - OUTPUT_COLUMN_FIELDS
unless unknown.empty?
raise ArgumentError, "unknown field: #{unknown.join(', ')}"
Method create_contributor_values
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_contributor_values(add_contributors)
realizes = []
(add_contributors || []).each do |add_contributor|
next if add_contributor[:id].blank?
if add_contributor[:id].to_i != 0
Method create_creator_values
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_creator_values(add_creators)
creates = []
(add_creators || []).each do |add_creator|
next if add_creator[:id].blank?
if add_creator[:id].to_i != 0
Method create_publisher_values
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_publisher_values(add_publishers)
produces = []
(add_publishers || []).each do |add_publisher|
next if add_publisher[:id].blank?
if add_publisher[:id].to_i != 0
Similar blocks of code found in 3 locations. Consider refactoring. Open
def calculate_count
self.started_at = Time.zone.now
Manifestation.find_each do |manifestation|
daily_count = manifestation.reserves.created(self.start_date, self.end_date).size
#manifestation.update_attributes({:daily_reserves_count => daily_count, :total_count => manifestation.total_count + daily_count})
- Read upRead up
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 52.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 3 locations. Consider refactoring. Open
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height());
- Read upRead up
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 58.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76