diff options
author | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
commit | 62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch) | |
tree | c3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /lib/bitbucket | |
parent | f6453eca992a9c142268e78ac782cef98110d183 (diff) | |
download | gitlab-ce-tc-standard-gem.tar.gz |
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I
decided to try https://github.com/testdouble/standard on our codebase.
It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'lib/bitbucket')
-rw-r--r-- | lib/bitbucket/client.rb | 2 | ||||
-rw-r--r-- | lib/bitbucket/collection.rb | 4 | ||||
-rw-r--r-- | lib/bitbucket/connection.rb | 6 | ||||
-rw-r--r-- | lib/bitbucket/page.rb | 6 | ||||
-rw-r--r-- | lib/bitbucket/representation/comment.rb | 10 | ||||
-rw-r--r-- | lib/bitbucket/representation/issue.rb | 22 | ||||
-rw-r--r-- | lib/bitbucket/representation/pull_request.rb | 34 | ||||
-rw-r--r-- | lib/bitbucket/representation/pull_request_comment.rb | 16 | ||||
-rw-r--r-- | lib/bitbucket/representation/repo.rb | 18 | ||||
-rw-r--r-- | lib/bitbucket/representation/user.rb | 2 |
10 files changed, 60 insertions, 60 deletions
diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb index 1343f424c51..4b928a7d32d 100644 --- a/lib/bitbucket/client.rb +++ b/lib/bitbucket/client.rb @@ -45,7 +45,7 @@ module Bitbucket def user @user ||= begin - parsed_response = connection.get('/user') + parsed_response = connection.get("/user") Representation::User.new(parsed_response) end end diff --git a/lib/bitbucket/collection.rb b/lib/bitbucket/collection.rb index 9c496daccaa..4e64a3f4616 100644 --- a/lib/bitbucket/collection.rb +++ b/lib/bitbucket/collection.rb @@ -13,9 +13,9 @@ module Bitbucket end def method_missing(method, *args) - return super unless self.respond_to?(method) + return super unless respond_to?(method) - self.__send__(method, *args) do |item| # rubocop:disable GitlabSecurity/PublicSend + __send__(method, *args) do |item| # rubocop:disable GitlabSecurity/PublicSend block_given? ? yield(item) : item end end diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb index 0041634f9e3..dd7f4e579f6 100644 --- a/lib/bitbucket/connection.rb +++ b/lib/bitbucket/connection.rb @@ -2,8 +2,8 @@ module Bitbucket class Connection - DEFAULT_API_VERSION = '2.0'.freeze - DEFAULT_BASE_URI = 'https://api.bitbucket.org/'.freeze + DEFAULT_API_VERSION = "2.0" + DEFAULT_BASE_URI = "https://api.bitbucket.org/" DEFAULT_QUERY = {}.freeze attr_reader :expires_at, :expires_in, :refresh_token, :token @@ -59,7 +59,7 @@ module Bitbucket end def provider - Gitlab::Auth::OAuth::Provider.config_for('bitbucket') + Gitlab::Auth::OAuth::Provider.config_for("bitbucket") end def options diff --git a/lib/bitbucket/page.rb b/lib/bitbucket/page.rb index 7cc1342ad65..42bc81fc8d2 100644 --- a/lib/bitbucket/page.rb +++ b/lib/bitbucket/page.rb @@ -20,13 +20,13 @@ module Bitbucket private def parse_attrs(raw) - raw.slice(*%w(size page pagelen next previous)).symbolize_keys + raw.slice("size", "page", "pagelen", "next", "previous").symbolize_keys end def parse_values(raw, bitbucket_rep_class) - return [] unless raw['values'] && raw['values'].is_a?(Array) + return [] unless raw["values"]&.is_a?(Array) - bitbucket_rep_class.decorate(raw['values']) + bitbucket_rep_class.decorate(raw["values"]) end def representation_class(type) diff --git a/lib/bitbucket/representation/comment.rb b/lib/bitbucket/representation/comment.rb index 1b8dc27793a..9c1848738ba 100644 --- a/lib/bitbucket/representation/comment.rb +++ b/lib/bitbucket/representation/comment.rb @@ -4,25 +4,25 @@ module Bitbucket module Representation class Comment < Representation::Base def author - user['username'] + user["username"] end def note - raw.fetch('content', {}).fetch('raw', nil) + raw.fetch("content", {}).fetch("raw", nil) end def created_at - raw['created_on'] + raw["created_on"] end def updated_at - raw['updated_on'] || raw['created_on'] + raw["updated_on"] || raw["created_on"] end private def user - raw.fetch('user', {}) + raw.fetch("user", {}) end end end diff --git a/lib/bitbucket/representation/issue.rb b/lib/bitbucket/representation/issue.rb index a88797cdab9..7c7a586f3bf 100644 --- a/lib/bitbucket/representation/issue.rb +++ b/lib/bitbucket/representation/issue.rb @@ -3,42 +3,42 @@ module Bitbucket module Representation class Issue < Representation::Base - CLOSED_STATUS = %w(resolved invalid duplicate wontfix closed).freeze + CLOSED_STATUS = %w[resolved invalid duplicate wontfix closed].freeze def iid - raw['id'] + raw["id"] end def kind - raw['kind'] + raw["kind"] end def author - raw.dig('reporter', 'username') + raw.dig("reporter", "username") end def description - raw.fetch('content', {}).fetch('raw', nil) + raw.fetch("content", {}).fetch("raw", nil) end def state - closed? ? 'closed' : 'opened' + closed? ? "closed" : "opened" end def title - raw['title'] + raw["title"] end def milestone - raw['milestone']['name'] if raw['milestone'].present? + raw["milestone"]["name"] if raw["milestone"].present? end def created_at - raw['created_on'] + raw["created_on"] end def updated_at - raw['edited_on'] + raw["edited_on"] end def to_s @@ -48,7 +48,7 @@ module Bitbucket private def closed? - CLOSED_STATUS.include?(raw['state']) + CLOSED_STATUS.include?(raw["state"]) end end end diff --git a/lib/bitbucket/representation/pull_request.rb b/lib/bitbucket/representation/pull_request.rb index 6a0e8b354bf..ecb8746da8d 100644 --- a/lib/bitbucket/representation/pull_request.rb +++ b/lib/bitbucket/representation/pull_request.rb @@ -4,63 +4,63 @@ module Bitbucket module Representation class PullRequest < Representation::Base def author - raw.fetch('author', {}).fetch('username', nil) + raw.fetch("author", {}).fetch("username", nil) end def description - raw['description'] + raw["description"] end def iid - raw['id'] + raw["id"] end def state - if raw['state'] == 'MERGED' - 'merged' - elsif raw['state'] == 'DECLINED' - 'closed' + if raw["state"] == "MERGED" + "merged" + elsif raw["state"] == "DECLINED" + "closed" else - 'opened' + "opened" end end def created_at - raw['created_on'] + raw["created_on"] end def updated_at - raw['updated_on'] + raw["updated_on"] end def title - raw['title'] + raw["title"] end def source_branch_name - source_branch.fetch('branch', {}).fetch('name', nil) + source_branch.fetch("branch", {}).fetch("name", nil) end def source_branch_sha - source_branch.fetch('commit', {}).fetch('hash', nil) + source_branch.fetch("commit", {}).fetch("hash", nil) end def target_branch_name - target_branch.fetch('branch', {}).fetch('name', nil) + target_branch.fetch("branch", {}).fetch("name", nil) end def target_branch_sha - target_branch.fetch('commit', {}).fetch('hash', nil) + target_branch.fetch("commit", {}).fetch("hash", nil) end private def source_branch - raw['source'] + raw["source"] end def target_branch - raw['destination'] + raw["destination"] end end end diff --git a/lib/bitbucket/representation/pull_request_comment.rb b/lib/bitbucket/representation/pull_request_comment.rb index 34dbf9ad22d..7eb8ef6803f 100644 --- a/lib/bitbucket/representation/pull_request_comment.rb +++ b/lib/bitbucket/representation/pull_request_comment.rb @@ -4,37 +4,37 @@ module Bitbucket module Representation class PullRequestComment < Comment def iid - raw['id'] + raw["id"] end def file_path - inline.fetch('path') + inline.fetch("path") end def old_pos - inline.fetch('from') + inline.fetch("from") end def new_pos - inline.fetch('to') + inline.fetch("to") end def parent_id - raw.fetch('parent', {}).fetch('id', nil) + raw.fetch("parent", {}).fetch("id", nil) end def inline? - raw.key?('inline') + raw.key?("inline") end def has_parent? - raw.key?('parent') + raw.key?("parent") end private def inline - raw.fetch('inline', {}) + raw.fetch("inline", {}) end end end diff --git a/lib/bitbucket/representation/repo.rb b/lib/bitbucket/representation/repo.rb index c5bfc91e43d..78dcca4883d 100644 --- a/lib/bitbucket/representation/repo.rb +++ b/lib/bitbucket/representation/repo.rb @@ -10,7 +10,7 @@ module Bitbucket end def owner_and_slug - @owner_and_slug ||= full_name.split('/', 2) + @owner_and_slug ||= full_name.split("/", 2) end def owner @@ -22,7 +22,7 @@ module Bitbucket end def clone_url(token = nil) - url = raw['links']['clone'].find { |link| link['name'] == 'https' }.fetch('href') + url = raw["links"]["clone"].find { |link| link["name"] == "https" }.fetch("href") if token.present? clone_url = URI.parse(url) @@ -34,31 +34,31 @@ module Bitbucket end def description - raw['description'] + raw["description"] end def full_name - raw['full_name'] + raw["full_name"] end def issues_enabled? - raw['has_issues'] + raw["has_issues"] end def name - raw['name'] + raw["name"] end def valid? - raw['scm'] == 'git' + raw["scm"] == "git" end def has_wiki? - raw['has_wiki'] + raw["has_wiki"] end def visibility_level - if raw['is_private'] + if raw["is_private"] Gitlab::VisibilityLevel::PRIVATE else Gitlab::VisibilityLevel::PUBLIC diff --git a/lib/bitbucket/representation/user.rb b/lib/bitbucket/representation/user.rb index 2b45d751e70..23d7008de92 100644 --- a/lib/bitbucket/representation/user.rb +++ b/lib/bitbucket/representation/user.rb @@ -4,7 +4,7 @@ module Bitbucket module Representation class User < Representation::Base def username - raw['username'] + raw["username"] end end end |