Showing 178 of 178 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
showSection() {
this.expandTarget.classList.add('display-none');
this.collapseTarget.classList.remove('display-none');
this.sectionTarget.classList.remove('display-none');
}
- 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 65.
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
Method index
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@current_round_id = current_round_id
if params[:baselines] == 'on'
@search = policy_scope(Submission)
.where(
Function getInnerText
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
getInnerText: function(node) {
// gets the text we want to use for sorting for a cell.
// strips leading and trailing whitespace.
// this is *not* a generic getInnerText function; it's special to sorttable.
// for example, you can override the cell text with a customkey attribute.
Method change
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
drop_view :leaderboards
drop_table :team_participants
remove_column :submissions, :team_id
drop_table :teams
Method day
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def day
submissions = @challenge
.submissions
.where(
"participant_id = ? and created_at >= ?",
Function dean_addEvent
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function dean_addEvent(element, type, handler) {
if (element.addEventListener) {
element.addEventListener(type, handler, false);
} else {
// assign each event handler a unique ID
- Read upRead up
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 week
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def week
submissions = @challenge
.submissions
.where(
"participant_id = ? and created_at >= ?", @participant_id,
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
drop_view :leaderboard
create_view :leaderboards,
"
SELECT * FROM (
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
Method grading_params
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def grading_params
case params[:grading_status]
when 'graded'
if params[:grading_message].blank?
grading_message = 'Graded successfully'
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
create_view :leaderboards,
"
SELECT s.id,
s.challenge_id,
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
drop_view :leaderboards;
create_view :leaderboards, "
SELECT s.id,
s.competition_id,
Method change
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
drop_view :leaderboards
create_view :leaderboard,
"
SELECT * FROM (
Method round
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def round
submissions = @challenge
.submissions
.where(
"post_challenge IS FALSE and participant_id = ? and challenge_round_id = ?",
Method submission_params
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def submission_params
params
.require(:submission)
.permit(
:challenge_id,
Method change
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change
create_table :visits do |t|
t.string :visit_token
t.string :visitor_token
Method webhook
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def webhook
if params[:api_key] == ENV['MAILCHIMP_INBOUND_API_KEY']
if params['type'] == 'unsubscribe' && params['data']['list_id'] == ENV['MAILCHIMP_LIST_ID']
participant = Participant.where(email: params['data']['email']).first
if participant
- Read upRead up
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_submissions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def set_submissions(challenge_id, grading_status, after, challenge_round_id)
if grading_status.blank? && after.blank? && challenge_round_id.blank?
@submissions = Submission.where(challenge_id: challenge_id)
elsif grading_status.blank? && after.blank? && challenge_round_id.present?
@submissions = Submission.where("challenge_id = ? AND challenge_round_id = ?",
- Read upRead up
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
create_table :login_activities do |t|
t.string :scope
t.string :strategy
t.string :identity
t.boolean :success
- 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 50.
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
create_table :login_activities do |t|
t.text :scope
t.text :strategy
t.text :identity
t.boolean :success
- 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 50.
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