Skip to content
Snippets Groups Projects
Commit b5291f95 authored by Gabriel Mazetto's avatar Gabriel Mazetto :spy_tone1:
Browse files

Fixed Rubocop offenses

parent d1f1c5c6
No related branches found
No related tags found
No related merge requests found
Showing
with 40 additions and 45 deletions
class Dashboard::SnippetsController < Dashboard::ApplicationController
def index
@snippets = SnippetsFinder.new.execute(current_user,
@snippets = SnippetsFinder.new.execute(
current_user,
filter: :by_user,
user: current_user,
scope: params[:scope]
Loading
Loading
Loading
Loading
@@ -68,7 +68,7 @@ class Projects::NotesController < Projects::ApplicationController
data = {
author: current_user,
is_award: true,
note: note_params[:note].gsub(":", '')
note: note_params[:note].delete(":")
}
 
note = noteable.notes.find_by(data)
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
 
if protected_branch &&
protected_branch.update_attributes(
developers_can_push: params[:developers_can_push]
developers_can_push: params[:developers_can_push]
)
 
respond_to do |format|
Loading
Loading
Loading
Loading
@@ -61,7 +61,7 @@ module ApplicationHelper
options[:class] ||= ''
options[:class] << ' identicon'
bg_key = project.id % 7
style = "background-color: ##{ allowed_colors.values[bg_key] }; color: #555"
style = "background-color: ##{allowed_colors.values[bg_key]}; color: #555"
 
content_tag(:div, class: options[:class], style: style) do
project.name[0, 1].upcase
Loading
Loading
module ExternalWikiHelper
def get_project_wiki_path(project)
external_wiki_service = project.services.
select { |service| service.to_param == 'external_wiki' }.first
find { |service| service.to_param == 'external_wiki' }
if external_wiki_service.present? && external_wiki_service.active?
external_wiki_service.properties['external_wiki_url']
else
Loading
Loading
Loading
Loading
@@ -65,7 +65,8 @@ module GitlabMarkdownHelper
end
 
def asciidoc(text)
Gitlab::Asciidoc.render(text,
Gitlab::Asciidoc.render(
text,
project: @project,
current_user: (current_user if defined?(current_user)),
 
Loading
Loading
Loading
Loading
@@ -330,10 +330,9 @@ module ProjectsHelper
def filename_path(project, filename)
if project && blob = project.repository.send(filename)
namespace_project_blob_path(
project.namespace,
project,
tree_join(project.default_branch,
blob.name)
project.namespace,
project,
tree_join(project.default_branch, blob.name)
)
end
end
Loading
Loading
Loading
Loading
@@ -79,7 +79,7 @@ module TreeHelper
part_path = File.join(part_path, part) unless part_path.empty?
part_path = part if part_path.empty?
 
next unless parts.last(2).include?(part) if parts.count > max_links
next if parts.count > max_links && !parts.last(2).include?(part)
yield(part, tree_join(@ref, part_path))
end
end
Loading
Loading
Loading
Loading
@@ -17,7 +17,7 @@ class Notify < BaseMailer
subject: subject,
body: body.html_safe,
content_type: 'text/html'
)
)
end
 
# Splits "gitlab.corp.company.com" up into "gitlab.corp.company.com",
Loading
Loading
Loading
Loading
@@ -126,12 +126,12 @@ class ApplicationSetting < ActiveRecord::Base
def restricted_signup_domains_raw=(values)
self.restricted_signup_domains = []
self.restricted_signup_domains = values.split(
/\s*[,;]\s* # comma or semicolon, optionally surrounded by whitespace
| # or
\s # any whitespace character
| # or
[\r\n] # any number of newline characters
/x)
/\s*[,;]\s* # comma or semicolon, optionally surrounded by whitespace
| # or
\s # any whitespace character
| # or
[\r\n] # any number of newline characters
/x)
self.restricted_signup_domains.reject! { |d| d.empty? }
end
end
Loading
Loading
@@ -13,7 +13,7 @@ module TokenAuthenticatable
@token_fields << token_field
 
define_singleton_method("find_by_#{token_field}") do |token|
where(token_field => token).first if token
find_by(token_field => token) if token
end
 
define_method("ensure_#{token_field}") do
Loading
Loading
@@ -37,7 +37,7 @@ module TokenAuthenticatable
def generate_token_for(token_field)
loop do
token = Devise.friendly_token
break token unless self.class.unscoped.where(token_field => token).first
break token unless self.class.unscoped.find_by(token_field => token)
end
end
end
Loading
Loading
@@ -194,9 +194,7 @@ class MergeRequest < ActiveRecord::Base
similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id
if similar_mrs.any?
errors.add :validate_branches,
"Cannot Create: This merge request already exists: #{
similar_mrs.pluck(:title)
}"
"Cannot Create: This merge request already exists: #{similar_mrs.pluck(:title)}"
end
end
end
Loading
Loading
Loading
Loading
@@ -45,7 +45,7 @@ class Namespace < ActiveRecord::Base
 
