diff --git a/Gemfile b/Gemfile
index 1841665..d910056 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,8 @@
# frozen_string_literal: true
-source 'https://rubygems.org'
+source "https://rubygems.org"
gemspec
gem "simplecov", require: false
+gem "standard"
diff --git a/Gemfile.lock b/Gemfile.lock
index c61dba7..65fdbf6 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -22,6 +22,7 @@ GEM
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
+ ast (2.4.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
@@ -40,6 +41,8 @@ GEM
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.2)
+ language_server-protocol (3.17.0.4)
+ lint_roller (1.1.0)
logger (1.7.0)
minitest (5.25.5)
net-http (0.6.0)
@@ -47,8 +50,16 @@ GEM
octokit (9.2.0)
faraday (>= 1, < 3)
sawyer (~> 0.9)
+ parallel (1.26.3)
+ parser (3.3.7.4)
+ ast (~> 2.4.1)
+ racc
+ prism (1.4.0)
public_suffix (6.0.1)
+ racc (1.8.1)
+ rainbow (3.1.1)
rake (13.2.1)
+ regexp_parser (2.10.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
@@ -62,6 +73,25 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
+ rubocop (1.75.2)
+ json (~> 2.3)
+ language_server-protocol (~> 3.17.0.2)
+ lint_roller (~> 1.1.0)
+ parallel (~> 1.10)
+ parser (>= 3.3.0.2)
+ rainbow (>= 2.2.2, < 4.0)
+ regexp_parser (>= 2.9.3, < 3.0)
+ rubocop-ast (>= 1.44.0, < 2.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (>= 2.4.0, < 4.0)
+ rubocop-ast (1.44.0)
+ parser (>= 3.3.7.2)
+ prism (~> 1.4)
+ rubocop-performance (1.25.0)
+ lint_roller (~> 1.1)
+ rubocop (>= 1.75.0, < 2.0)
+ rubocop-ast (>= 1.38.0, < 2.0)
+ ruby-progressbar (1.13.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
@@ -72,8 +102,23 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
+ standard (1.49.0)
+ language_server-protocol (~> 3.17.0.2)
+ lint_roller (~> 1.0)
+ rubocop (~> 1.75.2)
+ standard-custom (~> 1.0.0)
+ standard-performance (~> 1.8)
+ standard-custom (1.0.2)
+ lint_roller (~> 1.0)
+ rubocop (~> 1.50)
+ standard-performance (1.8.0)
+ lint_roller (~> 1.1)
+ rubocop-performance (~> 1.25.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
+ unicode-display_width (3.1.4)
+ unicode-emoji (~> 4.0, >= 4.0.4)
+ unicode-emoji (4.0.4)
uri (1.0.3)
PLATFORMS
@@ -95,6 +140,7 @@ DEPENDENCIES
rake
rspec
simplecov
+ standard
BUNDLED WITH
2.6.7
diff --git a/errbit_github_plugin.gemspec b/errbit_github_plugin.gemspec
index 413739f..4c39511 100644
--- a/errbit_github_plugin.gemspec
+++ b/errbit_github_plugin.gemspec
@@ -1,29 +1,28 @@
# frozen_string_literal: true
-lib = File.expand_path('../lib', __FILE__)
+lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require 'errbit_github_plugin/version'
+require "errbit_github_plugin/version"
Gem::Specification.new do |spec|
- spec.name = 'errbit_github_plugin'
- spec.version = ErrbitGithubPlugin::VERSION
- spec.authors = ['Stephen Crosby']
- spec.email = ['stevecrozz@gmail.com']
+ spec.name = "errbit_github_plugin"
+ spec.version = ErrbitGithubPlugin::VERSION
+ spec.authors = ["Stephen Crosby"]
+ spec.email = ["stevecrozz@gmail.com"]
- spec.description = %q{GitHub integration for Errbit}
- spec.summary = %q{GitHub integration for Errbit}
- spec.homepage = 'https://github.com/errbit/errbit_github_plugin'
- spec.license = 'MIT'
+ spec.description = "GitHub integration for Errbit"
+ spec.summary = "GitHub integration for Errbit"
+ spec.homepage = "https://github.com/errbit/errbit_github_plugin"
+ spec.license = "MIT"
- spec.files = `git ls-files`.split($/)
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
- spec.require_paths = ['lib']
+ spec.files = `git ls-files`.split($/)
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
+ spec.require_paths = ["lib"]
- spec.add_dependency 'errbit_plugin'
- spec.add_dependency 'octokit'
+ spec.add_dependency "errbit_plugin"
+ spec.add_dependency "octokit"
- spec.add_development_dependency 'rspec'
- spec.add_development_dependency 'rake'
- spec.add_development_dependency 'activesupport'
+ spec.add_development_dependency "rspec"
+ spec.add_development_dependency "rake"
+ spec.add_development_dependency "activesupport"
end
diff --git a/lib/errbit_github_plugin.rb b/lib/errbit_github_plugin.rb
index 0ae96cb..0a17647 100644
--- a/lib/errbit_github_plugin.rb
+++ b/lib/errbit_github_plugin.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
require "errbit_github_plugin/version"
-require 'errbit_github_plugin/error'
-require 'errbit_github_plugin/issue_tracker'
+require "errbit_github_plugin/error"
+require "errbit_github_plugin/issue_tracker"
module ErrbitGithubPlugin
def self.root
- File.expand_path '../..', __FILE__
+ File.expand_path "../..", __FILE__
end
def self.read_static_file(file)
- File.read(File.join(self.root, 'static', file))
+ File.read(File.join(root, "static", file))
end
end
diff --git a/lib/errbit_github_plugin/issue_tracker.rb b/lib/errbit_github_plugin/issue_tracker.rb
index c514e84..e4c31c1 100644
--- a/lib/errbit_github_plugin/issue_tracker.rb
+++ b/lib/errbit_github_plugin/issue_tracker.rb
@@ -1,17 +1,16 @@
# frozen_string_literal: true
-require 'octokit'
+require "octokit"
module ErrbitGithubPlugin
class IssueTracker < ErrbitPlugin::IssueTracker
+ LABEL = "github"
- LABEL = 'github'
-
- NOTE = 'Please configure your github repository in the GITHUB ' \
- 'REPO field above.
Instead of providing your ' \
- 'username & password, you can link your Github account to your ' \
- 'user profile, and allow Errbit to create issues using your ' \
- 'OAuth token.'
+ NOTE = "Please configure your github repository in the GITHUB " \
+ "REPO field above.
Instead of providing your " \
+ "username & password, you can link your Github account to your " \
+ "user profile, and allow Errbit to create issues using your " \
+ "OAuth token."
FIELDS = {
username: {
@@ -37,13 +36,13 @@ def self.fields
def self.icons
@icons ||= {
create: [
- 'image/png', ErrbitGithubPlugin.read_static_file('github_create.png')
+ "image/png", ErrbitGithubPlugin.read_static_file("github_create.png")
],
goto: [
- 'image/png', ErrbitGithubPlugin.read_static_file('github_goto.png'),
+ "image/png", ErrbitGithubPlugin.read_static_file("github_goto.png")
],
inactive: [
- 'image/png', ErrbitGithubPlugin.read_static_file('github_inactive.png'),
+ "image/png", ErrbitGithubPlugin.read_static_file("github_inactive.png")
]
}
end
@@ -58,11 +57,11 @@ def url
def errors
errors = []
- if self.class.fields.detect {|f| options[f[0]].blank? }
- errors << [:base, 'You must specify your GitHub username and password']
+ if self.class.fields.detect { |f| options[f[0]].blank? }
+ errors << [:base, "You must specify your GitHub username and password"]
end
if repo.blank?
- errors << [:base, 'You must specify your GitHub repository url.']
+ errors << [:base, "You must specify your GitHub repository url."]
end
errors
end
@@ -72,12 +71,14 @@ def repo
end
def create_issue(title, body, user: {})
- if user['github_login'] && user['github_oauth_token']
- github_client = Octokit::Client.new(
- login: user['github_login'], access_token: user['github_oauth_token'])
+ github_client = if user["github_login"] && user["github_oauth_token"]
+ Octokit::Client.new(
+ login: user["github_login"], access_token: user["github_oauth_token"]
+ )
else
- github_client = Octokit::Client.new(
- login: options['username'], password: options['password'])
+ Octokit::Client.new(
+ login: options["username"], password: options["password"]
+ )
end
issue = github_client.create_issue(repo, title, body)
issue.html_url
@@ -86,12 +87,14 @@ def create_issue(title, body, user: {})
end
def close_issue(url, user: {})
- if user['github_login'] && user['github_oauth_token']
- github_client = Octokit::Client.new(
- login: user['github_login'], access_token: user['github_oauth_token'])
+ github_client = if user["github_login"] && user["github_oauth_token"]
+ Octokit::Client.new(
+ login: user["github_login"], access_token: user["github_oauth_token"]
+ )
else
- github_client = Octokit::Client.new(
- login: options['username'], password: options['password'])
+ Octokit::Client.new(
+ login: options["username"], password: options["password"]
+ )
end
# It would be better to get the number from issue.number when we create the issue,
# however, since we only have the url, get the number from it.
diff --git a/lib/errbit_github_plugin/version.rb b/lib/errbit_github_plugin/version.rb
index 6045bea..839f65d 100644
--- a/lib/errbit_github_plugin/version.rb
+++ b/lib/errbit_github_plugin/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
module ErrbitGithubPlugin
- VERSION = '0.4.0'
+ VERSION = "0.4.0"
end
diff --git a/spec/issue_tracker_spec.rb b/spec/issue_tracker_spec.rb
index 61fa658..deca783 100644
--- a/spec/issue_tracker_spec.rb
+++ b/spec/issue_tracker_spec.rb
@@ -1,155 +1,154 @@
# frozen_string_literal: true
describe ErrbitGithubPlugin::IssueTracker do
- describe '.label' do
- it 'return LABEL' do
+ describe ".label" do
+ it "return LABEL" do
expect(described_class.label).to eq described_class::LABEL
end
end
- describe '.note' do
- it 'return NOTE' do
+ describe ".note" do
+ it "return NOTE" do
expect(described_class.note).to eq described_class::NOTE
end
end
- describe '.fields' do
- it 'return FIELDS' do
+ describe ".fields" do
+ it "return FIELDS" do
expect(described_class.fields).to eq described_class::FIELDS
end
end
- describe '.icons' do
-
- it 'puts create icon onto the icons' do
- expect(described_class.icons[:create][0]).to eq 'image/png'
+ describe ".icons" do
+ it "puts create icon onto the icons" do
+ expect(described_class.icons[:create][0]).to eq "image/png"
expect(
described_class.icons[:create][1]
- ).to eq ErrbitGithubPlugin.read_static_file('github_create.png')
+ ).to eq ErrbitGithubPlugin.read_static_file("github_create.png")
end
- it 'puts goto icon onto the icons' do
- expect(described_class.icons[:goto][0]).to eq 'image/png'
+ it "puts goto icon onto the icons" do
+ expect(described_class.icons[:goto][0]).to eq "image/png"
expect(
described_class.icons[:goto][1]
- ).to eq ErrbitGithubPlugin.read_static_file('github_goto.png')
+ ).to eq ErrbitGithubPlugin.read_static_file("github_goto.png")
end
- it 'puts inactive icon onto the icons' do
- expect(described_class.icons[:inactive][0]).to eq 'image/png'
+ it "puts inactive icon onto the icons" do
+ expect(described_class.icons[:inactive][0]).to eq "image/png"
expect(
described_class.icons[:inactive][1]
- ).to eq ErrbitGithubPlugin.read_static_file('github_inactive.png')
+ ).to eq ErrbitGithubPlugin.read_static_file("github_inactive.png")
end
end
let(:tracker) { described_class.new(options) }
- describe '#configured?' do
- context 'with errors' do
- let(:options) { { invalid_key: '' } }
- it 'return false' do
+ describe "#configured?" do
+ context "with errors" do
+ let(:options) { {invalid_key: ""} }
+ it "return false" do
expect(tracker.configured?).to eq false
end
end
- context 'without errors' do
+ context "without errors" do
let(:options) do
- { username: 'foo', password: 'bar', github_repo: 'user/repos' }
+ {username: "foo", password: "bar", github_repo: "user/repos"}
end
- it 'return true' do
+ it "return true" do
expect(tracker.configured?).to eq true
end
end
end
- describe '#url' do
- let(:options) { { github_repo: 'repo' } }
- it 'returns issues url' do
- expect(tracker.url).to eq 'https://github.com/repo/issues'
+ describe "#url" do
+ let(:options) { {github_repo: "repo"} }
+ it "returns issues url" do
+ expect(tracker.url).to eq "https://github.com/repo/issues"
end
end
- describe '#errors' do
+ describe "#errors" do
subject { tracker.errors }
- context 'without username' do
- let(:options) { { username: '', password: 'bar', github_repo: 'repo' } }
+ context "without username" do
+ let(:options) { {username: "", password: "bar", github_repo: "repo"} }
it { is_expected.not_to be_empty }
end
- context 'without password' do
+ context "without password" do
let(:options) do
- { username: '', password: 'bar', github_repo: 'repo' }
+ {username: "", password: "bar", github_repo: "repo"}
end
it { is_expected.not_to be_empty }
end
- context 'without github_repo' do
+ context "without github_repo" do
let(:options) do
- { username: 'foo', password: 'bar', github_repo: '' }
+ {username: "foo", password: "bar", github_repo: ""}
end
it { is_expected.not_to be_empty }
end
- context 'with completed options' do
+ context "with completed options" do
let(:options) do
- { username: 'foo', password: 'bar', github_repo: 'repo' }
+ {username: "foo", password: "bar", github_repo: "repo"}
end
it { is_expected.to be_empty }
end
end
- describe '#repo' do
- let(:options) { { github_repo: 'baz' } }
- it 'returns github repo' do
- expect(tracker.repo).to eq 'baz'
+ describe "#repo" do
+ let(:options) { {github_repo: "baz"} }
+ it "returns github repo" do
+ expect(tracker.repo).to eq "baz"
end
end
- describe '#create_issue' do
- subject { tracker.create_issue('title', 'body', user: user) }
+ describe "#create_issue" do
+ subject { tracker.create_issue("title", "body", user: user) }
let(:options) do
- { username: 'foo', password: 'bar', github_repo: 'user/repos' }
+ {username: "foo", password: "bar", github_repo: "user/repos"}
end
let(:fake_github_client) do
- double('Fake GitHub Client').tap do |github_client|
+ double("Fake GitHub Client").tap do |github_client|
github_client.stub(:create_issue).and_return(fake_issue)
end
end
let(:fake_issue) do
- double('Fake Issue').tap do |issue|
- issue.stub(:html_url).and_return('http://github.com/user/repos/issues/878')
+ double("Fake Issue").tap do |issue|
+ issue.stub(:html_url).and_return("http://github.com/user/repos/issues/878")
end
end
- context 'signed in with token' do
+ context "signed in with token" do
let(:user) do
{
- 'github_login' => 'bob',
- 'github_oauth_token' => 'valid_token'
+ "github_login" => "bob",
+ "github_oauth_token" => "valid_token"
}
end
- it 'return issue url' do
+ it "return issue url" do
Octokit::Client.stub(:new).with(
- login: user['github_login'], access_token: user['github_oauth_token']
+ login: user["github_login"], access_token: user["github_oauth_token"]
).and_return(fake_github_client)
expect(subject).to eq fake_issue.html_url
end
end
- context 'signed in with password' do
+ context "signed in with password" do
let(:user) { {} }
- it 'return issue url' do
- (Octokit::Client).stub(:new).with(
- login: options['username'], password: options['password']
+ it "return issue url" do
+ Octokit::Client.stub(:new).with(
+ login: options["username"], password: options["password"]
).and_return(fake_github_client)
expect(subject).to eq fake_issue.html_url
end
end
- context 'when unauthentication error' do
+ context "when unauthentication error" do
let(:user) do
- { 'github_login' => 'alice', 'github_oauth_token' => 'invalid_token' }
+ {"github_login" => "alice", "github_oauth_token" => "invalid_token"}
end
- it 'raise AuthenticationError' do
- (Octokit::Client).stub(:new).with(
- login: user['github_login'], access_token: user['github_oauth_token']
+ it "raise AuthenticationError" do
+ Octokit::Client.stub(:new).with(
+ login: user["github_login"], access_token: user["github_oauth_token"]
).and_raise(Octokit::Unauthorized)
expect { subject }.to raise_error
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 5daef9a..8bd2cca 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'simplecov'
+require "simplecov"
SimpleCov.start
-require 'errbit_plugin'
-require 'errbit_github_plugin'
-require 'active_support/all'
+require "errbit_plugin"
+require "errbit_github_plugin"
+require "active_support/all"
RSpec.configure do |config|
config.run_all_when_everything_filtered = true
@@ -16,5 +16,5 @@
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
- config.order = 'random'
+ config.order = "random"
end