Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rubocop - Use string interpolation (notes_controller) #11446

Closed
5 tasks
TildaDares opened this issue Sep 28, 2022 · 19 comments · Fixed by #11489
Closed
5 tasks

Rubocop - Use string interpolation (notes_controller) #11446

TildaDares opened this issue Sep 28, 2022 · 19 comments · Fixed by #11489
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template.

Comments

@TildaDares
Copy link
Member

Hi, this is a first-timers-only issue. This means we've worked to make it more legible to folks who either haven't contributed to our codebase before, or even folks who haven't contributed to open source before.

If that's you, we're interested in helping you take the first step and can answer questions and help you out as you do. Note that we're especially interested in contributions from people from underrepresented groups in free and open-source software!

We know that the process of creating a pull request is one of the biggest barriers for new contributors. This issue is for you 💝

If you have contributed before, consider leaving this one for someone new and looking through our general help wanted issues. Thanks!

🤔 What you will need to know.

Nothing. This issue is meant to welcome you to Open Source :) We are happy to walk you through the process.

📋 Step by Step

  • 🙋 Claim this issue: Claim the issue by commenting. If someone else has claimed it, ask if they've opened a pull request already and if they're stuck -- maybe you can help them solve a problem or move it along!
💡 Learn how to claim 🙋

Claiming an issue

Unless the issue is marked as reserved for someone, you can just say "I'd like to try this!" and then you've claimed it - no need to wait for someone to assign it to you. Just be sure you link your pull request (PR) to this issue so we can see where your solution is.

And open one early if possible - even before you've completed it with additional commits - and others can help you figure out any issues you may face.

See this page for some help in taking your first steps!

Below is a "diff" showing in red (and a -) which lines to remove, and in green (and a +) which lines to add:

@@ -140,7 +140,7 @@ class NotesController < ApplicationController
       return
     elsif params[:draft] == "true"
       token = SecureRandom.urlsafe_base64(16, false)
-      @node.slug = @node.slug + " token:" + token
+      @node.slug = "#{@node.slug} token:#{token}"
       @node.save!
     end

@@ -153,7 +153,7 @@ class NotesController < ApplicationController
       if params[:event] == 'on'
         @node.add_tag('event', current_user)
         @node.add_tag('event:rsvp', current_user)
-        @node.add_tag('date:' + params[:date], current_user) if params[:date]
+        @node.add_tag("date:#{params[:date]}", current_user) if params[:date]
       end

       @node.add_tag('first-time-poster', current_user) if current_user.first_time_poster
@@ -273,7 +273,7 @@ class NotesController < ApplicationController
         if request.xhr?
           render plain: "#{@node.path(format)}?_=#{Time.now.to_i}"
         else
-          redirect_to URI.parse(@node.path(format)).path + '?_=' + Time.now.to_i.to_s
+          redirect_to "#{URI.parse(@node.path(format)).path}?_=#{Time.now.to_i}"
         end
       else
         flash[:error] = I18n.t('notes_controller.edit_not_saved')
@@ -301,13 +301,13 @@ class NotesController < ApplicationController
               render plain: I18n.t('notes_controller.content_deleted')
             else
               flash[:notice] = I18n.t('notes_controller.content_deleted')
-              redirect_to '/dashboard' + '?_=' + Time.now.to_i.to_s
+              redirect_to "/dashboard?_=#{Time.now.to_i}"
             end
           end
         end
       else
         flash[:error] = I18n.t('notes_controller.more_than_one_contributor')
-        redirect_to '/dashboard' + '?_=' + Time.now.to_i.to_s
+        redirect_to "/dashboard?_=#{Time.now.to_i}"
     end
     else
       prompt_login
@@ -328,7 +328,7 @@ class NotesController < ApplicationController
   def author_topic
     @user = User.find_by(name: params[:author])
     @tagnames = params[:topic].split('+')
-    @title = @user.name + " on '" + @tagnames.join(', ') + "'"
+    @title = "#{@user.name} on '#{@tagnames.join(', ')}'"
     @notes = @user.notes_for_tags(@tagnames)
     @unpaginated = true
     render template: 'notes/index'
@@ -391,8 +391,8 @@ class NotesController < ApplicationController
     # leave a comment
     @comment = @node.add_comment(subject: 'rsvp', uid: current_user.uid, body: 'I will be attending!')
     # make a tag
-    @node.add_tag('rsvp:' + current_user.username, current_user)
-    redirect_to URI.parse(@node.path).path + '#comments'
+    @node.add_tag("rsvp:#{current_user.username}", current_user)
+    redirect_to "#{URI.parse(node.path).path}#comments"
   end

   # Updates title of a wiki page, takes id and title as query string params. maps to '/node/update/title'
@@ -400,21 +400,21 @@ class NotesController < ApplicationController
     node = Node.find params[:id].to_i
     unless current_user && current_user == node.author
       flash.keep[:error] = I18n.t('notes_controller.author_can_edit_note')
-      return redirect_to URI.parse(node.path).path + "#comments"
+      return redirect_to "#{URI.parse(node.path).path}#comments"
     end
     node.update(title: params[:title])
