File listing_form.js
has 400 lines of code (exceeds 250 allowed). Consider refactoring. Open
window.ST = window.ST || {};
(function(module) {
/* global disable_submit_button */
/* global set_textarea_maxlength */
Function initialize_new_listing_form
has 114 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.initialize_new_listing_form = function(
fileDefaultText,
fileBtnText,
locale,
share_type_message,
Function initialize_new_listing_form
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
fileDefaultText,
fileBtnText,
locale,
share_type_message,
date_message,
Function should_show_menu_for
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
function should_show_menu_for(attribute, selected_attributes, attribute_array) {
if (attribute_selected(attribute, selected_attributes)) {
return false;
} else if (attribute == "category") {
if (attribute_array.length < 2) {
Function initialize_edit_listing_form_selectors
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
module.initialize_edit_listing_form_selectors = function(locale, attribute_array, listing_form_menu_titles, category, subcategory, listing_shape, id) {
var ordered_attributes = ["category", "subcategory", "listing_shape"];
// Selected values (string or null required)
category = category ? "" + category : null;
Function initialize_edit_listing_form_selectors
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
module.initialize_edit_listing_form_selectors = function(locale, attribute_array, listing_form_menu_titles, category, subcategory, listing_shape, id) {
Avoid deeply nested control flow statements. Open
if (subcategories.length == 1) {
selected_attributes["subcategory"] = subcategories[0]["id"];
}
Avoid deeply nested control flow statements. Open
if (attribute_selected("subcategory", selected_attributes)) {
listing_shapes = get_listing_shapes_for_subcategory(selected_attributes["category"], selected_attributes["subcategory"], attribute_array);
} else {
listing_shapes = get_listing_shapes_for_category(selected_attributes["category"], attribute_array);
}
Avoid deeply nested control flow statements. Open
if (listing_shapes.length === 1) {
selected_attributes["listing_shape"] = listing_shapes[0]["id"];
}
Function select_listing_form_menu_link
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function select_listing_form_menu_link(link, locale, attribute_array, listing_form_menu_titles, ordered_attributes, selected_attributes) {
Function update_listing_form_view
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
function update_listing_form_view(locale, attribute_array, listing_form_menu_titles, ordered_attributes, selected_attributes) {
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return (listing_shapes.length > 1);
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return false;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (attribute_array.length < 2) {
// If there is exactly 1 category, it should be marked automatically as selected,
// without showing the form.
if (attribute_array.length == 1) {
selected_attributes["category"] = attribute_array[0]["id"];
- 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 62.
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 2 locations. Consider refactoring. Open
if (subcategories.length < 2) {
// If there is exactly 1 subcategory, it should be marked automatically as selected,
// without showing the form.
if (subcategories.length == 1) {
selected_attributes["subcategory"] = subcategories[0]["id"];
- 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 62.
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 2 locations. Consider refactoring. Open
$('#help_valid_until_link').click(function() { $('#help_valid_until').lightbox_me({centered: true, zIndex: 1000000}); });
- 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 46.
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