-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactoring the ruby code #18
Open
prashant-shekhar
wants to merge
1
commit into
elitmus:main
Choose a base branch
from
prashant-shekhar:refactoring-the-ruby-code
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
inherit_from: .rubocop_todo.yml | ||
AllCops: | ||
SuggestExtensions: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,371 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config` | ||
# on 2021-01-15 10:55:07 UTC using RuboCop version 1.7.0. | ||
# 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: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. | ||
# Include: **/*.gemfile, **/Gemfile, **/gems.rb | ||
Bundler/OrderedGems: | ||
Exclude: | ||
- 'Gemfile' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, IndentationWidth. | ||
# SupportedStyles: with_first_argument, with_fixed_indentation | ||
Layout/ArgumentAlignment: | ||
Exclude: | ||
- 'bin/webpack' | ||
- 'bin/webpack-dev-server' | ||
|
||
# Offense count: 6 | ||
# Cop supports --auto-correct. | ||
Layout/EmptyLineAfterGuardClause: | ||
Exclude: | ||
- 'bin/bundle' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Layout/EmptyLines: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle. | ||
# SupportedStyles: around, only_before | ||
Layout/EmptyLinesAroundAccessModifier: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: IndentationWidth. | ||
# SupportedStyles: special_inside_parentheses, consistent, align_braces | ||
Layout/FirstHashElementIndentation: | ||
EnforcedStyle: consistent | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: Width, IgnoredPatterns. | ||
Layout/IndentationWidth: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
|
||
# Offense count: 3 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. | ||
Layout/LeadingCommentSpace: | ||
Exclude: | ||
- 'Gemfile' | ||
- 'test/controllers/api/v1/users_controller_test.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Layout/LeadingEmptyLines: | ||
Exclude: | ||
- 'config/initializers/truemail.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, IndentationWidth. | ||
# SupportedStyles: aligned, indented | ||
Layout/MultilineOperationIndentation: | ||
Exclude: | ||
- 'bin/bundle' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
Layout/SpaceAfterColon: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
Layout/SpaceAfterComma: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
- 'app/models/user.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Layout/SpaceAroundKeyword: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
|
||
# Offense count: 8 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. | ||
# SupportedStylesForExponentOperator: space, no_space | ||
Layout/SpaceAroundOperators: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
|
||
# Offense count: 4 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. | ||
# SupportedStyles: space, no_space, compact | ||
# SupportedStylesForEmptyBrackets: space, no_space | ||
Layout/SpaceInsideArrayLiteralBrackets: | ||
Exclude: | ||
- 'db/migrate/20210102105504_create_active_storage_tables.active_storage.rb' | ||
|
||
# Offense count: 3 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. | ||
# SupportedStyles: space, no_space, compact | ||
# SupportedStylesForEmptyBraces: space, no_space | ||
Layout/SpaceInsideHashLiteralBraces: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle. | ||
# SupportedStyles: final_newline, final_blank_line | ||
Layout/TrailingEmptyLines: | ||
Exclude: | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
- 'config/initializers/truemail.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Lint/DeprecatedClassMethods: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 1 | ||
Lint/IneffectiveAccessModifier: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Lint/RedundantStringCoercion: | ||
Exclude: | ||
- 'app/workers/export_worker.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. | ||
Lint/UnusedMethodArgument: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. | ||
Lint/UselessAccessModifier: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. | ||
Metrics/AbcSize: | ||
Max: 34 | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. | ||
# IgnoredMethods: refine | ||
Metrics/BlockLength: | ||
Max: 47 | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: IgnoredMethods. | ||
Metrics/CyclomaticComplexity: | ||
Max: 9 | ||
|
||
# Offense count: 6 | ||
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. | ||
Metrics/MethodLength: | ||
Max: 22 | ||
|
||
# Offense count: 1 | ||
# Configuration parameters: IgnoredMethods. | ||
Metrics/PerceivedComplexity: | ||
Max: 9 | ||
|
||
# Offense count: 8 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle. | ||
# SupportedStyles: nested, compact | ||
Style/ClassAndModuleChildren: | ||
Exclude: | ||
- 'app/controllers/api/v1/emails_controller.rb' | ||
- 'app/controllers/api/v1/uploads_controller.rb' | ||
- 'app/controllers/api/v1/users_controller.rb' | ||
- 'test/channels/application_cable/connection_test.rb' | ||
- 'test/controllers/api/v1/emails_controller_test.rb' | ||
- 'test/controllers/api/v1/uploads_controller_test.rb' | ||
- 'test/controllers/api/v1/users_controller_test.rb' | ||
- 'test/test_helper.rb' | ||
|
||
# Offense count: 17 | ||
Style/Documentation: | ||
Enabled: false | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle. | ||
# SupportedStyles: compact, expanded | ||
Style/EmptyMethod: | ||
Exclude: | ||
- 'app/controllers/api/v1/uploads_controller.rb' | ||
- 'app/controllers/home_controller.rb' | ||
|
||
# Offense count: 3 | ||
# Cop supports --auto-correct. | ||
Style/ExpandPathArguments: | ||
Exclude: | ||
- 'bin/bundle' | ||
- 'bin/rails' | ||
- 'bin/rake' | ||
|
||
# Offense count: 67 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle. | ||
# SupportedStyles: always, always_true, never | ||
Style/FrozenStringLiteralComment: | ||
Enabled: false | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/GlobalStdStream: | ||
Exclude: | ||
- 'config/environments/production.rb' | ||
|
||
# Offense count: 3 | ||
# Cop supports --auto-correct. | ||
Style/IfUnlessModifier: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
- 'bin/bundle' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle. | ||
# SupportedStyles: both, prefix, postfix | ||
Style/NegatedIf: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: MinDigits, Strict. | ||
Style/NumericLiterals: | ||
Exclude: | ||
- 'db/schema.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/PerlBackrefs: | ||
Exclude: | ||
- 'bin/bundle' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/RedundantBegin: | ||
Exclude: | ||
- 'bin/yarn' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/RedundantConditional: | ||
Exclude: | ||
- 'app/models/user.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: SafeForConstants. | ||
Style/RedundantFetchBlock: | ||
Exclude: | ||
- 'config/puma.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/RedundantRegexpEscape: | ||
Exclude: | ||
- 'config/initializers/truemail.rb' | ||
|
||
# Offense count: 4 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AllowMultipleReturnValues. | ||
Style/RedundantReturn: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
Style/RedundantSelf: | ||
Exclude: | ||
- 'app/models/user.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AllowModifier. | ||
Style/SoleNestedConditional: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: . | ||
# SupportedStyles: use_perl_names, use_english_names | ||
Style/SpecialGlobalVars: | ||
EnforcedStyle: use_perl_names | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
Style/StderrPuts: | ||
Exclude: | ||
- 'bin/yarn' | ||
|
||
# Offense count: 282 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. | ||
# SupportedStyles: single_quotes, double_quotes | ||
Style/StringLiterals: | ||
Enabled: false | ||
|
||
# Offense count: 6 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: MinSize. | ||
# SupportedStyles: percent, brackets | ||
Style/SymbolArray: | ||
EnforcedStyle: brackets | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: IgnoredMethods. | ||
# IgnoredMethods: respond_to, define_method | ||
Style/SymbolProc: | ||
Exclude: | ||
- 'app/models/email.rb' | ||
|
||
# Offense count: 2 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: EnforcedStyleForMultiline. | ||
# SupportedStylesForMultiline: comma, consistent_comma, no_comma | ||
Style/TrailingCommaInHashLiteral: | ||
Exclude: | ||
- 'app/workers/export_worker.rb' | ||
- 'config/environments/development.rb' | ||
|
||
# Offense count: 1 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: MinSize, WordRegex. | ||
# SupportedStyles: percent, brackets | ||
Style/WordArray: | ||
EnforcedStyle: brackets | ||
|
||
# Offense count: 11 | ||
# Cop supports --auto-correct. | ||
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. | ||
# URISchemes: http, https | ||
Layout/LineLength: | ||
Max: 198 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
class Api::V1::EmailsController < ApplicationController | ||
before_action :require_login | ||
def index | ||
user = User.find(params[:userid]) | ||
emails = user.emails | ||
render json: emails | ||
emails = @logged_in_user.emails | ||
end | ||
|
||
def create | ||
render json: Email.validate_email(params[:email], params[:userid]) | ||
render json: Email.validate_email(params[:email], @logged_in_user.id) | ||
end | ||
|
||
def require_login | ||
render json: { message: "Please Login First!" }, status: :unauthorized unless !!session_user | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did
@logged_in_user
variable come from? where is it defined?