-    redirect_to URI.parse(node.path).path + "#comments"
+    redirect_to "#{URI.parse(node.path).path}#comments"
   end

   def publish_draft
     @node = Node.find(params[:id])
-    if current_user && current_user.uid == @node.uid || current_user.can_moderate? || @node.has_tag("with:#{current_user.username}")
+    if (current_user && current_user.uid == @node.uid) || current_user.can_moderate? || @node.has_tag("with:#{current_user.username}")
       @node.path = @node.generate_path
       @node.slug = @node.slug.split('token').first
       @node['created'] = DateTime.now.to_i # odd assignment needed due to legacy Drupal column types
       @node['changed'] = DateTime.now.to_i
       revision = @node.latest
-      revision['timestamp'] = DateTime.now.to_i # odd assignment needed due to legacy Drupal column types
+      revision['timestamp'] = DateTime.now.to_i # odd assignment needed due to legacy Drupal column types
       revision.save
       @node.save
       @node.publish
@@ -467,11 +467,13 @@ class NotesController < ApplicationController
   end

   def new_preview_note
-    Node.new_preview_note(uid: current_user.uid,
+    Node.new_preview_note(
+      uid: current_user.uid,
       title: params[:title],
       body: params[:body],
       main_image: params[:main_image],
-      location: params[:location])
+      location: params[:location]
+    )
   end

   def not_draft_and_user_is_first_time_poster?
  • 💾 Commit your changes

  • 🔀 Start a Pull Request. There are two ways how you can start a pull request:

  1. If you are familiar with the terminal or would like to learn it, here is a great tutorial on how to send a pull request using the terminal.

  2. You can also edit files directly in your browser and open a pull request from there.

  • 🏁 Done Ask in the comments for a review :)

Please keep us updated

💬⏰ - We encourage contributors to be respectful to the community and provide an update within a week of claiming the first-timers-only issue. We're happy to keep it assigned to you as long as you need it if you update us with a request for more time or help, but if we don't see any activity a week after you claim it we may reassign it to give someone else a chance. Thank you in advance!

If this happens to you, don't sweat it! Grab another open issue.

Is someone else already working on this?

🔗- We encourage contributors to link to the original issue in their pull request so all users can easily see if someone's already started on it.

👥- If someone seems stuck, offer them some help! Otherwise, take a look at some other issues you can help with. Thanks!

🤔❓ Questions?

Leave a comment below, and reach out in our chatroom!

@TildaDares TildaDares added the first-timers-only They need to be well-formatted using the First-timers_Issue_Template. label Sep 28, 2022
@TildaDares
Copy link
Member Author

Reserved for @Narayan1670 for 24 hours!

@Narayan1670
Copy link

hi @TildaDares , I would Like to claim this issue.

@TildaDares
Copy link
Member Author

Hi @Narayan1670, please go ahead!

@Narayan1670
Copy link

Done, @TildaDares please check.
Thanks.

@MAX-786
Copy link

MAX-786 commented Sep 29, 2022

Hi, can I get it if this gets re-assigned? Thanks.

@TildaDares
Copy link
Member Author

Hi @MAX-786, please request for an issue here #11105. Thank you!

@TildaDares
Copy link
Member Author

Hi @Narayan1670, do you need any help with this? Please feel free to ask.

@MAX-786
Copy link

MAX-786 commented Oct 8, 2022 via email

@TildaDares
Copy link
Member Author

Hi @MAX-786, please request for an issue here #11105. Thank you!

Hi @MAX-786, please leave a comment in the issue linked above. Thank you!

@Dapper50
Copy link
Contributor

Dapper50 commented Oct 9, 2022

hi @TildaDares Please can i work on this?

@TildaDares
Copy link
Member Author

Hi @Dapper50, contributors are only allowed to work on one first-timers-only issue. Please look for other issues without the first-timers-only label or you can create an FTO for others. Thank you!

@Ibom99
Copy link
Contributor

Ibom99 commented Oct 9, 2022

Hi @TildaDares is this issue still open for first timers?

@TildaDares
Copy link
Member Author

Hi @Ibom99, someone is already working on this. I’ll let you know if that changes. Thank you!

@RealRichi3
Copy link
Contributor

Hi @TildaDares, I'm trying to create a first time issue for others to work on, how to i add the code snippet just the way you did, it should also have the red and green lines too

@7malikk
Copy link
Contributor

7malikk commented Oct 13, 2022

@RealRichi3 Hello, make use of the FTO template here
If you run into any issues, ping me, I'll be glad to help

@RealRichi3
Copy link
Contributor

Thanks @7malikk, already found a way tho

@TildaDares
Copy link
Member Author

Reserved for @IdayatSanni for 24 hours!

@Dhei-vid
Copy link
Contributor

@TildaDares is there anything I could work on?

@IdayatSanni
Copy link
Contributor

Hello @TildaDares Yes I will work on it. thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-timers-only They need to be well-formatted using the First-timers_Issue_Template.
Projects
None yet
9 participants