class << self
def by_path(path)
where('lower(path) = :value', value: path.downcase).first
find_by('lower(path) = :value', value: path.downcase)
end
 
# Case insensetive search for namespace by path or name
Loading
Loading
@@ -148,6 +148,6 @@ class Namespace < ActiveRecord::Base
end
 
def find_fork_of(project)
projects.joins(:forked_project_link).where('forked_project_links.forked_from_project_id = ?', project.id).first
projects.joins(:forked_project_link).find_by('forked_project_links.forked_from_project_id = ?', project.id)
end
end
Loading
Loading
@@ -265,7 +265,7 @@ class Project < ActiveRecord::Base
joins(:namespace).
iwhere('namespaces.path' => namespace_path)
 
projects.where('projects.path' => project_path).take ||
projects.find_by('projects.path' => project_path) ||
projects.iwhere('projects.path' => project_path).take
end
 
Loading
Loading
@@ -450,7 +450,7 @@ class Project < ActiveRecord::Base
end
 
def external_issue_tracker
@external_issues_tracker ||= external_issues_trackers.select(&:activated?).first
@external_issues_tracker ||= external_issues_trackers.find(&:activated?)
end
 
def can_have_issues_tracker_id?
Loading
Loading
@@ -496,7 +496,7 @@ class Project < ActiveRecord::Base
end
 
def ci_service
@ci_service ||= ci_services.select(&:activated?).first
@ci_service ||= ci_services.find(&:activated?)
end
 
def avatar_type
Loading
Loading
@@ -547,7 +547,7 @@ class Project < ActiveRecord::Base
end
 
def project_member_by_name_or_email(name = nil, email = nil)
user = users.where('name like ? or email like ?', name, email).first
user = users.find_by('name like ? or email like ?', name, email)
project_members.where(user: user) if user
end
 
Loading
Loading
@@ -722,7 +722,7 @@ class Project < ActiveRecord::Base
end
 
def project_member(user)
project_members.where(user_id: user).first
project_members.find_by(user_id: user)
end
 
def default_branch
Loading
Loading
Loading
Loading
@@ -27,12 +27,10 @@ class BambooService < CiService
validates :build_key, presence: true, if: :activated?
validates :username,
presence: true,
if: ->(service) { service.password? },
if: :activated?
if: ->(service) { service.activated? && service.password? }
validates :password,
presence: true,
if: ->(service) { service.username? },
if: :activated?
if: ->(service) { service.activated? && service.username? }
 
attr_accessor :response
 
Loading
Loading
Loading
Loading
@@ -58,6 +58,6 @@ class FlowdockService < Service
repo_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}",
commit_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/%s",
diff_url: "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/compare/%s...%s",
)
)
end
end
Loading
Loading
@@ -57,6 +57,6 @@ class GemnasiumService < Service
token: token,
api_key: api_key,
repo: project.repository.path_to_repo
)
)
end
end
Loading
Loading
@@ -27,12 +27,10 @@ class TeamcityService < CiService
validates :build_type, presence: true, if: :activated?
validates :username,
presence: true,
if: ->(service) { service.password? },
if: :activated?
if: ->(service) { service.activated? && service.password? }
validates :password,
presence: true,
if: ->(service) { service.username? },
if: :activated?
if: ->(service) { service.activated? && service.username? }
 
attr_accessor :response
 
Loading
Loading
@@ -147,6 +145,6 @@ class TeamcityService < CiService
'</build>',
headers: { 'Content-type' => 'application/xml' },
basic_auth: auth
)
)
end
end
Loading
Loading
@@ -220,9 +220,9 @@ class User < ActiveRecord::Base
def find_for_database_authentication(warden_conditions)
conditions = warden_conditions.dup
if login = conditions.delete(:login)
where(conditions).where(["lower(username) = :value OR lower(email) = :value", { value: login.downcase }]).first
where(conditions).find_by("lower(username) = :value OR lower(email) = :value", value: login.downcase)
else
where(conditions).first
find_by(conditions)
end
end
 
Loading
Loading
@@ -285,7 +285,7 @@ class User < ActiveRecord::Base
end
 
def by_username_or_id(name_or_id)
where('users.username = ? OR users.id = ?', name_or_id.to_s, name_or_id.to_i).first
find_by('users.username = ? OR users.id = ?', name_or_id.to_s, name_or_id.to_i)
end
 
def build_user(attrs = {})
Loading
Loading
Loading
Loading
@@ -112,7 +112,7 @@ module MergeRequests
 
merge_requests_for_source_branch.each do |merge_request|
SystemNoteService.change_branch_presence(
merge_request, merge_request.project, @current_user,
merge_request, merge_request.project, @current_user,
:source, @branch_name, presence)
end
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment