Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
5c7a7381
Commit
5c7a7381
authored
Mar 08, 2018
by
Gabriel Mazetto
Committed by
Nick Thomas
Mar 08, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CE] Add Naming/FileName rule checking expected class/module per filename
parent
a2844000
Changes
27
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
224 additions
and
44 deletions
+224
-44
.rubocop.yml
.rubocop.yml
+72
-0
app/models/cycle_analytics/summary.rb
app/models/cycle_analytics/summary.rb
+0
-0
config/routes/git_http.rb
config/routes/git_http.rb
+1
-1
config/routes/group.rb
config/routes/group.rb
+1
-3
config/routes/project.rb
config/routes/project.rb
+1
-3
config/routes/user.rb
config/routes/user.rb
+1
-3
lib/constraints/group_url_constrainer.rb
lib/constraints/group_url_constrainer.rb
+7
-5
lib/constraints/project_url_constrainer.rb
lib/constraints/project_url_constrainer.rb
+11
-9
lib/constraints/user_url_constrainer.rb
lib/constraints/user_url_constrainer.rb
+7
-5
lib/declarative_policy.rb
lib/declarative_policy.rb
+3
-1
lib/declarative_policy/delegate_dsl.rb
lib/declarative_policy/delegate_dsl.rb
+16
-0
lib/declarative_policy/policy_dsl.rb
lib/declarative_policy/policy_dsl.rb
+44
-0
lib/declarative_policy/preferred_scope.rb
lib/declarative_policy/preferred_scope.rb
+1
-1
lib/declarative_policy/rule_dsl.rb
lib/declarative_policy/rule_dsl.rb
+45
-0
lib/gitlab/auth/result.rb
lib/gitlab/auth/result.rb
+1
-1
lib/gitlab/ci/pipeline/chain/command.rb
lib/gitlab/ci/pipeline/chain/command.rb
+1
-1
lib/gitlab/health_checks/metric.rb
lib/gitlab/health_checks/metric.rb
+1
-1
lib/gitlab/health_checks/result.rb
lib/gitlab/health_checks/result.rb
+1
-1
lib/gitlab/middleware/release_env.rb
lib/gitlab/middleware/release_env.rb
+1
-1
lib/gitlab/slash_commands/result.rb
lib/gitlab/slash_commands/result.rb
+1
-1
lib/haml_lint/inline_javascript.rb
lib/haml_lint/inline_javascript.rb
+1
-1
qa/qa/page/project/settings/ci_cd.rb
qa/qa/page/project/settings/ci_cd.rb
+1
-1
rubocop/rubocop.rb
rubocop/rubocop.rb
+1
-0
spec/lib/constraints/group_url_constrainer_spec.rb
spec/lib/constraints/group_url_constrainer_spec.rb
+1
-1
spec/lib/constraints/project_url_constrainer_spec.rb
spec/lib/constraints/project_url_constrainer_spec.rb
+1
-1
spec/lib/constraints/user_url_constrainer_spec.rb
spec/lib/constraints/user_url_constrainer_spec.rb
+1
-1
spec/routing/routing_spec.rb
spec/routing/routing_spec.rb
+2
-2
No files found.
.rubocop.yml
View file @
5c7a7381
...
...
@@ -31,6 +31,78 @@ Style/MutableConstant:
-
'
ee/db/post_migrate/**/*'
-
'
ee/db/geo/migrate/**/*'
Naming/FileName
:
ExpectMatchingDefinition
:
true
Exclude
:
-
'
spec/**/*'
-
'
features/**/*'
-
'
ee/spec/**/*'
-
'
qa/spec/**/*'
-
'
qa/qa/specs/**/*'
-
'
qa/bin/*'
-
'
config/**/*'
-
'
lib/generators/**/*'
-
'
ee/lib/generators/**/*'
IgnoreExecutableScripts
:
true
AllowedAcronyms
:
-
EE
-
JSON
-
LDAP
-
IO
-
HMAC
-
QA
-
ENV
-
STL
-
PDF
-
SVG
-
CTE
-
DN
-
RSA
-
CI
-
CD
-
OAuth
# default ones:
-
CLI
-
DSL
-
ACL
-
API
-
ASCII
-
CPU
-
CSS
-
DNS
-
EOF
-
GUID
-
HTML
-
HTTP
-
HTTPS
-
ID
-
IP
-
JSON
-
LHS
-
QPS
-
RAM
-
RHS
-
RPC
-
SLA
-
SMTP
-
SQL
-
SSH
-
TCP
-
TLS
-
TTL
-
UDP
-
UI
-
UID
-
UUID
-
URI
-
URL
-
UTF8
-
VM
-
XML
-
XMPP
-
XSRF
-
XSS
# Gitlab ###################################################################
Gitlab/ModuleWithInstanceVariables
:
...
...
app/models/cycle_analytics/summary.rb
deleted
100644 → 0
View file @
a2844000
config/routes/git_http.rb
View file @
5c7a7381
...
...
@@ -40,7 +40,7 @@ scope(path: '*namespace_id/:project_id',
# /info/refs?service=git-receive-pack, but nothing else.
#
git_http_handshake
=
lambda
do
|
request
|
ProjectUrlConstrainer
.
new
.
matches?
(
request
)
&&
::
Constraints
::
ProjectUrlConstrainer
.
new
.
matches?
(
request
)
&&
(
request
.
query_string
.
blank?
||
request
.
query_string
.
match
(
/\Aservice=git-(upload|receive)-pack\z/
))
end
...
...
config/routes/group.rb
View file @
5c7a7381
require
'constraints/group_url_constrainer'
resources
:groups
,
only:
[
:index
,
:new
,
:create
]
do
post
:preview_markdown
end
constraints
(
GroupUrlConstrainer
.
new
)
do
constraints
(
::
Constraints
::
GroupUrlConstrainer
.
new
)
do
scope
(
path:
'groups/*id'
,
controller: :groups
,
constraints:
{
id:
Gitlab
::
PathRegex
.
full_namespace_route_regex
,
format:
/(html|json|atom)/
})
do
...
...
config/routes/project.rb
View file @
5c7a7381
require
'constraints/project_url_constrainer'
resources
:projects
,
only:
[
:index
,
:new
,
:create
]
draw
:git_http
constraints
(
ProjectUrlConstrainer
.
new
)
do
constraints
(
::
Constraints
::
ProjectUrlConstrainer
.
new
)
do
# If the route has a wildcard segment, the segment has a regex constraint,
# the segment is potentially followed by _another_ wildcard segment, and
# the `format` option is not set to false, we need to specify that
...
...
config/routes/user.rb
View file @
5c7a7381
require
'constraints/user_url_constrainer'
devise_for
:users
,
controllers:
{
omniauth_callbacks: :omniauth_callbacks
,
registrations: :registrations
,
passwords: :passwords
,
...
...
@@ -35,7 +33,7 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
get
'/u/:username/contributed'
,
to:
redirect
(
'users/%{username}/contributed'
)
end
constraints
(
UserUrlConstrainer
.
new
)
do
constraints
(
::
Constraints
::
UserUrlConstrainer
.
new
)
do
# Get all keys of user
get
':username.keys'
=>
'profiles/keys#get_keys'
,
constraints:
{
username:
Gitlab
::
PathRegex
.
root_namespace_route_regex
}
...
...
lib/constraints/group_url_constrainer.rb
View file @
5c7a7381
class
GroupUrlConstrainer
def
matches?
(
request
)
full_path
=
request
.
params
[
:group_id
]
||
request
.
params
[
:id
]
module
Constraints
class
GroupUrlConstrainer
def
matches?
(
request
)
full_path
=
request
.
params
[
:group_id
]
||
request
.
params
[
:id
]
return
false
unless
NamespacePathValidator
.
valid_path?
(
full_path
)
return
false
unless
NamespacePathValidator
.
valid_path?
(
full_path
)
Group
.
find_by_full_path
(
full_path
,
follow_redirects:
request
.
get?
).
present?
Group
.
find_by_full_path
(
full_path
,
follow_redirects:
request
.
get?
).
present?
end
end
end
lib/constraints/project_url_constrainer.rb
View file @
5c7a7381
class
ProjectUrlConstrainer
def
matches?
(
request
)
namespace_path
=
request
.
params
[
:namespace_id
]
project_path
=
request
.
params
[
:project_id
]
||
request
.
params
[
:id
]
full_path
=
[
namespace_path
,
project_path
].
join
(
'/'
)
module
Constraints
class
ProjectUrlConstrainer
def
matches?
(
request
)
namespace_path
=
request
.
params
[
:namespace_id
]
project_path
=
request
.
params
[
:project_id
]
||
request
.
params
[
:id
]
full_path
=
[
namespace_path
,
project_path
].
join
(
'/'
)
return
false
unless
ProjectPathValidator
.
valid_path?
(
full_path
)
return
false
unless
ProjectPathValidator
.
valid_path?
(
full_path
)
# We intentionally allow SELECT(*) here so result of this query can be used
# as cache for further Project.find_by_full_path calls within request
Project
.
find_by_full_path
(
full_path
,
follow_redirects:
request
.
get?
).
present?
# We intentionally allow SELECT(*) here so result of this query can be used
# as cache for further Project.find_by_full_path calls within request
Project
.
find_by_full_path
(
full_path
,
follow_redirects:
request
.
get?
).
present?
end
end
end
lib/constraints/user_url_constrainer.rb
View file @
5c7a7381
class
UserUrlConstrainer
def
matches?
(
request
)
full_path
=
request
.
params
[
:username
]
module
Constraints
class
UserUrlConstrainer
def
matches?
(
request
)
full_path
=
request
.
params
[
:username
]
return
false
unless
NamespacePathValidator
.
valid_path?
(
full_path
)
return
false
unless
NamespacePathValidator
.
valid_path?
(
full_path
)
User
.
find_by_full_path
(
full_path
,
follow_redirects:
request
.
get?
).
present?
User
.
find_by_full_path
(
full_path
,
follow_redirects:
request
.
get?
).
present?
end
end
end
lib/declarative_policy.rb
View file @
5c7a7381
require_dependency
'declarative_policy/cache'
require_dependency
'declarative_policy/condition'
require_dependency
'declarative_policy/dsl'
require_dependency
'declarative_policy/delegate_dsl'
require_dependency
'declarative_policy/policy_dsl'
require_dependency
'declarative_policy/rule_dsl'
require_dependency
'declarative_policy/preferred_scope'
require_dependency
'declarative_policy/rule'
require_dependency
'declarative_policy/runner'
...
...
lib/declarative_policy/delegate_dsl.rb
0 → 100644
View file @
5c7a7381
module
DeclarativePolicy
# Used when the name of a delegate is mentioned in
# the rule DSL.
class
DelegateDsl
def
initialize
(
rule_dsl
,
delegate_name
)
@rule_dsl
=
rule_dsl
@delegate_name
=
delegate_name
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
empty?
&&
!
block_given?
@rule_dsl
.
delegate
(
@delegate_name
,
m
)
end
end
end
lib/declarative_policy/dsl.rb
→
lib/declarative_policy/
policy_
dsl.rb
View file @
5c7a7381
module
DeclarativePolicy
# The DSL evaluation context inside rule { ... } blocks.
# Responsible for creating and combining Rule objects.
#
# See Base.rule
class
RuleDsl
def
initialize
(
context_class
)
@context_class
=
context_class
end
def
can?
(
ability
)
Rule
::
Ability
.
new
(
ability
)
end
def
all?
(
*
rules
)
Rule
::
And
.
make
(
rules
)
end
def
any?
(
*
rules
)
Rule
::
Or
.
make
(
rules
)
end
def
none?
(
*
rules
)
~
Rule
::
Or
.
new
(
rules
)
end
def
cond
(
condition
)
Rule
::
Condition
.
new
(
condition
)
end
def
delegate
(
delegate_name
,
condition
)
Rule
::
DelegatedCondition
.
new
(
delegate_name
,
condition
)
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
size
==
0
&&
!
block_given?
if
@context_class
.
delegations
.
key?
(
m
)
DelegateDsl
.
new
(
self
,
m
)
else
cond
(
m
.
to_sym
)
end
end
end
# Used when the name of a delegate is mentioned in
# the rule DSL.
class
DelegateDsl
def
initialize
(
rule_dsl
,
delegate_name
)
@rule_dsl
=
rule_dsl
@delegate_name
=
delegate_name
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
size
==
0
&&
!
block_given?
@rule_dsl
.
delegate
(
@delegate_name
,
m
)
end
end
# The return value of a rule { ... } declaration.
# Can call back to register rules with the containing
# Policy class (context_class here). See Base.rule
...
...
lib/declarative_policy/preferred_scope.rb
View file @
5c7a7381
module
DeclarativePolicy
module
DeclarativePolicy
# rubocop:disable Naming/FileName
PREFERRED_SCOPE_KEY
=
:"DeclarativePolicy.preferred_scope"
class
<<
self
...
...
lib/declarative_policy/rule_dsl.rb
0 → 100644
View file @
5c7a7381
module
DeclarativePolicy
# The DSL evaluation context inside rule { ... } blocks.
# Responsible for creating and combining Rule objects.
#
# See Base.rule
class
RuleDsl
def
initialize
(
context_class
)
@context_class
=
context_class
end
def
can?
(
ability
)
Rule
::
Ability
.
new
(
ability
)
end
def
all?
(
*
rules
)
Rule
::
And
.
make
(
rules
)
end
def
any?
(
*
rules
)
Rule
::
Or
.
make
(
rules
)
end
def
none?
(
*
rules
)
~
Rule
::
Or
.
new
(
rules
)
end
def
cond
(
condition
)
Rule
::
Condition
.
new
(
condition
)
end
def
delegate
(
delegate_name
,
condition
)
Rule
::
DelegatedCondition
.
new
(
delegate_name
,
condition
)
end
def
method_missing
(
m
,
*
a
,
&
b
)
return
super
unless
a
.
empty?
&&
!
block_given?
if
@context_class
.
delegations
.
key?
(
m
)
DelegateDsl
.
new
(
self
,
m
)
else
cond
(
m
.
to_sym
)
end
end
end
end
lib/gitlab/auth/result.rb
View file @
5c7a7381
module
Gitlab
module
Gitlab
# rubocop:disable Naming/FileName
module
Auth
Result
=
Struct
.
new
(
:actor
,
:project
,
:type
,
:authentication_abilities
)
do
def
ci?
(
for_project
)
...
...
lib/gitlab/ci/pipeline/chain/command.rb
View file @
5c7a7381
module
Gitlab
module
Gitlab
# rubocop:disable Naming/FileName
module
Ci
module
Pipeline
module
Chain
...
...
lib/gitlab/health_checks/metric.rb
View file @
5c7a7381
module
Gitlab::HealthChecks
module
Gitlab::HealthChecks
# rubocop:disable Naming/FileName
Metric
=
Struct
.
new
(
:name
,
:value
,
:labels
)
end
lib/gitlab/health_checks/result.rb
View file @
5c7a7381
module
Gitlab::HealthChecks
module
Gitlab::HealthChecks
# rubocop:disable Naming/FileName
Result
=
Struct
.
new
(
:success
,
:message
,
:labels
)
end
lib/gitlab/middleware/release_env.rb
View file @
5c7a7381
module
Gitlab
module
Gitlab
# rubocop:disable Naming/FileName
module
Middleware
# Some of middleware would hold env for no good reason even after the
# request had already been processed, and we could not garbage collect
...
...
lib/gitlab/slash_commands/result.rb
View file @
5c7a7381
module
Gitlab
module
Gitlab
# rubocop:disable Naming/FileName
module
SlashCommands
Result
=
Struct
.
new
(
:type
,
:message
)
end
...
...
lib/haml_lint/inline_javascript.rb
View file @
5c7a7381
unless
Rails
.
env
.
production?
unless
Rails
.
env
.
production?
# rubocop:disable Naming/FileName
require
'haml_lint/haml_visitor'
require
'haml_lint/linter'
require
'haml_lint/linter_registry'
...
...
qa/qa/page/project/settings/ci_cd.rb
View file @
5c7a7381
module
QA
module
QA
# rubocop:disable Naming/FileName
module
Page
module
Project
module
Settings
...
...
rubocop/rubocop.rb
View file @
5c7a7381
# rubocop:disable Naming/FileName
require_relative
'cop/gitlab/module_with_instance_variables'
require_relative
'cop/gitlab/predicate_memoization'
require_relative
'cop/include_sidekiq_worker'
...
...
spec/lib/constraints/group_url_constrainer_spec.rb
View file @
5c7a7381
require
'spec_helper'
describe
GroupUrlConstrainer
do
describe
Constraints
::
GroupUrlConstrainer
do
let!
(
:group
)
{
create
(
:group
,
path:
'gitlab'
)
}
describe
'#matches?'
do
...
...
spec/lib/constraints/project_url_constrainer_spec.rb
View file @
5c7a7381
require
'spec_helper'
describe
ProjectUrlConstrainer
do
describe
Constraints
::
ProjectUrlConstrainer
do
let!
(
:project
)
{
create
(
:project
)
}
let!
(
:namespace
)
{
project
.
namespace
}
...
...
spec/lib/constraints/user_url_constrainer_spec.rb
View file @
5c7a7381
require
'spec_helper'
describe
UserUrlConstrainer
do
describe
Constraints
::
UserUrlConstrainer
do
let!
(
:user
)
{
create
(
:user
,
username:
'dz'
)
}
describe
'#matches?'
do
...
...
spec/routing/routing_spec.rb
View file @
5c7a7381
...
...
@@ -9,7 +9,7 @@ require 'spec_helper'
# user_calendar_activities GET /u/:username/calendar_activities(.:format)
describe
UsersController
,
"routing"
do
it
"to #show"
do
allow_any_instance_of
(
UserUrlConstrainer
).
to
receive
(
:matches?
).
and_return
(
true
)
allow_any_instance_of
(
::
Constraints
::
UserUrlConstrainer
).
to
receive
(
:matches?
).
and_return
(
true
)
expect
(
get
(
"/User"
)).
to
route_to
(
'users#show'
,
username:
'User'
)
end
...
...
@@ -210,7 +210,7 @@ describe Profiles::KeysController, "routing" do
# get all the ssh-keys of a user
it
"to #get_keys"
do
allow_any_instance_of
(
UserUrlConstrainer
).
to
receive
(
:matches?
).
and_return
(
true
)
allow_any_instance_of
(
::
Constraints
::
UserUrlConstrainer
).
to
receive
(
:matches?
).
and_return
(
true
)
expect
(
get
(
"/foo.keys"
)).
to
route_to
(
'profiles/keys#get_keys'
,
username:
'foo'
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment