From f4a22851a1e5fae6a6796755afad75b0a574f2b9 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 13:09:37 +0200 Subject: [PATCH 01/12] Update rubocop and add basic checks --- .rubocop.yml | 47 ++++++ .rubocop_todo.yml | 414 ++++++++++++++++++++++++++++++++++++++++++++++ Gemfile.lock | 8 +- 3 files changed, 465 insertions(+), 4 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..da59ef22 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,47 @@ +inherit_from: .rubocop_todo.yml + +Style/HashSyntax: + EnforcedStyle: ruby19 + +# Things deprecated in current ruby API +Lint/DeprecatedClassMethods: + Enabled: true + +# Do not compare with nil. Use .nil? instead +Style/NilComparison: + Enabled: true + +Style/EmptyLineBetweenDefs: + Enabled: true + +# Offense count: 4 +# Cop supports --auto-correct. +Style/EmptyLines: + Enabled: false + +# Offense count: 1 +Style/EmptyLinesAroundAccessModifier: + Enabled: false + +# Offense count: 21 +# Cop supports --auto-correct. +Style/EmptyLinesAroundBody: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/EmptyLiteral: + Enabled: false + +# Offense count: 1 +# Configuration parameters: Exclude. +Style/FileName: + Enabled: false + +AllCops: + Include: + - Rakefile + - config.ru + Exclude: + - db/schema.rb + - features/**/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..0b6e7d2b --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,414 @@ +# This configuration was generated by `rubocop --auto-gen-config` +# on 2014-07-21 12:48:09 +0200 using RuboCop version 0.24.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 3 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Enabled: false + +# Offense count: 4 +Lint/BlockAlignment: + Enabled: false + +# Offense count: 1 +Lint/LiteralInCondition: + Enabled: false + +# Offense count: 2 +Lint/Loop: + Enabled: false + +# Offense count: 3 +Lint/ParenthesesAsGroupedExpression: + Enabled: false + +# Offense count: 13 +# Cop supports --auto-correct. +Lint/RescueException: + Enabled: false + +# Offense count: 1 +Lint/ShadowingOuterLocalVariable: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +Lint/UnusedBlockArgument: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/UnusedMethodArgument: + Enabled: false + +# Offense count: 6 +Lint/UselessAssignment: + Enabled: false + +# Offense count: 1 +Lint/Void: + Enabled: false + +# Offense count: 17 +Style/AccessorMethodName: + Enabled: false + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. +Style/AlignHash: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/AlignParameters: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/AndOr: + Enabled: false + +# Offense count: 1 +Style/BlockNesting: + Max: 4 + +# Offense count: 2 +# Cop supports --auto-correct. +Style/Blocks: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/BracesAroundHashParameters: + Enabled: false + +# Offense count: 1 +Style/CaseEquality: + Enabled: false + +# Offense count: 20 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/ClassAndModuleChildren: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/ClassCheck: + Enabled: false + +# Offense count: 8 +# Configuration parameters: CountComments. +Style/ClassLength: + Max: 524 + +# Offense count: 1 +Style/ClassVars: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: PreferredMethods. +Style/CollectionMethods: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Enabled: false + +# Offense count: 4 +# Configuration parameters: Keywords. +Style/CommentAnnotation: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Style/CommentIndentation: + Enabled: false + +# Offense count: 10 +Style/CyclomaticComplexity: + Max: 16 + +# Offense count: 5 +# Cop supports --auto-correct. +Style/DeprecatedHashMethods: + Enabled: false + +# Offense count: 228 +Style/Documentation: + Enabled: false + +# Offense count: 150 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/DotPosition: + Enabled: false + +# Offense count: 9 +Style/DoubleNegation: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs. +Style/EmptyLineBetweenDefs: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Style/EmptyLines: + Enabled: false + +# Offense count: 1 +Style/EmptyLinesAroundAccessModifier: + Enabled: false + +# Offense count: 21 +# Cop supports --auto-correct. +Style/EmptyLinesAroundBody: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/EmptyLiteral: + Enabled: false + +# Offense count: 1 +# Configuration parameters: Exclude. +Style/FileName: + Enabled: false + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/For: + Enabled: false + +# Offense count: 8 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Enabled: false + +# Offense count: 214 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/HashSyntax: + Enabled: false + +# Offense count: 27 +# Configuration parameters: MaxLineLength. +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/IndentArray: + Enabled: false + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/IndentHash: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +Style/IndentationConsistency: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +Style/IndentationWidth: + Enabled: false + +# Offense count: 7 +# Cop supports --auto-correct. +Style/LeadingCommentSpace: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Enabled: false + +# Offense count: 515 +# Configuration parameters: AllowURI. +Style/LineLength: + Max: 217 + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/MethodDefParentheses: + Enabled: false + +# Offense count: 68 +# Configuration parameters: CountComments. +Style/MethodLength: + Max: 134 + +# Offense count: 14 +# Cop supports --auto-correct. +Style/NegatedIf: + Enabled: false + +# Offense count: 18 +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/Next: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/NumericLiterals: + MinDigits: 15 + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowSafeAssignment. +Style/ParenthesesAroundCondition: + Enabled: false + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Enabled: false + +# Offense count: 2 +# Configuration parameters: NamePrefixBlacklist. +Style/PredicateName: + Enabled: false + +# Offense count: 3 +# Configuration parameters: SupportedStyles. +Style/RaiseArgs: + EnforcedStyle: compact + +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantBegin: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Enabled: false + +# Offense count: 8 +# Cop supports --auto-correct. +Style/RedundantSelf: + Enabled: false + +# Offense count: 10 +# Configuration parameters: MaxSlashes. +Style/RegexpLiteral: + Enabled: false + +# Offense count: 1 +Style/SelfAssignment: + Enabled: false + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/SignalException: + Enabled: false + +# Offense count: 1 +# Configuration parameters: Methods. +Style/SingleLineBlockParams: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfMethodIsEmpty. +Style/SingleLineMethods: + Enabled: false + +# Offense count: 285 +# Cop supports --auto-correct. +Style/SingleSpaceBeforeFirstArg: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Style/SpaceAfterComma: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/SpaceAroundEqualsInParameterDefault: + Enabled: false + +# Offense count: 5 +# Cop supports --auto-correct. +Style/SpaceAroundOperators: + Enabled: false + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/SpaceBeforeSemicolon: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +Style/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 4 +# Cop supports --auto-correct. +Style/SpaceInsideBrackets: + Enabled: false + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. +Style/SpaceInsideHashLiteralBraces: + Enabled: false + +# Offense count: 577 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/StringLiterals: + Enabled: false + +# Offense count: 1 +Style/Tab: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/TrailingBlankLines: + Enabled: false + +# Offense count: 24 +# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. +Style/TrailingComma: + Enabled: false + +# Offense count: 38 +# Cop supports --auto-correct. +Style/TrailingWhitespace: + Enabled: false + +# Offense count: 8 +# Cop supports --auto-correct. +Style/WordArray: + MinSize: 5 diff --git a/Gemfile.lock b/Gemfile.lock index fdfd7edd..6f8468e9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -221,7 +221,7 @@ GEM activesupport (>= 3.0.0) cocaine (~> 0.5.3) mime-types - parser (2.1.9) + parser (2.2.0.pre.3) ast (>= 1.1, < 3.0) slop (~> 3.4, >= 3.4.5) pdf-core (0.2.5) @@ -310,9 +310,9 @@ GEM rspec-mocks (~> 3.0.0) rspec-support (~> 3.0.0) rspec-support (3.0.2) - rubocop (0.22.0) + rubocop (0.24.1) json (>= 1.7.7, < 2) - parser (~> 2.1.9) + parser (>= 2.2.0.pre.3, < 3.0) powerpack (~> 0.0.6) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.4) @@ -336,7 +336,7 @@ GEM multi_json simplecov-html (~> 0.8.0) simplecov-html (0.8.0) - slop (3.5.0) + slop (3.6.0) spring (1.1.2) spring-commands-rspec (1.0.2) spring (>= 0.9.1) From 763f864dc9b8207789870601c2d4605730e69347 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 14:27:32 +0200 Subject: [PATCH 02/12] Fix basic style issues with rubocop --- .rubocop.yml | 64 +++++++++++++-- .rubocop_todo.yml | 82 ------------------- Gemfile | 4 + Gemfile.lock | 8 ++ .../admin/difficulty_levels_controller.rb | 1 - app/controllers/admin/events_controller.rb | 6 +- app/controllers/admin/questions_controller.rb | 4 +- .../admin/social_events_controller.rb | 2 - app/controllers/admin/stats_controller.rb | 4 +- app/controllers/admin/venue_controller.rb | 1 - .../event_attachments_controller.rb | 6 +- app/controllers/schedule_controller.rb | 2 - .../users/omniauth_callbacks_controller.rb | 2 +- app/mailers/mailbot.rb | 3 - app/models/conference.rb | 1 - app/models/datatable.rb | 1 - app/models/dietary_choice.rb | 1 - app/models/event.rb | 12 ++- app/models/event_attachment.rb | 3 - app/models/openid.rb | 2 +- app/models/room.rb | 1 - app/models/track.rb | 1 - app/models/venue.rb | 14 ++-- app/models/vote.rb | 1 - config/boot.rb | 2 +- config/environment.rb | 2 +- .../20121223122842_create_venue_table.rb | 1 - .../20130113105652_create_email_table.rb | 1 - ...0130515125823_change_attachment_default.rb | 1 + .../20131229072532_registrations_vchoices.rb | 2 +- .../20140610163947_create_event_users.rb | 1 - ...23203_add_events_per_week_to_conference.rb | 3 +- db/seeds.rb | 2 +- spec/models/conference_spec.rb | 6 +- spec/support/login_macros.rb | 2 - spec/views/home/index.html.haml_spec.rb | 2 +- 36 files changed, 108 insertions(+), 143 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index da59ef22..9c4550a3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,31 +11,79 @@ Lint/DeprecatedClassMethods: Style/NilComparison: Enabled: true +# Use one empty line between method definitions Style/EmptyLineBetweenDefs: Enabled: true -# Offense count: 4 -# Cop supports --auto-correct. +# There should be only one empty line in designated place Style/EmptyLines: + Enabled: true + +# Keep a blank line before and after private. +Style/EmptyLinesAroundAccessModifier: + Enabled: true + +# Do not insert empty line after class definition and before closing class +Style/EmptyLinesAroundBody: + Enabled: true + +# Use hash literal {} instead of Hash.new +Style/EmptyLiteral: + Enabled: true + +# Prefer `each` over `for i` +Style/For: + Enabled: true + +# Wrap your assignment in condition if you mean it, otherwise it is most likely equality check +Lint/AssignmentInCondition: + Enabled: true + +# Align blocks of code properly +Lint/BlockAlignment: + Enabled: true + +# Do not use literal in conditions. We have it enabled for now +Lint/LiteralInCondition: Enabled: false +# Prefer `Kernel#loop -> break` over `begin -> while` +Lint/Loop: + Enabled: true + +# do not put space before arguments when they are in parentheses +Lint/ParenthesesAsGroupedExpression: + Enabled: true + +# Offense count: 13 +# Cop supports --auto-correct. +Lint/RescueException: + Enabled: true + # Offense count: 1 -Style/EmptyLinesAroundAccessModifier: +Lint/ShadowingOuterLocalVariable: Enabled: false -# Offense count: 21 +# Offense count: 5 # Cop supports --auto-correct. -Style/EmptyLinesAroundBody: +Lint/UnusedBlockArgument: Enabled: false # Offense count: 2 # Cop supports --auto-correct. -Style/EmptyLiteral: +Lint/UnusedMethodArgument: + Enabled: false + +# Offense count: 6 +Lint/UselessAssignment: Enabled: false # Offense count: 1 -# Configuration parameters: Exclude. -Style/FileName: +Lint/Void: + Enabled: false + +# Offense count: 17 +Style/AccessorMethodName: Enabled: false AllCops: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0b6e7d2b..2839ff76 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -5,58 +5,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 -# Configuration parameters: AllowSafeAssignment. -Lint/AssignmentInCondition: - Enabled: false - -# Offense count: 4 -Lint/BlockAlignment: - Enabled: false - -# Offense count: 1 -Lint/LiteralInCondition: - Enabled: false - -# Offense count: 2 -Lint/Loop: - Enabled: false - -# Offense count: 3 -Lint/ParenthesesAsGroupedExpression: - Enabled: false - -# Offense count: 13 -# Cop supports --auto-correct. -Lint/RescueException: - Enabled: false - -# Offense count: 1 -Lint/ShadowingOuterLocalVariable: - Enabled: false - -# Offense count: 5 -# Cop supports --auto-correct. -Lint/UnusedBlockArgument: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Lint/UnusedMethodArgument: - Enabled: false - -# Offense count: 6 -Lint/UselessAssignment: - Enabled: false - -# Offense count: 1 -Lint/Void: - Enabled: false - -# Offense count: 17 -Style/AccessorMethodName: - Enabled: false - # Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. @@ -156,41 +104,11 @@ Style/DotPosition: Style/DoubleNegation: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs. -Style/EmptyLineBetweenDefs: - Enabled: false - -# Offense count: 4 -# Cop supports --auto-correct. -Style/EmptyLines: - Enabled: false - -# Offense count: 1 -Style/EmptyLinesAroundAccessModifier: - Enabled: false - -# Offense count: 21 -# Cop supports --auto-correct. -Style/EmptyLinesAroundBody: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -Style/EmptyLiteral: - Enabled: false - # Offense count: 1 # Configuration parameters: Exclude. Style/FileName: Enabled: false -# Offense count: 1 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/For: - Enabled: false - # Offense count: 8 # Configuration parameters: MinBodyLength. Style/GuardClause: diff --git a/Gemfile b/Gemfile index 6720b8db..0de00755 100644 --- a/Gemfile +++ b/Gemfile @@ -128,3 +128,7 @@ group :test do # Extracted from RSpec 3 stub_model and mock_model gem 'rspec-activemodel-mocks' end + +group :development, :test do + gem 'debugger' +end diff --git a/Gemfile.lock b/Gemfile.lock index 6f8468e9..e5ead004 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,6 +90,7 @@ GEM coffee-script-source execjs coffee-script-source (1.7.0) + columnize (0.8.9) coveralls (0.7.0) multi_json (~> 1.3) rest-client @@ -99,6 +100,12 @@ GEM d3_rails (3.4.6) railties (>= 3.1.0) database_cleaner (1.3.0) + debugger (1.6.8) + columnize (>= 0.3.1) + debugger-linecache (~> 1.2.0) + debugger-ruby_core_source (~> 1.3.5) + debugger-linecache (1.2.0) + debugger-ruby_core_source (1.3.5) devise (3.2.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -399,6 +406,7 @@ DEPENDENCIES coveralls d3_rails database_cleaner + debugger devise factory_girl_rails font-awesome-rails diff --git a/app/controllers/admin/difficulty_levels_controller.rb b/app/controllers/admin/difficulty_levels_controller.rb index 17335117..a52cefcf 100644 --- a/app/controllers/admin/difficulty_levels_controller.rb +++ b/app/controllers/admin/difficulty_levels_controller.rb @@ -25,6 +25,5 @@ class Admin::DifficultyLevelsController < ApplicationController flash[:error] = "Difficulty Levels update failed." redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) end - end end diff --git a/app/controllers/admin/events_controller.rb b/app/controllers/admin/events_controller.rb index 6b664ec6..ffabf501 100644 --- a/app/controllers/admin/events_controller.rb +++ b/app/controllers/admin/events_controller.rb @@ -18,7 +18,7 @@ module Admin @mystates = [] @mytypes = [] - @eventstats = Hash.new + @eventstats = {} @totallength = 0 @machine_states.each do |mystate| @@ -50,7 +50,7 @@ module Admin @totallength += myevent.event_type.length end - if @eventstats[mytype.title] == nil + if @eventstats[mytype.title].nil? @eventstats[mytype.title] = { 'count' => events_mytype.count, 'length' => events_mytype.count * mytype.length } end @@ -150,7 +150,7 @@ module Admin @event = Event.find(params[:id]) @ratings = @event.votes.includes(:user) - if votes = current_user.votes.find_by_event_id(params[:id]) + if (votes = current_user.votes.find_by_event_id(params[:id])) votes.update_attributes(rating: params[:rating]) else @myvote = @event.votes.build diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index d23e8da7..838f587e 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -79,7 +79,7 @@ class Admin::QuestionsController < ApplicationController a.delete end flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}" - end + end rescue ActiveRecord::RecordInvalid flash[:error] = "Could not delete question." end @@ -91,6 +91,6 @@ class Admin::QuestionsController < ApplicationController end @questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id) - @questions_conference = @conference.questions + @questions_conference = @conference.questions end end diff --git a/app/controllers/admin/social_events_controller.rb b/app/controllers/admin/social_events_controller.rb index 3411fc44..336e7cef 100644 --- a/app/controllers/admin/social_events_controller.rb +++ b/app/controllers/admin/social_events_controller.rb @@ -11,7 +11,5 @@ class Admin::SocialEventsController < ApplicationController else redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.') end - end - end diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index feee3a34..758c46f9 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -48,7 +48,7 @@ module Admin if @events.count > 0 start_date = @events.minimum('created_at').strftime('%Y-%m-%d') end_date = @events.maximum('created_at').strftime('%Y-%m-%d') - unless start_date == nil || end_date == nil + unless start_date.nil? || end_date.nil? @events_time = var_time(start_date, end_date, @events, 'created_at') end end @@ -87,7 +87,7 @@ module Admin typelength += myevent.event_type.length @totallength += myevent.event_type.length end - if @eventstats[mytype.title] == nil + if @eventstats[mytype.title].nil? @eventstats[mytype.title] = { 'count' => events_mytype.count, 'length' => events_mytype.count * mytype.length } end diff --git a/app/controllers/admin/venue_controller.rb b/app/controllers/admin/venue_controller.rb index 4c8696d6..ccef1259 100644 --- a/app/controllers/admin/venue_controller.rb +++ b/app/controllers/admin/venue_controller.rb @@ -19,5 +19,4 @@ class Admin::VenueController < ApplicationController @venue = @conference.venue render :venue_info end - end diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index a7e63b47..7a7c1514 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -71,8 +71,10 @@ class EventAttachmentsController < ApplicationController :content_type => 'text/html', :layout => false } - format.json { render json: [@upload.to_jq_upload].to_json, status: :created, - location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) } + format.json do + render json: [@upload.to_jq_upload].to_json, status: :created, + location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) + end else format.html { render action: "new" } format.json { render json: @upload.errors, status: :unprocessable_entity } diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index 2a00ae7c..de984489 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -1,5 +1,4 @@ class ScheduleController < ApplicationController - layout "application" def index @@ -14,5 +13,4 @@ class ScheduleController < ApplicationController @today = @conference.start_date.strftime("%Y-%m-%d") end end - end diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 61b4088f..4fa0341c 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -13,7 +13,7 @@ module Users openid = Openid.find_for_oauth(auth_hash) # Get or create openid # If openid exists and is associated with a user, sign in with associated user, # even if the email of the associated user and the email of the provided openid are different - unless user = openid.user + unless (user = openid.user) user = User.find_for_auth(auth_hash, current_user) # Get or create users end diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index a7bd0807..ea40fa12 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -6,7 +6,6 @@ class Mailbot < ActionMailer::Base person.email, conference.email_settings.registration_subject, conference.email_settings.generate_registration_email(conference, person)) - end def acceptance_mail(event) @@ -16,7 +15,6 @@ class Mailbot < ActionMailer::Base person.email, conference.email_settings.accepted_subject, conference.email_settings.generate_accepted_email(event)) - end def rejection_mail(event) @@ -63,5 +61,4 @@ class Mailbot < ActionMailer::Base :subject => subject, :body => body) end - end diff --git a/app/models/conference.rb b/app/models/conference.rb index 543f64d0..fae89ad8 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -102,7 +102,6 @@ class Conference < ActiveRecord::Base return media_types end - ## # Checks if the user is registered to the conference # diff --git a/app/models/datatable.rb b/app/models/datatable.rb index 922e85b6..339d4897 100644 --- a/app/models/datatable.rb +++ b/app/models/datatable.rb @@ -18,7 +18,6 @@ class Datatable } end - def data [] end diff --git a/app/models/dietary_choice.rb b/app/models/dietary_choice.rb index ffe896b7..961346b8 100644 --- a/app/models/dietary_choice.rb +++ b/app/models/dietary_choice.rb @@ -3,5 +3,4 @@ class DietaryChoice < ActiveRecord::Base belongs_to :conference has_many :registrations - end diff --git a/app/models/event.rb b/app/models/event.rb index ae2830e7..53d696e0 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -197,11 +197,15 @@ class Event < ActiveRecord::Base errors.add(:user_biography, 'must be filled out') if submitter.biography_word_count == 0 end + # TODO: create a module to be mixed into model to perform same operation + # venue.rb has same functionality which can be shared + # TODO: rename guid to UUID as guid is specifically Microsoft term def generate_guid - begin - guid = SecureRandom.urlsafe_base64 - end while self.class.where(guid: guid).exists? - self.guid = guid + loop do + @guid = SecureRandom.urlsafe_base64 + break if !self.class.where(guid: guid).any? + end + self.guid = @guid end def set_week diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index e90e0f23..98d3c547 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -18,12 +18,9 @@ class EventAttachment < ActiveRecord::Base "delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), "delete_type" => "DELETE" } - end #:path => ":rails_root/public/system/:attachment/:id/:style/:filename", # :url => "/system/:attachment/:id/:style/:filename" #has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"} - - end diff --git a/app/models/openid.rb b/app/models/openid.rb index 2795cd44..2fc1c245 100644 --- a/app/models/openid.rb +++ b/app/models/openid.rb @@ -11,7 +11,7 @@ class Openid < ActiveRecord::Base if openid.new_record? openid.email = auth.info.email - if existing_openid = Openid.where(email: openid.email).first + if (existing_openid = Openid.where(email: openid.email).first) openid.user_id = existing_openid.user_id end end diff --git a/app/models/room.rb b/app/models/room.rb index 6ce73d1e..f4611a7d 100644 --- a/app/models/room.rb +++ b/app/models/room.rb @@ -15,5 +15,4 @@ class Room < ActiveRecord::Base # end while Person.where(:guid => guid).exists? self.guid = guid end - end diff --git a/app/models/track.rb b/app/models/track.rb index 94201a73..beb033c9 100644 --- a/app/models/track.rb +++ b/app/models/track.rb @@ -14,5 +14,4 @@ class Track < ActiveRecord::Base # end while Person.where(:guid => guid).exists? self.guid = guid end - end diff --git a/app/models/venue.rb b/app/models/venue.rb index abf6e22d..21934332 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -11,13 +11,17 @@ class Venue < ActiveRecord::Base content_type: [/jpg/, /jpeg/, /png/, /gif/], size: { in: 0..500.kilobytes } accepts_nested_attributes_for :lodgings, allow_destroy: true + private + # TODO: create a module to be mixed into model to perform same operation + # event.rb has same functionality which can be shared + # TODO: rename guid to UUID as guid is specifically Microsoft term def generate_guid - begin - guid = SecureRandom.urlsafe_base64 - end while Venue.where(:guid => guid).exists? - self.guid = guid + loop do + @guid = SecureRandom.urlsafe_base64 + break if !Venue.where(:guid => guid).any? + end + self.guid = @guid end - end diff --git a/app/models/vote.rb b/app/models/vote.rb index 9d174ba6..2ef9729f 100644 --- a/app/models/vote.rb +++ b/app/models/vote.rb @@ -4,5 +4,4 @@ class Vote < ActiveRecord::Base belongs_to :user belongs_to :event delegate :name, to: :user - end diff --git a/config/boot.rb b/config/boot.rb index 4489e586..f2830ae3 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -3,4 +3,4 @@ require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) diff --git a/config/environment.rb b/config/environment.rb index 6b0a63d2..760642c1 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -7,7 +7,7 @@ begin CONFIG = YAML.load_file(path)[Rails.env] rescue Exception puts "Error while parsing config file #{path}" - CONFIG = Hash.new + CONFIG = {} end # Initialize the rails application diff --git a/db/migrate/20121223122842_create_venue_table.rb b/db/migrate/20121223122842_create_venue_table.rb index 0c7c0c57..38e7115f 100644 --- a/db/migrate/20121223122842_create_venue_table.rb +++ b/db/migrate/20121223122842_create_venue_table.rb @@ -15,5 +15,4 @@ class CreateVenueTable < ActiveRecord::Migration def down drop_table :venues end - end diff --git a/db/migrate/20130113105652_create_email_table.rb b/db/migrate/20130113105652_create_email_table.rb index ba6bf60e..0d566bcd 100644 --- a/db/migrate/20130113105652_create_email_table.rb +++ b/db/migrate/20130113105652_create_email_table.rb @@ -12,7 +12,6 @@ class CreateEmailTable < ActiveRecord::Migration t.text :confirmed_email_template t.timestamps end - end def down diff --git a/db/migrate/20130515125823_change_attachment_default.rb b/db/migrate/20130515125823_change_attachment_default.rb index f2acc537..89701f12 100644 --- a/db/migrate/20130515125823_change_attachment_default.rb +++ b/db/migrate/20130515125823_change_attachment_default.rb @@ -2,6 +2,7 @@ class ChangeAttachmentDefault < ActiveRecord::Migration def up change_column_default(:event_attachments, :public, true) end + def down change_column_default(:event_attachments, :public, nil) end diff --git a/db/migrate/20131229072532_registrations_vchoices.rb b/db/migrate/20131229072532_registrations_vchoices.rb index 76f430e4..ae1d824e 100644 --- a/db/migrate/20131229072532_registrations_vchoices.rb +++ b/db/migrate/20131229072532_registrations_vchoices.rb @@ -1,6 +1,6 @@ class RegistrationsVchoices < ActiveRecord::Migration def up - create_table :registrations_vchoices, :id => false do |t| + create_table :registrations_vchoices, :id => false do |t| t.references :registration, :vchoice end end diff --git a/db/migrate/20140610163947_create_event_users.rb b/db/migrate/20140610163947_create_event_users.rb index 91043d20..7d0fdbe3 100644 --- a/db/migrate/20140610163947_create_event_users.rb +++ b/db/migrate/20140610163947_create_event_users.rb @@ -30,6 +30,5 @@ class CreateEventUsers < ActiveRecord::Migration record.comment = ep.comment record.save! end - end end diff --git a/db/migrate/20140701123203_add_events_per_week_to_conference.rb b/db/migrate/20140701123203_add_events_per_week_to_conference.rb index 70110d24..04163176 100644 --- a/db/migrate/20140701123203_add_events_per_week_to_conference.rb +++ b/db/migrate/20140701123203_add_events_per_week_to_conference.rb @@ -65,10 +65,9 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration conference.save end - # Cumulate the previous weeks to get a snapshot TempConference.all.each do |conference| - hash = conference.events_per_week.sort.to_h + hash = conference.events_per_week.sort.to_hash previous = nil hash.each do |week, values| diff --git a/db/seeds.rb b/db/seeds.rb index 5d04058d..8c47da2c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -18,7 +18,7 @@ answer_no = Answer.create(:title => "No") questions_yes_no = ["Do you need handicapped access to the venue?", "Are you attending with partner?", "Will you attend the social event(s)?", "Will you stay at suggested hotel?"] -for i in questions_yes_no do +questions_yes_no.each do |i| q = Question.create(:title => i, :question_type_id => qtype_yesno.id, :global => true) Qanswer.create(:question_id => q.id, :answer_id => answer_no.id) diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index af30caa0..9c63e291 100644 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -406,7 +406,7 @@ describe Conference do end describe '#difficulty_levels' do - before (:each) do + before do subject.email_settings = create(:email_settings) @easy = create(:difficulty_level, title: 'Easy', color: '#000000') @hard = create(:difficulty_level, title: 'Hard', color: '#ffffff') @@ -503,7 +503,7 @@ describe Conference do end describe 'event type distribution' do - before (:each) do + before do subject.email_settings = create(:email_settings) @workshop = create(:event_type, title: 'Workshop', color: '#000000') @lecture = create(:event_type, title: 'Lecture', color: '#ffffff') @@ -599,7 +599,7 @@ describe Conference do end describe 'tracks_distribution' do - before (:each) do + before do subject.email_settings = create(:email_settings) @track_one = create(:track, name: 'Track One', color: '#000000') @track_two = create(:track, name: 'Track Two', color: '#ffffff') diff --git a/spec/support/login_macros.rb b/spec/support/login_macros.rb index e8f22147..716cbbbe 100644 --- a/spec/support/login_macros.rb +++ b/spec/support/login_macros.rb @@ -1,5 +1,4 @@ module LoginMacros - include Warden::Test::Helpers Warden.test_mode! @@ -10,5 +9,4 @@ module LoginMacros def sign_out logout(:user) end - end diff --git a/spec/views/home/index.html.haml_spec.rb b/spec/views/home/index.html.haml_spec.rb index 32599a2a..6affa8d8 100644 --- a/spec/views/home/index.html.haml_spec.rb +++ b/spec/views/home/index.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'home/index' do - it "renders _conference partial for each conference" do + it "renders _conference partial for each conference" do allow(view).to receive(:date_string).and_return("January 17 - 21 2014") assign(:current, [create(:conference), create(:conference)]) render From 056fe5ec3f0ad62fa6edf2ac7b382e29bcdbdf95 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 14:37:26 +0200 Subject: [PATCH 03/12] Fix others additional lints --- .rubocop.yml | 21 ++++++++----------- .../admin/dietchoices_controller.rb | 2 +- .../admin/eventtypes_controller.rb | 2 +- .../admin/registrations_controller.rb | 4 ++-- .../admin/supporter_levels_controller.rb | 2 +- .../admin/volunteers_controller.rb | 2 +- .../conference_registration_controller.rb | 2 +- .../event_attachments_controller.rb | 2 +- app/controllers/proposal_controller.rb | 6 +++--- .../users/omniauth_callbacks_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/models/ability.rb | 2 +- app/models/conference.rb | 2 +- app/models/datatable.rb | 6 +++--- config/environment.rb | 2 +- ...23203_add_events_per_week_to_conference.rb | 2 +- spec/features/user_spec.rb | 4 +++- spec/features/volunteers_spec.rb | 2 +- 18 files changed, 33 insertions(+), 34 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9c4550a3..5aa96d75 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -55,28 +55,25 @@ Lint/Loop: Lint/ParenthesesAsGroupedExpression: Enabled: true -# Offense count: 13 -# Cop supports --auto-correct. +# Do not rescue Exceptions class itself Lint/RescueException: Enabled: true -# Offense count: 1 +# do not shadow local variables in blocks, choose other name Lint/ShadowingOuterLocalVariable: - Enabled: false + Enabled: true -# Offense count: 5 -# Cop supports --auto-correct. +# use _ or variable_name to explicitly mark variable as unused Lint/UnusedBlockArgument: - Enabled: false + Enabled: true -# Offense count: 2 -# Cop supports --auto-correct. +# use _ or _argument_name to explicitly mark argument as unused Lint/UnusedMethodArgument: - Enabled: false + Enabled: true -# Offense count: 6 +# avoid useless assignment Lint/UselessAssignment: - Enabled: false + Enabled: true # Offense count: 1 Lint/Void: diff --git a/app/controllers/admin/dietchoices_controller.rb b/app/controllers/admin/dietchoices_controller.rb index 688cd632..f1258dce 100644 --- a/app/controllers/admin/dietchoices_controller.rb +++ b/app/controllers/admin/dietchoices_controller.rb @@ -9,7 +9,7 @@ class Admin::DietchoicesController < ApplicationController begin @conference.update_attributes!(params[:conference]) redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :notice => 'Dietary choices were successfully updated.') - rescue Exception => e + rescue => e redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :alert => "Dietary choices update failed: #{e.message}") end end diff --git a/app/controllers/admin/eventtypes_controller.rb b/app/controllers/admin/eventtypes_controller.rb index d29f78cd..286e8f75 100644 --- a/app/controllers/admin/eventtypes_controller.rb +++ b/app/controllers/admin/eventtypes_controller.rb @@ -10,7 +10,7 @@ class Admin::EventtypesController < ApplicationController redirect_to(admin_conference_eventtypes_path( conference_id: @conference.short_title), notice: 'Event types were successfully updated.') - rescue Exception => e + rescue => e redirect_to(admin_conference_eventtypes_path( conference_id: @conference.short_title), alert: "Event types update failed: #{e.message}") diff --git a/app/controllers/admin/registrations_controller.rb b/app/controllers/admin/registrations_controller.rb index e00fa7ba..6ebe3db0 100644 --- a/app/controllers/admin/registrations_controller.rb +++ b/app/controllers/admin/registrations_controller.rb @@ -44,7 +44,7 @@ module Admin @registration.update_attributes!(params[:registration]) flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}" redirect_to(admin_conference_registrations_path(@conference.short_title)) - rescue Exception => e + rescue => e Rails.logger.debug e.backtrace.join("\n") redirect_to(admin_conference_registrations_path(@conference.short_title), alert: 'Failed to update registration:' + e.message) @@ -104,7 +104,7 @@ module Admin begin registration.destroy redirect_to admin_conference_registrations_path flash[:notice] = "Deleted registration for #{user.name} #{user.email}" - rescue Exception => e + rescue => e Rails.logger.debug e.backtrace.join("\n") redirect_to(admin_conference_registrations_path(@conference.short_title), alert: 'Failed to delete registration:' + e.message) diff --git a/app/controllers/admin/supporter_levels_controller.rb b/app/controllers/admin/supporter_levels_controller.rb index e835dcf5..3e11db97 100644 --- a/app/controllers/admin/supporter_levels_controller.rb +++ b/app/controllers/admin/supporter_levels_controller.rb @@ -9,7 +9,7 @@ class Admin::SupporterLevelsController < ApplicationController begin @conference.update_attributes!(params[:conference]) redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :notice => 'Supporter levels were successfully updated.') - rescue Exception => e + rescue => e redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :alert => "Supporter levels update failed: #{e.message}") end end diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index 0da1f31f..31593893 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -18,7 +18,7 @@ class Admin::VolunteersController < ApplicationController begin @conference.update_attributes!(params[:conference]) redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.") - rescue Exception => e + rescue => e redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}") end end diff --git a/app/controllers/conference_registration_controller.rb b/app/controllers/conference_registration_controller.rb index 4fbf2a0a..3d9f0513 100644 --- a/app/controllers/conference_registration_controller.rb +++ b/app/controllers/conference_registration_controller.rb @@ -68,7 +68,7 @@ class ConferenceRegistrationController < ApplicationController else registration.update_attributes!(registration_params) end - rescue Exception => e + rescue => e Rails.logger.debug e.backtrace.join('\n') redirect_to(register_conference_path(id: conference.short_title), alert: 'Registration failed:' + e.message) diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index 7a7c1514..61a76b0b 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -53,7 +53,7 @@ class EventAttachmentsController < ApplicationController if !organizer_or_admin? begin event = current_user.events.find(params[:proposal_id]) - rescue Exception => e + rescue => e # They certainly aren't allowed to attach a file to someone else's proposal raise ActionController::RoutingError.new('Invalid proposal') end diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 1016bad7..9334c4df 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -23,7 +23,7 @@ class ProposalController < ApplicationController else @event = Event.find(params[:id]) end - rescue Exception => e + rescue => e Rails.logger.debug("Proposal failure in verify_access: #{e.message}") redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), alert: 'Invalid or uneditable proposal.') @@ -91,7 +91,7 @@ class ProposalController < ApplicationController event.update_attributes!(params[:event]) redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), notice: "'#{event.title}' was successfully updated.") - rescue Exception => e + rescue => e redirect_to edit_conference_proposal_path(@conference.short_title, @event), alert: e.message end end @@ -131,7 +131,7 @@ class ProposalController < ApplicationController begin @event.save! - rescue Exception => e + rescue => e @url = conference_proposal_index_path(@conference.short_title) @event_types = @conference.event_types @user = current_user diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 4fa0341c..2833137a 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -26,7 +26,7 @@ module Users sign_in user redirect_to root_path, notice: user.email + " signed in successfully with #{provider}" - rescue Exception => e + rescue => e redirect_back_or_to new_user_registration_path, alert: 'Failed' + e.message end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 62a97153..620bf62a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -75,7 +75,7 @@ module ApplicationHelper end def normalize_array_length(hashmap, length) - hashmap.each do |key, value| + hashmap.each do |_, value| if value.length < length value.fill(value[-1], value.length...length) end diff --git a/app/models/ability.rb b/app/models/ability.rb index 58929d7a..1ca0df1d 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -1,7 +1,7 @@ class Ability include CanCan::Ability - def initialize(user) + def initialize(user) # rubocop:disable Lint/UnusedMethodArgument # Define abilities for the passed in user here. For example: # # user ||= User.new # guest user (not logged in) diff --git a/app/models/conference.rb b/app/models/conference.rb index fae89ad8..f269a1bb 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -639,7 +639,7 @@ class Conference < ActiveRecord::Base # ====Returns # * +Fixnum+ -> Progress in Percent def calculate_setup_progress(result) - (result.select { |k, v| v }.length / result.length.to_f * 100).round(0).to_s + (result.select { |_k, v| v }.length / result.length.to_f * 100).round(0).to_s end ## diff --git a/app/models/datatable.rb b/app/models/datatable.rb index 339d4897..4ba59673 100644 --- a/app/models/datatable.rb +++ b/app/models/datatable.rb @@ -9,7 +9,7 @@ class Datatable @view = view end - def as_json(options = {}) + def as_json { sEcho: params[:sEcho].to_i, iTotalRecords: @klass.count, @@ -55,10 +55,10 @@ class Datatable search_for = params[:sSearch].split(' ') terms = {} which_one = -1 - criteria = search_for.inject([]) do |criteria,atom| + criteria = search_for.inject([]) do |mem, atom| which_one += 1 terms["search#{which_one}".to_sym] = "%#{atom}%" - criteria << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})" + mem << "(#{search_cols.map{|col| "#{col} like :search#{which_one}"}.join(' or ')})" end.join(' and ') [criteria, terms] end diff --git a/config/environment.rb b/config/environment.rb index 760642c1..bcd18b20 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -5,7 +5,7 @@ require File.expand_path('../application', __FILE__) path = Rails.root.join("config", "config.yml") begin CONFIG = YAML.load_file(path)[Rails.env] -rescue Exception +rescue puts "Error while parsing config file #{path}" CONFIG = {} end diff --git a/db/migrate/20140701123203_add_events_per_week_to_conference.rb b/db/migrate/20140701123203_add_events_per_week_to_conference.rb index 04163176..bedf4f58 100644 --- a/db/migrate/20140701123203_add_events_per_week_to_conference.rb +++ b/db/migrate/20140701123203_add_events_per_week_to_conference.rb @@ -72,7 +72,7 @@ class AddEventsPerWeekToConference < ActiveRecord::Migration hash.each do |week, values| if previous - values.each do |state, value| + values.each do |state, _value| hash[week][state] += previous[state] end end diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index ddec87b8..5e5a57df 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -5,7 +5,8 @@ feature User do let!(:participant_role) { create(:participant_role) } let!(:admin_role) { create(:admin_role) } let(:admin) { create(:admin) } - shared_examples 'admin ability' do |user| + + shared_examples 'admin ability' do scenario 'deletes a user', feature: true, js: true do sign_in(admin) visit admin_users_path @@ -34,6 +35,7 @@ feature User do sign_out end end + describe 'admin' do it_behaves_like 'admin ability', :admin end diff --git a/spec/features/volunteers_spec.rb b/spec/features/volunteers_spec.rb index bc1e6d76..70f4e16b 100644 --- a/spec/features/volunteers_spec.rb +++ b/spec/features/volunteers_spec.rb @@ -8,7 +8,7 @@ feature Conference do let(:admin) { create(:admin) } let(:conference) { create(:conference) } - shared_examples 'volunteer' do |user| + shared_examples 'volunteer' do scenario 'adds and updates vdays', feature: true, js: true do sign_in(admin) visit admin_conference_volunteers_info_path( From 31212b4f1c2f0fb50d2c3d895722d83e8457312d Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 14:42:58 +0200 Subject: [PATCH 04/12] Fix linting cops --- app/controllers/admin/stats_controller.rb | 2 +- app/controllers/admin/supporters_controller.rb | 2 +- app/controllers/event_attachments_controller.rb | 4 ++-- db/seeds.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb index 758c46f9..b5685bff 100644 --- a/app/controllers/admin/stats_controller.rb +++ b/app/controllers/admin/stats_controller.rb @@ -187,7 +187,7 @@ module Admin total = @conference.events.where(state: mystate).count status = "#{myvar.name}" - percent = 0 + percent = 0 # rubocop:disable Lint/UselessAssignment if value != 0 percent = (value.to_f / total * 100).round(2) result << { 'status' => status, 'value' => value, 'percent' => percent } diff --git a/app/controllers/admin/supporters_controller.rb b/app/controllers/admin/supporters_controller.rb index 6975d5f5..216c2bda 100644 --- a/app/controllers/admin/supporters_controller.rb +++ b/app/controllers/admin/supporters_controller.rb @@ -10,7 +10,7 @@ class Admin::SupportersController < ApplicationController def create params[:supporter_registration][:conference_id] = @conference.id - supporter = SupporterRegistration.create!(params[:supporter_registration]) + SupporterRegistration.create!(params[:supporter_registration]) redirect_to(admin_conference_supporters_path(:conference_id => @conference.short_title), :notice => "Supporter added") end end diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index 61a76b0b..af6ce3fc 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -52,8 +52,8 @@ class EventAttachmentsController < ApplicationController if !organizer_or_admin? begin - event = current_user.events.find(params[:proposal_id]) - rescue => e + current_user.events.find(params[:proposal_id]) + rescue # They certainly aren't allowed to attach a file to someone else's proposal raise ActionController::RoutingError.new('Invalid proposal') end diff --git a/db/seeds.rb b/db/seeds.rb index 8c47da2c..c01e0fcc 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,8 +10,8 @@ Role.create(:name => "Organizer") Role.create(:name => "Admin") qtype_yesno = QuestionType.create(:title => "Yes/No") -qtype_single = QuestionType.create(:title => "Single Choice") -qtype_multiple = QuestionType.create(:title => "Multiple Choice") +QuestionType.create(:title => "Single Choice") +QuestionType.create(:title => "Multiple Choice") answer_yes = Answer.create(:title => "Yes") answer_no = Answer.create(:title => "No") From 3901973fd67ce8136adeab72d9ac1c9cfe181832 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 14:45:17 +0200 Subject: [PATCH 05/12] Do not use variables in void context --- .rubocop.yml | 3 +-- app/controllers/proposal_controller.rb | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 5aa96d75..0132798b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -75,9 +75,8 @@ Lint/UnusedMethodArgument: Lint/UselessAssignment: Enabled: true -# Offense count: 1 Lint/Void: - Enabled: false + Enabled: true # Offense count: 17 Style/AccessorMethodName: diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 9334c4df..b485d6cf 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -182,7 +182,6 @@ class ProposalController < ApplicationController end def restart - @event if @event.transition_possible? :restart begin @event.restart From 5289f41eb514c9684669b59cf8f457a52c4854d9 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 14:49:05 +0200 Subject: [PATCH 06/12] Use only new hash syntax --- .rubocop.yml | 6 ++--- .../admin/dietchoices_controller.rb | 4 +-- .../admin/difficulty_levels_controller.rb | 8 +++--- app/controllers/admin/questions_controller.rb | 14 +++++----- .../admin/social_events_controller.rb | 4 +-- .../admin/supporter_levels_controller.rb | 4 +-- .../admin/supporters_controller.rb | 2 +- .../admin/volunteers_controller.rb | 6 ++--- .../api/v1/conferences_controller.rb | 2 +- app/controllers/application_controller.rb | 2 +- .../event_attachments_controller.rb | 10 +++---- app/controllers/schedule_controller.rb | 2 +- app/helpers/application_helper.rb | 6 ++--- app/mailers/mailbot.rb | 10 +++---- app/models/answer.rb | 4 +-- app/models/call_for_papers.rb | 2 +- app/models/comment.rb | 14 +++++----- app/models/conference.rb | 2 +- app/models/difficulty_level.rb | 2 +- app/models/event_attachment.rb | 2 +- app/models/event_type.rb | 2 +- app/models/qanswer.rb | 2 +- app/models/question.rb | 10 +++---- app/models/vday.rb | 2 +- app/models/venue.rb | 2 +- app/models/vposition.rb | 2 +- config/application.rb | 2 +- config/deploy.rb | 6 ++--- config/environments/development.rb | 2 +- config/environments/production.rb | 2 +- config/routes.rb | 26 +++++++++---------- .../20121223110942_devise_create_users.rb | 12 ++++----- ...20121223115038_create_conferences_table.rb | 18 ++++++------- .../20121223115106_create_people_table.rb | 12 ++++----- .../20121223115117_create_rooms_table.rb | 6 ++--- .../20121223115125_create_tracks_table.rb | 6 ++--- .../20121223115135_create_events_table.rb | 10 +++---- .../20121223120413_create_event_types.rb | 4 +-- ...0121223122307_create_event_people_table.rb | 2 +- db/migrate/20121223135447_user_roles_table.rb | 2 +- db/migrate/20121224144728_create_cfp_table.rb | 8 +++--- ...130103134212_create_registrations_table.rb | 6 ++--- db/migrate/20130104142209_create_comments.rb | 4 +-- ...05115603_create_event_attachments_table.rb | 4 +-- ...e_cfp_and_reg_booleans_from_conferences.rb | 4 +-- db/migrate/20130107114930_create_versions.rb | 6 ++--- .../20130113105652_create_email_table.rb | 8 +++--- ...maximum_abstract_lengths_to_event_types.rb | 4 +-- ...91022_add_dietary_choice_to_conferences.rb | 2 +- ...0202091051_create_dietary_choices_table.rb | 2 +- ...add_handicapped_access_to_registrations.rb | 2 +- ...0202130737_create_supporter_level_table.rb | 2 +- ...23_create_table_supporter_registrations.rb | 2 +- ...add_use_supporter_levels_to_conferences.rb | 2 +- ...reate_registrations_social_events_table.rb | 2 +- ...2155_set_registration_defaults_to_false.rb | 2 +- ...43459_create_events_registrations_table.rb | 2 +- ...712072609_add_attended_to_registrations.rb | 2 +- ...add_schedule_changes_to_call_for_papers.rb | 2 +- ...815201317_add_rating_to_call_for_papers.rb | 2 +- .../20130821133651_create_vpositions.rb | 2 +- ...hange_default_rating_in_call_for_papers.rb | 4 +-- .../20131229072532_registrations_vchoices.rb | 2 +- ...0109191321_create_conferences_questions.rb | 2 +- ...112192801_create_qanswers_registrations.rb | 6 ++--- ...20140212172244_create_difficulty_levels.rb | 2 +- ...add_use_difficulty_levels_to_conference.rb | 2 +- ...305102505_use_vdays_vpositions_defaults.rb | 8 +++--- db/seeds.rb | 22 ++++++++-------- spec/support/database_cleaner.rb | 2 +- spec/support/login_macros.rb | 2 +- spec/views/home/index.html.haml_spec.rb | 2 +- 72 files changed, 179 insertions(+), 181 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0132798b..538267b0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,7 @@ inherit_from: .rubocop_todo.yml Style/HashSyntax: + Enabled: true EnforcedStyle: ruby19 # Things deprecated in current ruby API @@ -75,13 +76,10 @@ Lint/UnusedMethodArgument: Lint/UselessAssignment: Enabled: true +# Do not use variables in void context Lint/Void: Enabled: true -# Offense count: 17 -Style/AccessorMethodName: - Enabled: false - AllCops: Include: - Rakefile diff --git a/app/controllers/admin/dietchoices_controller.rb b/app/controllers/admin/dietchoices_controller.rb index f1258dce..cf315a40 100644 --- a/app/controllers/admin/dietchoices_controller.rb +++ b/app/controllers/admin/dietchoices_controller.rb @@ -8,9 +8,9 @@ class Admin::DietchoicesController < ApplicationController def update begin @conference.update_attributes!(params[:conference]) - redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :notice => 'Dietary choices were successfully updated.') + redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), notice: 'Dietary choices were successfully updated.') rescue => e - redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :alert => "Dietary choices update failed: #{e.message}") + redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), alert: "Dietary choices update failed: #{e.message}") end end end diff --git a/app/controllers/admin/difficulty_levels_controller.rb b/app/controllers/admin/difficulty_levels_controller.rb index a52cefcf..51aacd7f 100644 --- a/app/controllers/admin/difficulty_levels_controller.rb +++ b/app/controllers/admin/difficulty_levels_controller.rb @@ -12,18 +12,18 @@ class Admin::DifficultyLevelsController < ApplicationController @conference.use_difficulty_levels = false @conference.save! flash[:error] = "You cannot enable the usage of difficulty levels without having set any levels." - redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) + redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) rescue ActiveRecord::RecordInvalid flash[:error] = "Something went wrong. Difficulty Levels update failed." - redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) + redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) end else flash[:notice] = "Difficulty Levels were successfully updated." - redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) + redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) end else flash[:error] = "Difficulty Levels update failed." - redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title)) + redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) end end end diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index 838f587e..1e9e4551 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -3,7 +3,7 @@ class Admin::QuestionsController < ApplicationController def index @conference = Conference.find_by(short_title: params[:conference_id]) - @questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id) + @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id) @questions_conference = @conference.questions @new_question = @conference.questions.new end @@ -34,7 +34,7 @@ class Admin::QuestionsController < ApplicationController @question = Question.find(params[:id]) if @question.global == true && !has_role?(current_user, "Admin") - redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :alert => "Sorry, you cannot edit global questions. Create a new one.") + redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.") end end @@ -45,9 +45,9 @@ class Admin::QuestionsController < ApplicationController @question = Question.find(params[:id]) if @question.update_attributes(params[:question]) - redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Question '#{@question.title}' for #{@conference.short_title} successfully updated.") + redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.") else - redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.") + redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.") end end @@ -56,9 +56,9 @@ class Admin::QuestionsController < ApplicationController @conference = Conference.find_by(short_title: params[:conference_id]) if @conference.update_attributes(params[:conference]) - redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Questions for #{@conference.short_title} successfully updated.") + redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.") else - redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.") + redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.") end end @@ -90,7 +90,7 @@ class Admin::QuestionsController < ApplicationController flash[:error] = "You must be an admin to delete a question." end - @questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id) + @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id) @questions_conference = @conference.questions end end diff --git a/app/controllers/admin/social_events_controller.rb b/app/controllers/admin/social_events_controller.rb index 336e7cef..b11b38f4 100644 --- a/app/controllers/admin/social_events_controller.rb +++ b/app/controllers/admin/social_events_controller.rb @@ -7,9 +7,9 @@ class Admin::SocialEventsController < ApplicationController def update if @conference.update_attributes(params[:conference]) - redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events were successfully updated.') + redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events were successfully updated.') else - redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.') + redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events update failed.') end end end diff --git a/app/controllers/admin/supporter_levels_controller.rb b/app/controllers/admin/supporter_levels_controller.rb index 3e11db97..33218920 100644 --- a/app/controllers/admin/supporter_levels_controller.rb +++ b/app/controllers/admin/supporter_levels_controller.rb @@ -8,9 +8,9 @@ class Admin::SupporterLevelsController < ApplicationController def update begin @conference.update_attributes!(params[:conference]) - redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :notice => 'Supporter levels were successfully updated.') + redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), notice: 'Supporter levels were successfully updated.') rescue => e - redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :alert => "Supporter levels update failed: #{e.message}") + redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), alert: "Supporter levels update failed: #{e.message}") end end end diff --git a/app/controllers/admin/supporters_controller.rb b/app/controllers/admin/supporters_controller.rb index 216c2bda..a114daca 100644 --- a/app/controllers/admin/supporters_controller.rb +++ b/app/controllers/admin/supporters_controller.rb @@ -11,6 +11,6 @@ class Admin::SupportersController < ApplicationController def create params[:supporter_registration][:conference_id] = @conference.id SupporterRegistration.create!(params[:supporter_registration]) - redirect_to(admin_conference_supporters_path(:conference_id => @conference.short_title), :notice => "Supporter added") + redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title), notice: "Supporter added") end end diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index 31593893..afc688c9 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -9,7 +9,7 @@ class Admin::VolunteersController < ApplicationController if @conference.use_vpositions @volunteers = @conference.registrations.joins(:vchoices).uniq else - @volunteers = @conference.registrations.where(:volunteer => true) + @volunteers = @conference.registrations.where(volunteer: true) end end @@ -17,9 +17,9 @@ class Admin::VolunteersController < ApplicationController @conference = Conference.find_by(short_title: params[:conference_id]) begin @conference.update_attributes!(params[:conference]) - redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.") + redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.") rescue => e - redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}") + redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}") end end end diff --git a/app/controllers/api/v1/conferences_controller.rb b/app/controllers/api/v1/conferences_controller.rb index 4a851b94..9e0338b1 100644 --- a/app/controllers/api/v1/conferences_controller.rb +++ b/app/controllers/api/v1/conferences_controller.rb @@ -7,6 +7,6 @@ class Api::V1::ConferencesController < Api::BaseController else conferences = Conference.find_all_by_guid(params[:conference_id]) end - render :json => conferences, :serializer => ConferencesArraySerializer + render json: conferences, serializer: ConferencesArraySerializer end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 21416ebf..fade3e37 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -70,7 +70,7 @@ class ApplicationController < ActionController::Base rescue_from CanCan::AccessDenied do |exception| Rails.logger.debug("Access denied!") - redirect_to root_path, :alert => exception.message + redirect_to root_path, alert: exception.message end helper_method :organizer_or_admin? diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index af6ce3fc..a54fc2a4 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -1,6 +1,6 @@ class EventAttachmentsController < ApplicationController before_filter :verify_user - skip_before_filter :verify_user, :only => [:show] + skip_before_filter :verify_user, only: [:show] def index @proposal = Event.find(params[:proposal_id]) @@ -67,9 +67,9 @@ class EventAttachmentsController < ApplicationController respond_to do |format| if @upload.save format.html { - render :json => [@upload.to_jq_upload].to_json, - :content_type => 'text/html', - :layout => false + render json: [@upload.to_jq_upload].to_json, + content_type: 'text/html', + layout: false } format.json do render json: [@upload.to_jq_upload].to_json, status: :created, @@ -108,7 +108,7 @@ class EventAttachmentsController < ApplicationController respond_to do |format| - format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), :notice => "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" } + format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), notice: "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" } format.json { head :no_content } end diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index de984489..365d8bf2 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -2,7 +2,7 @@ class ScheduleController < ApplicationController layout "application" def index - @conference = Conference.includes(:rooms, {:events => [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first + @conference = Conference.includes(:rooms, {events: [:speakers, :track, :event_type]}).where("conferences.short_title" => params[:conference_id]).first @rooms = @conference.rooms @events = @conference.events @dates = @conference.start_date..@conference.end_date diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 620bf62a..43d72465 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -126,15 +126,15 @@ module ApplicationHelper end def add_association_link(association_name, form_builder, div_class, html_options = {}) - link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(:class => "assoc btn btn-success") + link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(class: "assoc btn btn-success") end def remove_association_link(association_name, form_builder) - link_to_remove_association("Remove " + association_name.to_s.singularize, form_builder, :class => "assoc btn btn-danger") + tag(:hr) + link_to_remove_association("Remove " + association_name.to_s.singularize, form_builder, class: "assoc btn btn-danger") + tag(:hr) end def dynamic_association(association_name, title, form_builder, options = {}) - render "shared/dynamic_association", :association_name => association_name, :title => title, :f => form_builder, :hint => options[:hint] + render "shared/dynamic_association", association_name: association_name, title: title, f: form_builder, hint: options[:hint] end def has_role?(current_user, role) diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index ea40fa12..f73ba4fb 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -55,10 +55,10 @@ class Mailbot < ActionMailer::Base end def build_email(conference, to, subject, body) - mail(:to => to, - :from => conference.contact_email, - :reply_to => conference.contact_email, - :subject => subject, - :body => body) + mail(to: to, + from: conference.contact_email, + reply_to: conference.contact_email, + subject: subject, + body: body) end end diff --git a/app/models/answer.rb b/app/models/answer.rb index da91c47a..fa0894fd 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -2,7 +2,7 @@ class Answer < ActiveRecord::Base attr_accessible :title has_many :qanswers - has_many :questions, :through => :qanswers + has_many :questions, through: :qanswers - validates :title, :presence => true + validates :title, presence: true end diff --git a/app/models/call_for_papers.rb b/app/models/call_for_papers.rb index 7581fed2..d14ba923 100644 --- a/app/models/call_for_papers.rb +++ b/app/models/call_for_papers.rb @@ -5,7 +5,7 @@ class CallForPapers < ActiveRecord::Base belongs_to :conference validates_presence_of :start_date, :end_date - validates :rating, :numericality => { :greater_than_or_equal_to => 0, :less_than_or_equal_to => 10 } + validates :rating, numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 10 } ## # Calculates how many weeks the call for paper is. diff --git a/app/models/comment.rb b/app/models/comment.rb index 350a5b25..6196856e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -1,5 +1,5 @@ class Comment < ActiveRecord::Base - acts_as_nested_set :scope => [:commentable_id, :commentable_type] + acts_as_nested_set scope: [:commentable_id, :commentable_type] attr_accessible :commentable, :body, :user_id validates_presence_of :body validates_presence_of :user @@ -8,7 +8,7 @@ class Comment < ActiveRecord::Base # want user to vote on the quality of comments. #acts_as_votable - belongs_to :commentable, :polymorphic => true + belongs_to :commentable, polymorphic: true # NOTE: Comments belong to a user belongs_to :user @@ -18,9 +18,9 @@ class Comment < ActiveRecord::Base # example in readme def self.build_from(obj, user_id, comment) new \ - :commentable => obj, - :body => comment, - :user_id => user_id + commentable: obj, + body: comment, + user_id: user_id end #helper method to check if a comment has children @@ -31,13 +31,13 @@ class Comment < ActiveRecord::Base # Helper class method to lookup all comments assigned # to all commentable types for a given user. scope :find_comments_by_user, lambda { |user| - where(:user_id => user.id).order('created_at DESC') + where(user_id: user.id).order('created_at DESC') } # Helper class method to look up all comments for # commentable class name and commentable id. scope :find_comments_for_commentable, lambda { |commentable_str, commentable_id| - where(:commentable_type => commentable_str.to_s, :commentable_id => commentable_id).order('created_at DESC') + where(commentable_type: commentable_str.to_s, commentable_id: commentable_id).order('created_at DESC') } # Helper class method to look up a commentable object diff --git a/app/models/conference.rb b/app/models/conference.rb index f269a1bb..d2a3a907 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -89,7 +89,7 @@ class Conference < ActiveRecord::Base format: URI::regexp(%w(http https)), allow_blank: true validates_uniqueness_of :short_title - validates_format_of :short_title, :with => /\A[a-zA-Z0-9_-]*\z/ + validates_format_of :short_title, with: /\A[a-zA-Z0-9_-]*\z/ before_create :generate_guid before_create :create_venue before_create :create_event_types diff --git a/app/models/difficulty_level.rb b/app/models/difficulty_level.rb index 8334ce69..ac8306ae 100644 --- a/app/models/difficulty_level.rb +++ b/app/models/difficulty_level.rb @@ -4,5 +4,5 @@ class DifficultyLevel < ActiveRecord::Base belongs_to :conference has_many :events - validates :title, :presence => true + validates :title, presence: true end diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index 98d3c547..41915248 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -4,7 +4,7 @@ class EventAttachment < ActiveRecord::Base belongs_to :event attr_accessible :public, :attachment, :event_id, :title - has_attached_file :attachment, :path => ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" + has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" include Rails.application.routes.url_helpers def to_jq_upload diff --git a/app/models/event_type.rb b/app/models/event_type.rb index dfa81a71..81db86da 100644 --- a/app/models/event_type.rb +++ b/app/models/event_type.rb @@ -4,7 +4,7 @@ class EventType < ActiveRecord::Base belongs_to :conference validates :title, presence: true - validates :length, :numericality => {:greater_than => 0} + validates :length, numericality: {greater_than: 0} validates :minimum_abstract_length, presence: true validates :maximum_abstract_length, presence: true diff --git a/app/models/qanswer.rb b/app/models/qanswer.rb index f2628c8a..3376814d 100644 --- a/app/models/qanswer.rb +++ b/app/models/qanswer.rb @@ -2,7 +2,7 @@ class Qanswer < ActiveRecord::Base attr_accessible :question_id, :answer_id belongs_to :question - belongs_to :answer, :dependent => :delete + belongs_to :answer, dependent: :delete has_and_belongs_to_many :registrations end diff --git a/app/models/question.rb b/app/models/question.rb index 35d693aa..1a6302c1 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -4,11 +4,11 @@ class Question < ActiveRecord::Base belongs_to :question_type has_and_belongs_to_many :conferences - has_many :qanswers, :dependent => :delete_all - has_many :answers, :through => :qanswers, :dependent => :delete_all + has_many :qanswers, dependent: :delete_all + has_many :answers, through: :qanswers, dependent: :delete_all - validates :title, :presence => true - validates :answers, :presence => true + validates :title, presence: true + validates :answers, presence: true - accepts_nested_attributes_for :answers, :allow_destroy => true + accepts_nested_attributes_for :answers, allow_destroy: true end diff --git a/app/models/vday.rb b/app/models/vday.rb index 118bf5e2..a752c12f 100644 --- a/app/models/vday.rb +++ b/app/models/vday.rb @@ -4,5 +4,5 @@ class Vday < ActiveRecord::Base belongs_to :conference has_many :vchoices - has_many :vpositions, :through => :vchoices, :dependent => :destroy + has_many :vpositions, through: :vchoices, dependent: :destroy end diff --git a/app/models/venue.rb b/app/models/venue.rb index 21934332..0963c0d7 100644 --- a/app/models/venue.rb +++ b/app/models/venue.rb @@ -20,7 +20,7 @@ class Venue < ActiveRecord::Base def generate_guid loop do @guid = SecureRandom.urlsafe_base64 - break if !Venue.where(:guid => guid).any? + break if !Venue.where(guid: guid).any? end self.guid = @guid end diff --git a/app/models/vposition.rb b/app/models/vposition.rb index 308f94ff..4f6e0966 100644 --- a/app/models/vposition.rb +++ b/app/models/vposition.rb @@ -4,7 +4,7 @@ class Vposition < ActiveRecord::Base belongs_to :conference has_many :vchoices - has_many :vdays, :through => :vchoices + has_many :vdays, through: :vchoices validates_presence_of :title, :vdays end diff --git a/config/application.rb b/config/application.rb index 4c76b590..a9790016 100644 --- a/config/application.rb +++ b/config/application.rb @@ -5,7 +5,7 @@ include ActionView::Helpers::NumberHelper if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) + Bundler.require(*Rails.groups(assets: %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end diff --git a/config/deploy.rb b/config/deploy.rb index 2ffab60a..80509ff9 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -12,7 +12,7 @@ set :repository, 'https://github.com/openSUSE/osem.git' # They will be linked in the 'deploy:link_shared_paths' step. set :shared_paths, %w{ config/database.yml log public/system config/secrets.yml config/config.yml tmp} -task :setup => :environment do +task setup: :environment do queue! %[mkdir -p "#{deploy_to}/shared/log"] queue! %[chmod g+rx,u+rwx "#{deploy_to}/shared/log"] @@ -27,7 +27,7 @@ task :setup => :environment do end desc 'Deploys the current version to the server.' -task :deploy => :environment do +task deploy: :environment do deploy do invoke :'git:clone' invoke :'deploy:link_shared_paths' @@ -43,7 +43,7 @@ task :deploy => :environment do end desc 'Notifies the exception handler of the deploy.' -task :notify_errbit => :environment do +task notify_errbit: :environment do revision = `git rev-parse HEAD`.strip user = ENV['USER'] queue "bundle exec rake hoptoad:deploy TO=#{rails_env} REVISION=#{revision} REPO=#{repository} USER=#{user}" diff --git a/config/environments/development.rb b/config/environments/development.rb index 75fcca69..14a4bdc6 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -35,6 +35,6 @@ Osem::Application.configure do config.eager_load = false # Set the detault url for action mailer - config.action_mailer.default_url_options = { :host => CONFIG['url_for_emails'] } + config.action_mailer.default_url_options = { host: CONFIG['url_for_emails'] } end diff --git a/config/environments/production.rb b/config/environments/production.rb index f7cccb68..69c7f9de 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -67,5 +67,5 @@ Osem::Application.configure do config.active_support.deprecation = :notify # Set the detault url for action mailer - config.action_mailer.default_url_options = { :host => CONFIG['url_for_emails'] } + config.action_mailer.default_url_options = { host: CONFIG['url_for_emails'] } end diff --git a/config/routes.rb b/config/routes.rb index 57efb713..c62b3282 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,7 +70,7 @@ Osem::Application.routes.draw do patch :restart get :vote end - resource :speaker, :only => [:edit, :update] + resource :speaker, only: [:edit, :update] end resources :supporters @@ -79,11 +79,11 @@ Osem::Application.routes.draw do resources :conference, only: [:show] do resources :proposal do - resources :event_attachment, :controller => "event_attachments" + resources :event_attachment, controller: "event_attachments" patch '/confirm' => 'proposal#confirm' patch '/restart' => 'proposal#restart' end - resource :schedule, :only => [] do + resource :schedule, only: [] do get "/" => "schedule#index" end member do @@ -96,17 +96,17 @@ Osem::Application.routes.draw do namespace :api, defaults: {format: 'json'} do namespace :v1 do - resources :conferences, :only => :index do - resources :conferences, :only => :index - resources :rooms, :only => :index - resources :tracks, :only => :index - resources :speakers, :only => :index - resources :events, :only => :index + resources :conferences, only: :index do + resources :conferences, only: :index + resources :rooms, only: :index + resources :tracks, only: :index + resources :speakers, only: :index + resources :events, only: :index end - resources :rooms, :only => :index - resources :tracks, :only => :index - resources :speakers, :only => :index - resources :events, :only => :index + resources :rooms, only: :index + resources :tracks, only: :index + resources :speakers, only: :index + resources :events, only: :index end end diff --git a/db/migrate/20121223110942_devise_create_users.rb b/db/migrate/20121223110942_devise_create_users.rb index cd02db0e..aa694e16 100644 --- a/db/migrate/20121223110942_devise_create_users.rb +++ b/db/migrate/20121223110942_devise_create_users.rb @@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration def up create_table(:users) do |t| ## Database authenticatable - t.string :email, :null => false, :default => "" - t.string :encrypted_password, :null => false, :default => "" + t.string :email, null: false, default: "" + t.string :encrypted_password, null: false, default: "" ## Recoverable t.string :reset_password_token @@ -13,7 +13,7 @@ class DeviseCreateUsers < ActiveRecord::Migration t.datetime :remember_created_at ## Trackable - t.integer :sign_in_count, :default => 0 + t.integer :sign_in_count, default: 0 t.datetime :current_sign_in_at t.datetime :last_sign_in_at t.string :current_sign_in_ip @@ -36,9 +36,9 @@ class DeviseCreateUsers < ActiveRecord::Migration t.timestamps end - add_index :users, :email, :unique => true - add_index :users, :reset_password_token, :unique => true - add_index :users, :confirmation_token, :unique => true + add_index :users, :email, unique: true + add_index :users, :reset_password_token, unique: true + add_index :users, :confirmation_token, unique: true # add_index :users, :unlock_token, :unique => true # add_index :users, :authentication_token, :unique => true end diff --git a/db/migrate/20121223115038_create_conferences_table.rb b/db/migrate/20121223115038_create_conferences_table.rb index 7dd19349..932b66e7 100644 --- a/db/migrate/20121223115038_create_conferences_table.rb +++ b/db/migrate/20121223115038_create_conferences_table.rb @@ -1,17 +1,17 @@ class CreateConferencesTable < ActiveRecord::Migration def up create_table :conferences do |t| - t.string :guid, :null => false - t.string :title, :null => false - t.string :short_title, :null => false + t.string :guid, null: false + t.string :title, null: false + t.string :short_title, null: false t.string :social_tag - t.string :contact_email, :null => false - t.string :timezone, :null => false + t.string :contact_email, null: false + t.string :timezone, null: false t.string :html_export_path - t.date :start_date, :null => false - t.date :end_date, :null => false - t.boolean :cfp_open, :default => false - t.boolean :registration_open, :default => false + t.date :start_date, null: false + t.date :end_date, null: false + t.boolean :cfp_open, default: false + t.boolean :registration_open, default: false t.references :venue t.timestamps diff --git a/db/migrate/20121223115106_create_people_table.rb b/db/migrate/20121223115106_create_people_table.rb index 202f22fe..f378afaa 100644 --- a/db/migrate/20121223115106_create_people_table.rb +++ b/db/migrate/20121223115106_create_people_table.rb @@ -1,12 +1,12 @@ class CreatePeopleTable < ActiveRecord::Migration def up create_table :people do |t| - t.string :guid, :null => false - t.string :first_name, :default => "" - t.string :last_name, :default => "" - t.string :public_name, :default => "" - t.string :company, :default => "" - t.string :email, :null => false + t.string :guid, null: false + t.string :first_name, default: "" + t.string :last_name, default: "" + t.string :public_name, default: "" + t.string :company, default: "" + t.string :email, null: false t.boolean :email_public t.string :avatar_file_name t.string :avatar_content_type diff --git a/db/migrate/20121223115117_create_rooms_table.rb b/db/migrate/20121223115117_create_rooms_table.rb index dc11072e..0a45ac62 100644 --- a/db/migrate/20121223115117_create_rooms_table.rb +++ b/db/migrate/20121223115117_create_rooms_table.rb @@ -1,11 +1,11 @@ class CreateRoomsTable < ActiveRecord::Migration def up create_table :rooms do |t| - t.string :guid, :null => false + t.string :guid, null: false t.references :conference - t.string :name, :null => false + t.string :name, null: false t.integer :size - t.boolean :public, :default => true + t.boolean :public, default: true end end diff --git a/db/migrate/20121223115125_create_tracks_table.rb b/db/migrate/20121223115125_create_tracks_table.rb index 8e06f0a3..58d50fda 100644 --- a/db/migrate/20121223115125_create_tracks_table.rb +++ b/db/migrate/20121223115125_create_tracks_table.rb @@ -1,11 +1,11 @@ class CreateTracksTable < ActiveRecord::Migration def up create_table :tracks do |t| - t.string :guid, :null => false + t.string :guid, null: false t.references :conference - t.string :name, :null => false + t.string :name, null: false t.text :description - t.string :color, :default => "#ffffff" + t.string :color, default: "#ffffff" t.timestamps end diff --git a/db/migrate/20121223115135_create_events_table.rb b/db/migrate/20121223115135_create_events_table.rb index 7542d5ec..a0c9fac0 100644 --- a/db/migrate/20121223115135_create_events_table.rb +++ b/db/migrate/20121223115135_create_events_table.rb @@ -1,19 +1,19 @@ class CreateEventsTable < ActiveRecord::Migration def up create_table :events do |t| - t.string :guid, :null => false + t.string :guid, null: false t.references :conference t.references :event_type - t.string :title, :null => false + t.string :title, null: false t.string :subtitle t.integer :time_slots - t.string :state, :null => false, :default => "new" - t.string :progress, :null => false, :default => "new" + t.string :state, null: false, default: "new" + t.string :progress, null: false, default: "new" t.string :language t.datetime :start_time t.text :abstract t.text :description - t.boolean :public, :default => true + t.boolean :public, default: true t.string :logo_file_name t.string :logo_content_type t.integer :logo_file_size diff --git a/db/migrate/20121223120413_create_event_types.rb b/db/migrate/20121223120413_create_event_types.rb index d3e8743b..3257ade4 100644 --- a/db/migrate/20121223120413_create_event_types.rb +++ b/db/migrate/20121223120413_create_event_types.rb @@ -2,8 +2,8 @@ class CreateEventTypes < ActiveRecord::Migration def up create_table :event_types do |t| t.references :conference - t.string :title, :null => false - t.integer :length, :default => 30 + t.string :title, null: false + t.integer :length, default: 30 end end diff --git a/db/migrate/20121223122307_create_event_people_table.rb b/db/migrate/20121223122307_create_event_people_table.rb index 9ee30bc6..3459b433 100644 --- a/db/migrate/20121223122307_create_event_people_table.rb +++ b/db/migrate/20121223122307_create_event_people_table.rb @@ -4,7 +4,7 @@ class CreateEventPeopleTable < ActiveRecord::Migration t.references :proposal t.references :person t.references :event - t.string :event_role, :null => false, :default => "participant" + t.string :event_role, null: false, default: "participant" t.string :comment t.timestamps diff --git a/db/migrate/20121223135447_user_roles_table.rb b/db/migrate/20121223135447_user_roles_table.rb index 81f715dc..1f23cbb1 100644 --- a/db/migrate/20121223135447_user_roles_table.rb +++ b/db/migrate/20121223135447_user_roles_table.rb @@ -1,6 +1,6 @@ class UserRolesTable < ActiveRecord::Migration def self.up - create_table :roles_users, :id => false do |t| + create_table :roles_users, id: false do |t| t.references :role, :user end end diff --git a/db/migrate/20121224144728_create_cfp_table.rb b/db/migrate/20121224144728_create_cfp_table.rb index d8180398..eb730271 100644 --- a/db/migrate/20121224144728_create_cfp_table.rb +++ b/db/migrate/20121224144728_create_cfp_table.rb @@ -1,10 +1,10 @@ class CreateCfpTable < ActiveRecord::Migration def up create_table :call_for_papers do |t| - t.date :start_date, :null => false - t.date :end_date, :null => false - t.date :hard_deadline, :null => false - t.text :description, :null => false + t.date :start_date, null: false + t.date :end_date, null: false + t.date :hard_deadline, null: false + t.text :description, null: false t.references :conference t.timestamps diff --git a/db/migrate/20130103134212_create_registrations_table.rb b/db/migrate/20130103134212_create_registrations_table.rb index 9618d62c..41877ad5 100644 --- a/db/migrate/20130103134212_create_registrations_table.rb +++ b/db/migrate/20130103134212_create_registrations_table.rb @@ -4,9 +4,9 @@ class CreateRegistrationsTable < ActiveRecord::Migration t.references :person t.references :conference - t.boolean :attending_social_events, :default => true - t.boolean :attending_social_events_with_partner, :default => false - t.boolean :using_affiliated_lodging, :default => true + t.boolean :attending_social_events, default: true + t.boolean :attending_social_events_with_partner, default: false + t.boolean :using_affiliated_lodging, default: true t.date :arrival t.date :departure diff --git a/db/migrate/20130104142209_create_comments.rb b/db/migrate/20130104142209_create_comments.rb index 2cb9baca..f52c0c2b 100644 --- a/db/migrate/20130104142209_create_comments.rb +++ b/db/migrate/20130104142209_create_comments.rb @@ -1,9 +1,9 @@ class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| - t.string :title, :limit => 50, :default => "" + t.string :title, limit: 50, default: "" t.text :comment - t.references :commentable, :polymorphic => true + t.references :commentable, polymorphic: true t.references :user t.timestamps end diff --git a/db/migrate/20130105115603_create_event_attachments_table.rb b/db/migrate/20130105115603_create_event_attachments_table.rb index 9f140c27..0332eb03 100644 --- a/db/migrate/20130105115603_create_event_attachments_table.rb +++ b/db/migrate/20130105115603_create_event_attachments_table.rb @@ -2,12 +2,12 @@ class CreateEventAttachmentsTable < ActiveRecord::Migration def up create_table :event_attachments do |t| t.references :event - t.string :title, :null => false + t.string :title, null: false t.string :attachment_file_name t.string :attachment_content_type t.integer :attachment_file_size t.datetime :attachment_updated_at - t.boolean :public, :default => true + t.boolean :public, default: true t.timestamps end end diff --git a/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb b/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb index 48e53f37..5eaa39df 100644 --- a/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb +++ b/db/migrate/20130107113653_remove_cfp_and_reg_booleans_from_conferences.rb @@ -5,7 +5,7 @@ class RemoveCfpAndRegBooleansFromConferences < ActiveRecord::Migration end def down - add_column :conferences, :cfp_open, :default => false - add_column :registration_open, :default => false + add_column :conferences, :cfp_open, default: false + add_column :registration_open, default: false end end diff --git a/db/migrate/20130107114930_create_versions.rb b/db/migrate/20130107114930_create_versions.rb index be8287d8..02694362 100644 --- a/db/migrate/20130107114930_create_versions.rb +++ b/db/migrate/20130107114930_create_versions.rb @@ -1,9 +1,9 @@ class CreateVersions < ActiveRecord::Migration def self.up create_table :versions do |t| - t.string :item_type, :null => false - t.integer :item_id, :null => false - t.string :event, :null => false + t.string :item_type, null: false + t.integer :item_id, null: false + t.string :event, null: false t.string :whodunnit t.text :object t.text :object_changes diff --git a/db/migrate/20130113105652_create_email_table.rb b/db/migrate/20130113105652_create_email_table.rb index 0d566bcd..a7b6b3e6 100644 --- a/db/migrate/20130113105652_create_email_table.rb +++ b/db/migrate/20130113105652_create_email_table.rb @@ -2,10 +2,10 @@ class CreateEmailTable < ActiveRecord::Migration def up create_table :email_settings do |t| t.references :conference - t.boolean :send_on_registration, :default => true - t.boolean :send_on_accepted, :default => true - t.boolean :send_on_rejected, :default => true - t.boolean :send_on_confirmed_without_registration, :default => true + t.boolean :send_on_registration, default: true + t.boolean :send_on_accepted, default: true + t.boolean :send_on_rejected, default: true + t.boolean :send_on_confirmed_without_registration, default: true t.text :registration_email_template t.text :accepted_email_template t.text :rejected_email_template diff --git a/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb b/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb index b1d1e171..9ca53b4c 100644 --- a/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb +++ b/db/migrate/20130131100257_add_minimum_and_maximum_abstract_lengths_to_event_types.rb @@ -1,6 +1,6 @@ class AddMinimumAndMaximumAbstractLengthsToEventTypes < ActiveRecord::Migration def change - add_column :event_types, :minimum_abstract_length, :integer, :default => 0 - add_column :event_types, :maximum_abstract_length, :integer, :default => 500 + add_column :event_types, :minimum_abstract_length, :integer, default: 0 + add_column :event_types, :maximum_abstract_length, :integer, default: 500 end end diff --git a/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb b/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb index c1e55417..50287c31 100644 --- a/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb +++ b/db/migrate/20130202091022_add_dietary_choice_to_conferences.rb @@ -1,5 +1,5 @@ class AddDietaryChoiceToConferences < ActiveRecord::Migration def change - add_column :conferences, :use_dietary_choices, :boolean, :default => false + add_column :conferences, :use_dietary_choices, :boolean, default: false end end diff --git a/db/migrate/20130202091051_create_dietary_choices_table.rb b/db/migrate/20130202091051_create_dietary_choices_table.rb index bc320e88..464c7250 100644 --- a/db/migrate/20130202091051_create_dietary_choices_table.rb +++ b/db/migrate/20130202091051_create_dietary_choices_table.rb @@ -2,7 +2,7 @@ class CreateDietaryChoicesTable < ActiveRecord::Migration def up create_table :dietary_choices do |t| t.references :conference - t.string :title, :null => false + t.string :title, null: false t.timestamps end end diff --git a/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb b/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb index 63cd4251..e98b4e2f 100644 --- a/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb +++ b/db/migrate/20130202102024_add_handicapped_access_to_registrations.rb @@ -1,5 +1,5 @@ class AddHandicappedAccessToRegistrations < ActiveRecord::Migration def change - add_column :registrations, :handicapped_access_required, :boolean, :default => false + add_column :registrations, :handicapped_access_required, :boolean, default: false end end diff --git a/db/migrate/20130202130737_create_supporter_level_table.rb b/db/migrate/20130202130737_create_supporter_level_table.rb index 342a37fd..417fe9d0 100644 --- a/db/migrate/20130202130737_create_supporter_level_table.rb +++ b/db/migrate/20130202130737_create_supporter_level_table.rb @@ -2,7 +2,7 @@ class CreateSupporterLevelTable < ActiveRecord::Migration def up create_table :supporter_levels do |t| t.references :conference - t.string :title, :null => false + t.string :title, null: false t.string :url end end diff --git a/db/migrate/20130202130923_create_table_supporter_registrations.rb b/db/migrate/20130202130923_create_table_supporter_registrations.rb index 625d2286..5137ebb9 100644 --- a/db/migrate/20130202130923_create_table_supporter_registrations.rb +++ b/db/migrate/20130202130923_create_table_supporter_registrations.rb @@ -7,7 +7,7 @@ class CreateTableSupporterRegistrations < ActiveRecord::Migration t.string :name t.string :email t.string :code - t.boolean :code_is_valid, :default => false + t.boolean :code_is_valid, default: false end end diff --git a/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb b/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb index 5d3918b2..f201511a 100644 --- a/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb +++ b/db/migrate/20130202131932_add_use_supporter_levels_to_conferences.rb @@ -1,5 +1,5 @@ class AddUseSupporterLevelsToConferences < ActiveRecord::Migration def change - add_column :conferences, :use_supporter_levels, :boolean, :default => false + add_column :conferences, :use_supporter_levels, :boolean, default: false end end diff --git a/db/migrate/20130216120112_create_registrations_social_events_table.rb b/db/migrate/20130216120112_create_registrations_social_events_table.rb index df245ed0..9a783d4f 100644 --- a/db/migrate/20130216120112_create_registrations_social_events_table.rb +++ b/db/migrate/20130216120112_create_registrations_social_events_table.rb @@ -1,6 +1,6 @@ class CreateRegistrationsSocialEventsTable < ActiveRecord::Migration def up - create_table :registrations_social_events, :id => false do |t| + create_table :registrations_social_events, id: false do |t| t.references :registration, :social_event end end diff --git a/db/migrate/20130216122155_set_registration_defaults_to_false.rb b/db/migrate/20130216122155_set_registration_defaults_to_false.rb index b8bdce04..bbb45d64 100644 --- a/db/migrate/20130216122155_set_registration_defaults_to_false.rb +++ b/db/migrate/20130216122155_set_registration_defaults_to_false.rb @@ -1,6 +1,6 @@ class SetRegistrationDefaultsToFalse < ActiveRecord::Migration def up - change_column :registrations, :using_affiliated_lodging, :boolean, :default => false + change_column :registrations, :using_affiliated_lodging, :boolean, default: false end def down diff --git a/db/migrate/20130711043459_create_events_registrations_table.rb b/db/migrate/20130711043459_create_events_registrations_table.rb index 3238c571..0c084a9a 100644 --- a/db/migrate/20130711043459_create_events_registrations_table.rb +++ b/db/migrate/20130711043459_create_events_registrations_table.rb @@ -1,6 +1,6 @@ class CreateEventsRegistrationsTable < ActiveRecord::Migration def up - create_table :events_registrations, :id => false do |t| + create_table :events_registrations, id: false do |t| t.references :registration, :event end end diff --git a/db/migrate/20130712072609_add_attended_to_registrations.rb b/db/migrate/20130712072609_add_attended_to_registrations.rb index c7420f04..3a6f15ee 100644 --- a/db/migrate/20130712072609_add_attended_to_registrations.rb +++ b/db/migrate/20130712072609_add_attended_to_registrations.rb @@ -1,5 +1,5 @@ class AddAttendedToRegistrations < ActiveRecord::Migration def change - add_column :registrations, :attended, :boolean, :default => 0 + add_column :registrations, :attended, :boolean, default: 0 end end diff --git a/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb b/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb index 277f08fa..d0cabf03 100644 --- a/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb +++ b/db/migrate/20130728055450_add_schedule_changes_to_call_for_papers.rb @@ -1,5 +1,5 @@ class AddScheduleChangesToCallForPapers < ActiveRecord::Migration def change - add_column :call_for_papers, :schedule_changes, :boolean, :default => 0 + add_column :call_for_papers, :schedule_changes, :boolean, default: 0 end end diff --git a/db/migrate/20130815201317_add_rating_to_call_for_papers.rb b/db/migrate/20130815201317_add_rating_to_call_for_papers.rb index 234ba63d..1aab4ac6 100644 --- a/db/migrate/20130815201317_add_rating_to_call_for_papers.rb +++ b/db/migrate/20130815201317_add_rating_to_call_for_papers.rb @@ -1,5 +1,5 @@ class AddRatingToCallForPapers < ActiveRecord::Migration def change - add_column :call_for_papers, :rating, :integer, :null => 1 + add_column :call_for_papers, :rating, :integer, null: 1 end end diff --git a/db/migrate/20130821133651_create_vpositions.rb b/db/migrate/20130821133651_create_vpositions.rb index 10c15263..af7fa36c 100644 --- a/db/migrate/20130821133651_create_vpositions.rb +++ b/db/migrate/20130821133651_create_vpositions.rb @@ -2,7 +2,7 @@ class CreateVpositions < ActiveRecord::Migration def up create_table :vpositions do |t| t.references :conference - t.string :title, :null => false + t.string :title, null: false t.text :description t.timestamps diff --git a/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb index d81556d7..7fe2f314 100644 --- a/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb +++ b/db/migrate/20131228132353_change_default_rating_in_call_for_papers.rb @@ -1,9 +1,9 @@ class ChangeDefaultRatingInCallForPapers < ActiveRecord::Migration def up - change_column :call_for_papers, :rating, :integer, :default => 3 + change_column :call_for_papers, :rating, :integer, default: 3 end def down - change_column :call_for_papers, :rating, :integer, :null => 1 + change_column :call_for_papers, :rating, :integer, null: 1 end end diff --git a/db/migrate/20131229072532_registrations_vchoices.rb b/db/migrate/20131229072532_registrations_vchoices.rb index ae1d824e..1c25a32f 100644 --- a/db/migrate/20131229072532_registrations_vchoices.rb +++ b/db/migrate/20131229072532_registrations_vchoices.rb @@ -1,6 +1,6 @@ class RegistrationsVchoices < ActiveRecord::Migration def up - create_table :registrations_vchoices, :id => false do |t| + create_table :registrations_vchoices, id: false do |t| t.references :registration, :vchoice end end diff --git a/db/migrate/20140109191321_create_conferences_questions.rb b/db/migrate/20140109191321_create_conferences_questions.rb index 4a46952b..7cb8dbaf 100644 --- a/db/migrate/20140109191321_create_conferences_questions.rb +++ b/db/migrate/20140109191321_create_conferences_questions.rb @@ -1,6 +1,6 @@ class CreateConferencesQuestions < ActiveRecord::Migration def change - create_table :conferences_questions, :id => false do |t| + create_table :conferences_questions, id: false do |t| t.references :conference t.references :question end diff --git a/db/migrate/20140112192801_create_qanswers_registrations.rb b/db/migrate/20140112192801_create_qanswers_registrations.rb index b1a6b79c..e523173a 100644 --- a/db/migrate/20140112192801_create_qanswers_registrations.rb +++ b/db/migrate/20140112192801_create_qanswers_registrations.rb @@ -1,8 +1,8 @@ class CreateQanswersRegistrations < ActiveRecord::Migration def change - create_table :qanswers_registrations, :id => false do |t| - t.references :registration, :null => false - t.references :qanswer, :null => false + create_table :qanswers_registrations, id: false do |t| + t.references :registration, null: false + t.references :qanswer, null: false end end end diff --git a/db/migrate/20140212172244_create_difficulty_levels.rb b/db/migrate/20140212172244_create_difficulty_levels.rb index c4f06239..dd5be4d0 100644 --- a/db/migrate/20140212172244_create_difficulty_levels.rb +++ b/db/migrate/20140212172244_create_difficulty_levels.rb @@ -4,7 +4,7 @@ class CreateDifficultyLevels < ActiveRecord::Migration t.references :conference t.string :title t.text :description - t.string :color, :default => "#ffffff" + t.string :color, default: "#ffffff" t.timestamps end diff --git a/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb b/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb index 9fbb503f..00df5c25 100644 --- a/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb +++ b/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb @@ -1,5 +1,5 @@ class AddUseDifficultyLevelsToConference < ActiveRecord::Migration def change - add_column :conferences, :use_difficulty_levels, :boolean, :default => false + add_column :conferences, :use_difficulty_levels, :boolean, default: false end end diff --git a/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb b/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb index 9c8fc4e9..c579854e 100644 --- a/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb +++ b/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb @@ -1,11 +1,11 @@ class UseVdaysVpositionsDefaults < ActiveRecord::Migration def up - change_column :conferences, :use_vpositions, :boolean, :default => false - change_column :conferences, :use_vdays, :boolean, :default => false + change_column :conferences, :use_vpositions, :boolean, default: false + change_column :conferences, :use_vdays, :boolean, default: false end def down - change_column :conferences, :use_vpositions, :boolean, :default => nil - change_column :conferences, :use_vdays, :boolean, :default => nil + change_column :conferences, :use_vpositions, :boolean, default: nil + change_column :conferences, :use_vdays, :boolean, default: nil end end diff --git a/db/seeds.rb b/db/seeds.rb index c01e0fcc..92d873a8 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,22 +5,22 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) -Role.create(:name => "Participant") -Role.create(:name => "Organizer") -Role.create(:name => "Admin") +Role.create(name: "Participant") +Role.create(name: "Organizer") +Role.create(name: "Admin") -qtype_yesno = QuestionType.create(:title => "Yes/No") -QuestionType.create(:title => "Single Choice") -QuestionType.create(:title => "Multiple Choice") +qtype_yesno = QuestionType.create(title: "Yes/No") +QuestionType.create(title: "Single Choice") +QuestionType.create(title: "Multiple Choice") -answer_yes = Answer.create(:title => "Yes") -answer_no = Answer.create(:title => "No") +answer_yes = Answer.create(title: "Yes") +answer_no = Answer.create(title: "No") questions_yes_no = ["Do you need handicapped access to the venue?", "Are you attending with partner?", "Will you attend the social event(s)?", "Will you stay at suggested hotel?"] questions_yes_no.each do |i| - q = Question.create(:title => i, :question_type_id => qtype_yesno.id, :global => true) + q = Question.create(title: i, question_type_id: qtype_yesno.id, global: true) - Qanswer.create(:question_id => q.id, :answer_id => answer_no.id) - Qanswer.create(:question_id => q.id, :answer_id => answer_yes.id) + Qanswer.create(question_id: q.id, answer_id: answer_no.id) + Qanswer.create(question_id: q.id, answer_id: answer_yes.id) end diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 65e4ba37..4fb7551f 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -7,7 +7,7 @@ RSpec.configure do |config| DatabaseCleaner.strategy = :transaction end - config.before(:each, :js => true) do + config.before(:each, js: true) do DatabaseCleaner.strategy = :truncation end diff --git a/spec/support/login_macros.rb b/spec/support/login_macros.rb index 716cbbbe..67b9743c 100644 --- a/spec/support/login_macros.rb +++ b/spec/support/login_macros.rb @@ -3,7 +3,7 @@ module LoginMacros Warden.test_mode! def sign_in(user) - login_as(user, :scope => :user) + login_as(user, scope: :user) end def sign_out diff --git a/spec/views/home/index.html.haml_spec.rb b/spec/views/home/index.html.haml_spec.rb index 6affa8d8..5c258854 100644 --- a/spec/views/home/index.html.haml_spec.rb +++ b/spec/views/home/index.html.haml_spec.rb @@ -5,6 +5,6 @@ describe 'home/index' do allow(view).to receive(:date_string).and_return("January 17 - 21 2014") assign(:current, [create(:conference), create(:conference)]) render - expect(view).to render_template(:partial => "_conference_details", :count => 2) + expect(view).to render_template(partial: "_conference_details", count: 2) end end From bce659a5d944e4e2d46557596eb4401818401934 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 15:05:44 +0200 Subject: [PATCH 07/12] Move Accessor names to todo --- .rubocop_todo.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2839ff76..318072cf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -114,12 +114,6 @@ Style/FileName: Style/GuardClause: Enabled: false -# Offense count: 214 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/HashSyntax: - Enabled: false - # Offense count: 27 # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: @@ -330,3 +324,6 @@ Style/TrailingWhitespace: # Cop supports --auto-correct. Style/WordArray: MinSize: 5 + +Style/AccessorMethodName: + Enabled: false From ad2ec92cfa4baba2ab4d10d604febcc5e50db5dc Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 15:06:22 +0200 Subject: [PATCH 08/12] Add rubocop to travis run --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index ac711855..524d5c72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,3 +17,4 @@ before_script: - RAILS_ENV=test bundle exec rake db:migrate --trace script: - bundle exec rspec --color --format documentation + - bundle exec rubocop -D From 98e9dec25289567b12f7df422212922e1fcfbf98 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 15:23:10 +0200 Subject: [PATCH 09/12] Fix travis rubocop --- .rubocop.yml | 5 ++--- .travis.yml | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 538267b0..2dbf0b8e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -82,8 +82,7 @@ Lint/Void: AllCops: Include: - - Rakefile - - config.ru + - '**/Rakefile' + - '**/config.ru' Exclude: - db/schema.rb - - features/**/* diff --git a/.travis.yml b/.travis.yml index 524d5c72..432dbb1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,4 +17,4 @@ before_script: - RAILS_ENV=test bundle exec rake db:migrate --trace script: - bundle exec rspec --color --format documentation - - bundle exec rubocop -D + - bundle exec rubocop -Dc .rubocop.yml From 949ce14fcaa8c53c5113a9aef34f5aed60675e60 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 15:57:54 +0200 Subject: [PATCH 10/12] Update travis and rubocop to work together --- .gitignore | 1 - .rubocop.yml | 3 ++- .travis.yml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 37c69299..a9ebd7f2 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,3 @@ pickle-email-*.html /bundle /doc/app .ruby-version -rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml index 2dbf0b8e..dbd68f69 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -85,4 +85,5 @@ AllCops: - '**/Rakefile' - '**/config.ru' Exclude: - - db/schema.rb + - 'db/schema.rb' + - 'vendor/bundle/**/*' diff --git a/.travis.yml b/.travis.yml index 432dbb1c..62a547a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,5 @@ before_script: - cp config/secrets.yml.example config/secrets.yml - RAILS_ENV=test bundle exec rake db:migrate --trace script: - - bundle exec rspec --color --format documentation - - bundle exec rubocop -Dc .rubocop.yml + - 'bundle exec rspec --color --format documentation' + - 'bundle exec rubocop -Dc .rubocop.yml' From d245b9db124c6b1d56ba69c089262ff13b05c83c Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Mon, 21 Jul 2014 16:05:30 +0200 Subject: [PATCH 11/12] Echo version of phantomjs in use --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 62a547a3..28860e03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ rvm: - 2.1.1 before_install: - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" + - "echo `phantomjs -v`" branches: only: - master From 5717f1f55b91ffabaacd59b700211aeeb33f7c86 Mon Sep 17 00:00:00 2001 From: Artem Chernikov Date: Tue, 22 Jul 2014 10:22:12 +0200 Subject: [PATCH 12/12] Add readme section about style --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index ec9cf432..567067a4 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,13 @@ bundle exec guard This uses [spring](https://github.com/rails/spring) to provide a [fast feedback loop for the red/green cycle](http://bitzesty.com/blog/2013/05/enable-tdd-with-faster-ruby-on-rails-stack-reloading/). + +## Style +We are using [rubocop](https://github.com/bbatsov/rubocop) as a style checker. It is running each time +Travis run its testing routine. If you want to run it locally just `bundle exec rubocop`. +You can read through current enabled rules in `.rubocop.yml` file. Explanations of the defined [rules](http://rubydoc.info/github/bbatsov/rubocop/master/frames) can be found in modules [Cop::Lint](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Lint) and [Cop::Style](http://rubydoc.info/github/bbatsov/rubocop/master/Rubocop/Cop/Style). +Additionally you can read through [community ruby style-guide](https://github.com/bbatsov/ruby-style-guide) to better understand core principles. + # Communication GitHub issues are the primary way for communicating about specific proposed changes to this project. If you have other questions feel free to subscribe to