danger-go 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +137 -0
- data/Guardfile +19 -0
- data/LICENSE +21 -0
- data/README.md +97 -0
- data/Rakefile +23 -0
- data/danger-go.gemspec +49 -0
- data/docs/images/gopher.png +0 -0
- data/lib/danger_golint.rb +1 -0
- data/lib/danger_plugin.rb +1 -0
- data/lib/golint/gem_version.rb +3 -0
- data/lib/golint/plugin.rb +98 -0
- data/spec/golint_spec.rb +69 -0
- data/spec/spec_helper.rb +59 -0
- metadata +201 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 922a2aadc91e2b58508bf4cc19482dac1c51dec7
|
4
|
+
data.tar.gz: 9c723007bec4dfc3621fea94c9a04b3087c49895
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 02ed62b8ea45a738eba78089563461d79f1e7d24e53bcc117c3eaf8226db699569091df22b7287fe9d93ba00ad30aa92ce7aeef7f2d1ea163ceb5247bb7d3fb5
|
7
|
+
data.tar.gz: 5fbb98e324a123123b384e8ef447697051c0f04174ce4717bae793c852f4450e1f900a903939893de62926171cba51b663d9be78b1a1b5949b27890d7502833a
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
danger-go (0.0.1)
|
5
|
+
danger-plugin-api (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.5.2)
|
11
|
+
public_suffix (>= 2.0.2, < 4.0)
|
12
|
+
ast (2.3.0)
|
13
|
+
claide (1.0.2)
|
14
|
+
claide-plugins (0.9.2)
|
15
|
+
cork
|
16
|
+
nap
|
17
|
+
open4 (~> 1.3)
|
18
|
+
coderay (1.1.1)
|
19
|
+
colored2 (3.1.2)
|
20
|
+
cork (0.3.0)
|
21
|
+
colored2 (~> 3.1)
|
22
|
+
danger (5.5.5)
|
23
|
+
claide (~> 1.0)
|
24
|
+
claide-plugins (>= 0.9.2)
|
25
|
+
colored2 (~> 3.1)
|
26
|
+
cork (~> 0.1)
|
27
|
+
faraday (~> 0.9)
|
28
|
+
faraday-http-cache (~> 1.0)
|
29
|
+
git (~> 1)
|
30
|
+
kramdown (~> 1.5)
|
31
|
+
no_proxy_fix
|
32
|
+
octokit (~> 4.7)
|
33
|
+
terminal-table (~> 1)
|
34
|
+
danger-plugin-api (1.0.0)
|
35
|
+
danger (> 2.0)
|
36
|
+
diff-lcs (1.2.5)
|
37
|
+
faraday (0.13.1)
|
38
|
+
multipart-post (>= 1.2, < 3)
|
39
|
+
faraday-http-cache (1.3.1)
|
40
|
+
faraday (~> 0.8)
|
41
|
+
ffi (>= 1.9.24)
|
42
|
+
formatador (0.2.5)
|
43
|
+
git (1.3.0)
|
44
|
+
guard (2.14.0)
|
45
|
+
formatador (>= 0.2.4)
|
46
|
+
listen (>= 2.7, < 4.0)
|
47
|
+
lumberjack (~> 1.0)
|
48
|
+
nenv (~> 0.1)
|
49
|
+
notiffany (~> 0.0)
|
50
|
+
pry (>= 0.9.12)
|
51
|
+
shellany (~> 0.0)
|
52
|
+
thor (>= 0.18.1)
|
53
|
+
guard-compat (1.2.1)
|
54
|
+
guard-rspec (4.7.3)
|
55
|
+
guard (~> 2.1)
|
56
|
+
guard-compat (~> 1.1)
|
57
|
+
rspec (>= 2.99.0, < 4.0)
|
58
|
+
kramdown (1.16.2)
|
59
|
+
listen (3.0.7)
|
60
|
+
rb-fsevent (>= 0.9.3)
|
61
|
+
rb-inotify (>= 0.9.7)
|
62
|
+
lumberjack (1.0.10)
|
63
|
+
method_source (0.8.2)
|
64
|
+
multipart-post (2.0.0)
|
65
|
+
nap (1.1.0)
|
66
|
+
nenv (0.3.0)
|
67
|
+
no_proxy_fix (0.1.2)
|
68
|
+
notiffany (0.1.1)
|
69
|
+
nenv (~> 0.1)
|
70
|
+
shellany (~> 0.0)
|
71
|
+
octokit (4.8.0)
|
72
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
73
|
+
open4 (1.3.4)
|
74
|
+
parallel (1.12.1)
|
75
|
+
parser (2.4.0.2)
|
76
|
+
ast (~> 2.3)
|
77
|
+
powerpack (0.1.1)
|
78
|
+
pry (0.10.4)
|
79
|
+
coderay (~> 1.1.0)
|
80
|
+
method_source (~> 0.8.1)
|
81
|
+
slop (~> 3.4)
|
82
|
+
public_suffix (2.0.5)
|
83
|
+
rainbow (2.2.2)
|
84
|
+
rake
|
85
|
+
rake (10.5.0)
|
86
|
+
rb-fsevent (0.9.8)
|
87
|
+
rb-inotify (0.9.7)
|
88
|
+
ffi (>= 1.9.24)
|
89
|
+
rspec (3.5.0)
|
90
|
+
rspec-core (~> 3.5.0)
|
91
|
+
rspec-expectations (~> 3.5.0)
|
92
|
+
rspec-mocks (~> 3.5.0)
|
93
|
+
rspec-core (3.5.4)
|
94
|
+
rspec-support (~> 3.5.0)
|
95
|
+
rspec-expectations (3.5.0)
|
96
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
97
|
+
rspec-support (~> 3.5.0)
|
98
|
+
rspec-mocks (3.5.0)
|
99
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
100
|
+
rspec-support (~> 3.5.0)
|
101
|
+
rspec-support (3.5.0)
|
102
|
+
rubocop (0.49.1)
|
103
|
+
parallel (~> 1.10)
|
104
|
+
parser (>= 2.3.3.1, < 3.0)
|
105
|
+
powerpack (~> 0.1)
|
106
|
+
rainbow (>= 1.99.1, < 3.0)
|
107
|
+
ruby-progressbar (~> 1.7)
|
108
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
109
|
+
ruby-progressbar (1.9.0)
|
110
|
+
sawyer (0.8.1)
|
111
|
+
addressable (>= 2.3.5, < 2.6)
|
112
|
+
faraday (~> 0.8, < 1.0)
|
113
|
+
shellany (0.0.1)
|
114
|
+
slop (3.6.0)
|
115
|
+
terminal-table (1.8.0)
|
116
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
117
|
+
thor (0.19.1)
|
118
|
+
unicode-display_width (1.1.1)
|
119
|
+
yard (0.9.12)
|
120
|
+
|
121
|
+
PLATFORMS
|
122
|
+
ruby
|
123
|
+
|
124
|
+
DEPENDENCIES
|
125
|
+
bundler (~> 1.3)
|
126
|
+
danger-go!
|
127
|
+
guard (~> 2.14)
|
128
|
+
guard-rspec (~> 4.7)
|
129
|
+
listen (= 3.0.7)
|
130
|
+
pry
|
131
|
+
rake (~> 10.0)
|
132
|
+
rspec (~> 3.4)
|
133
|
+
rubocop (~> 0.49.0)
|
134
|
+
yard (~> 0.9.11)
|
135
|
+
|
136
|
+
BUNDLED WITH
|
137
|
+
2.0.1
|
data/Guardfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# A guardfile for making Danger Plugins
|
2
|
+
# For more info see https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
# To run, use `bundle exec guard`.
|
5
|
+
|
6
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
7
|
+
require 'guard/rspec/dsl'
|
8
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
9
|
+
|
10
|
+
# RSpec files
|
11
|
+
rspec = dsl.rspec
|
12
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
13
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
14
|
+
watch(rspec.spec_files)
|
15
|
+
|
16
|
+
# Ruby files
|
17
|
+
ruby = dsl.ruby
|
18
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
19
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 PIGNOSE
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
<h1 align="center">danger-go</h1>
|
2
|
+
<p align="center">
|
3
|
+
<a href="https://github.com/KennethanCeyer/danger-go/blob/master/LICENSE" target="_blank"><img src="http://img.shields.io/badge/license-MIT-green.svg?style=flat" alt="License"></a>
|
4
|
+
<a href="http://rubygems.org/gems/danger-go" target="_blank"><img src="https://img.shields.io/gem/v/danger-go.svg?style=flat" alt="License"></a>
|
5
|
+
</p>
|
6
|
+
<p align="center">A Dangerfile for golang developer (golint)</p>
|
7
|
+
<p align="center"><img src="./docs/images/gopher.png"></p>
|
8
|
+
|
9
|
+
## Getting Started
|
10
|
+
|
11
|
+
### Installation
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ gem install danger-go
|
15
|
+
```
|
16
|
+
|
17
|
+
### Requirements
|
18
|
+
|
19
|
+
Make sure your system has follows requirements
|
20
|
+
|
21
|
+
- go
|
22
|
+
- golint
|
23
|
+
|
24
|
+
**golint**
|
25
|
+
|
26
|
+
This project uses `golint` as default lint toolchain,
|
27
|
+
The code will try to install when your system does not have golint tool,
|
28
|
+
However, If you want to ensure to install golint,
|
29
|
+
Use follows line.
|
30
|
+
|
31
|
+
```bash
|
32
|
+
$ go get golang.org/x/lint/golint
|
33
|
+
```
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
### Basic
|
38
|
+
|
39
|
+
Put follows line into your `Dangerfile`.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
golint.lint
|
43
|
+
```
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
### Install
|
48
|
+
|
49
|
+
**Clone this repo**
|
50
|
+
|
51
|
+
```bash
|
52
|
+
$ git clone https://github.com/KennethanCeyer/danger-go.git
|
53
|
+
```
|
54
|
+
|
55
|
+
**Run bundler to download dependencies**
|
56
|
+
|
57
|
+
```bash
|
58
|
+
$ bundle install
|
59
|
+
```
|
60
|
+
|
61
|
+
**Run rake spec to test**
|
62
|
+
|
63
|
+
```bash
|
64
|
+
$ bundle exec rake spec
|
65
|
+
```
|
66
|
+
|
67
|
+
**Use guard to automatically have tests run as you make changes**
|
68
|
+
|
69
|
+
```bash
|
70
|
+
$ bundle exec guard
|
71
|
+
```
|
72
|
+
|
73
|
+
## License
|
74
|
+
|
75
|
+
This project is under MIT License
|
76
|
+
|
77
|
+
MIT License
|
78
|
+
|
79
|
+
Copyright (c) 2019 PIGNOSE
|
80
|
+
|
81
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
82
|
+
of this software and associated documentation files (the "Software"), to deal
|
83
|
+
in the Software without restriction, including without limitation the rights
|
84
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
85
|
+
copies of the Software, and to permit persons to whom the Software is
|
86
|
+
furnished to do so, subject to the following conditions:
|
87
|
+
|
88
|
+
The above copyright notice and this permission notice shall be included in all
|
89
|
+
copies or substantial portions of the Software.
|
90
|
+
|
91
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
92
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
93
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
94
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
95
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
96
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
97
|
+
SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'rubocop/rake_task'
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:specs)
|
6
|
+
|
7
|
+
task default: :specs
|
8
|
+
|
9
|
+
task :spec do
|
10
|
+
Rake::Task['specs'].invoke
|
11
|
+
Rake::Task['rubocop'].invoke
|
12
|
+
Rake::Task['spec_docs'].invoke
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run RuboCop on the lib/specs directory'
|
16
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
17
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
21
|
+
task :spec_docs do
|
22
|
+
sh 'bundle exec danger plugins lint'
|
23
|
+
end
|
data/danger-go.gemspec
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'golint/gem_version.rb'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'danger-go'
|
8
|
+
spec.version = Golint::VERSION
|
9
|
+
spec.authors = ['KennethanCeyer']
|
10
|
+
spec.email = ['kenneth@pigno.se']
|
11
|
+
spec.description = %q{A Dangerfile for golang developer}
|
12
|
+
spec.summary = %q{danger-go support toolkit for golang user}
|
13
|
+
spec.homepage = 'https://github.com/KennethanCeyer/danger-go'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
22
|
+
|
23
|
+
# General ruby development
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
|
27
|
+
# Testing support
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
29
|
+
|
30
|
+
# Linting code and docs
|
31
|
+
spec.add_development_dependency "rubocop", "~> 0.49.0"
|
32
|
+
spec.add_development_dependency "yard", "~> 0.9.11"
|
33
|
+
|
34
|
+
# Makes testing easy via `bundle exec guard`
|
35
|
+
spec.add_development_dependency 'guard', '~> 2.14'
|
36
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
37
|
+
|
38
|
+
# If you want to work on older builds of ruby
|
39
|
+
spec.add_development_dependency 'listen', '3.0.7'
|
40
|
+
|
41
|
+
# This gives you the chance to run a REPL inside your tests
|
42
|
+
# via:
|
43
|
+
#
|
44
|
+
# require 'pry'
|
45
|
+
# binding.pry
|
46
|
+
#
|
47
|
+
# This will stop test execution and let you inspect the results
|
48
|
+
spec.add_development_dependency 'pry'
|
49
|
+
end
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'golint/gem_version'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'golint/plugin'
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Danger
|
5
|
+
# Lint javascript files using [golint](http://golint.org/).
|
6
|
+
# Results are send as inline commen.
|
7
|
+
#
|
8
|
+
# @example Run golint with changed files only
|
9
|
+
#
|
10
|
+
# golint.filtering = true
|
11
|
+
# golint.lint
|
12
|
+
#
|
13
|
+
# @see leonhartX/danger-golint
|
14
|
+
# @tags lint, golang, golint
|
15
|
+
class DangerGolint < Plugin
|
16
|
+
# Root directory from where golint will run.
|
17
|
+
# Defaults to current directory.
|
18
|
+
# @return [String]
|
19
|
+
attr_writer :base_dir
|
20
|
+
|
21
|
+
MARKDOWN_TEMPLATE = ""\
|
22
|
+
"## DangerGo found issues\n\n"\
|
23
|
+
"| File | Line | Column | Reason |\n"\
|
24
|
+
"|------|------|--------|--------|\n"\
|
25
|
+
|
26
|
+
def base_dir
|
27
|
+
@base_dir || "."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Lints go files.
|
31
|
+
# Generates `errors` and `warnings` due to golint's config.
|
32
|
+
# Will try to send inline comment if supported(Github)
|
33
|
+
#
|
34
|
+
# @return [void]
|
35
|
+
#
|
36
|
+
def lint
|
37
|
+
errors = lint_results.reject { |r| r.nil? }
|
38
|
+
|
39
|
+
return if errors.empty?
|
40
|
+
|
41
|
+
print_markdown_table(errors)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
# Check existing status golint toolchain
|
47
|
+
# #
|
48
|
+
# @return [bool]
|
49
|
+
def golint_installed?
|
50
|
+
`which golint`.strip.empty? == false
|
51
|
+
end
|
52
|
+
|
53
|
+
# Get lint result regards the filtering option
|
54
|
+
#
|
55
|
+
# return [Hash]
|
56
|
+
def lint_results
|
57
|
+
bin = 'golint'
|
58
|
+
system 'go get -u golang.org/x/lint/golint' unless golint_installed?
|
59
|
+
return run_lint(bin, base_dir)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Run golint aginst a single dir.
|
63
|
+
#
|
64
|
+
# @param [String] bin
|
65
|
+
# The binary path of golint
|
66
|
+
#
|
67
|
+
# @param [String] dir
|
68
|
+
# Dir to be linted
|
69
|
+
#
|
70
|
+
# @return [Output]
|
71
|
+
def run_lint(bin, dir)
|
72
|
+
command = "#{bin}"
|
73
|
+
`#{command} #{dir}`.split('\n')
|
74
|
+
end
|
75
|
+
|
76
|
+
# Print markdown string
|
77
|
+
#
|
78
|
+
# @param [List<string>] errors
|
79
|
+
#
|
80
|
+
# @return [string]
|
81
|
+
def print_markdown_table(errors=[])
|
82
|
+
report = errors.inject(MARKDOWN_TEMPLATE) do |out, error_line|
|
83
|
+
file, line, column, reason = error_line.split(":")
|
84
|
+
out += "| #{short_link(file, line)} | #{line} | #{column} | #{reason.strip.gsub("'", "`")} |\n"
|
85
|
+
end
|
86
|
+
|
87
|
+
markdown(report)
|
88
|
+
end
|
89
|
+
|
90
|
+
def short_link(file, line)
|
91
|
+
if danger.scm_provider.to_s == "github"
|
92
|
+
return github.html_link("#{file}#L#{line}", full_path: false)
|
93
|
+
end
|
94
|
+
|
95
|
+
file
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/spec/golint_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
describe Danger::DangerGolint do
|
5
|
+
it 'should be a plugin' do
|
6
|
+
expect(Danger::DangerGolint.new(nil)).to be_a Danger::Plugin
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# You should test your custom attributes and methods here
|
11
|
+
#
|
12
|
+
describe 'with Dangerfile' do
|
13
|
+
before do
|
14
|
+
@dangerfile = testing_dangerfile
|
15
|
+
@golint = @dangerfile.golint
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'golint not installed' do
|
19
|
+
before do
|
20
|
+
allow(@golint).to receive(:`).with("which golint").and_return("")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'golint installed' do
|
25
|
+
before do
|
26
|
+
allow(@golint).to receive(:`).with("which golint").and_return("/usr/bin/golint")
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'lint' do
|
30
|
+
it 'runs lint from current directory by default' do
|
31
|
+
expect(@golint).to receive(:`).with("golint .").and_return("")
|
32
|
+
@golint.lint
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'runs lint from a custom directory' do
|
36
|
+
expect(@golint).to receive(:`).with("golint my/custom/directory").and_return("")
|
37
|
+
|
38
|
+
@golint.base_dir = "my/custom/directory"
|
39
|
+
@golint.lint
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'handles a lint with no errors' do
|
43
|
+
allow(@golint).to receive(:`).with("golint .").and_return("")
|
44
|
+
@golint.lint
|
45
|
+
expect(@golint.status_report[:markdowns].first).to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'when running on github' do
|
50
|
+
it 'handles a lint with errors count greater than threshold' do
|
51
|
+
lint_report = "test.go:213:3: don't use underscores in Go names; var my_var should be myVar\n"
|
52
|
+
|
53
|
+
allow(@golint).to receive(:`).with("golint .").and_return(lint_report)
|
54
|
+
allow(@dangerfile.danger).to receive(:scm_provider).and_return("github")
|
55
|
+
allow(@dangerfile.github).to receive(:html_link)
|
56
|
+
.with("test.go#L213", full_path: false)
|
57
|
+
.and_return("fake_link_to:test.go#L213")
|
58
|
+
|
59
|
+
@golint.lint
|
60
|
+
|
61
|
+
markdown = @golint.status_report[:markdowns].first
|
62
|
+
expect(markdown.message).to include("## DangerGo found issues")
|
63
|
+
expect(markdown.message).to include("| fake_link_to:test.go#L213 | 213 | 3 | don`t use underscores in Go names; var my_var should be myVar |")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
ROOT = Pathname.new(File.expand_path('..', __dir__))
|
3
|
+
$LOAD_PATH.unshift((ROOT + 'lib').to_s)
|
4
|
+
$LOAD_PATH.unshift((ROOT + 'spec').to_s)
|
5
|
+
|
6
|
+
require 'bundler/setup'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'danger'
|
11
|
+
|
12
|
+
# Use coloured output, it's the best.
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.filter_gems_from_backtrace 'bundler'
|
15
|
+
config.color = true
|
16
|
+
config.tty = true
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'danger_plugin'
|
20
|
+
|
21
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
22
|
+
# If you are expanding these files, see if it's already been done ^.
|
23
|
+
|
24
|
+
# A silent version of the user interface,
|
25
|
+
# it comes with an extra function `.string` which will
|
26
|
+
# strip all ANSI colours from the string.
|
27
|
+
|
28
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
29
|
+
def testing_ui
|
30
|
+
@output = StringIO.new
|
31
|
+
def @output.winsize
|
32
|
+
[20, 9999]
|
33
|
+
end
|
34
|
+
|
35
|
+
cork = Cork::Board.new(out: @output)
|
36
|
+
def cork.string
|
37
|
+
out.string.gsub(/\e\[([;\d]+)?m/, '')
|
38
|
+
end
|
39
|
+
cork
|
40
|
+
end
|
41
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
42
|
+
|
43
|
+
# Example environment (ENV) that would come from
|
44
|
+
# running a PR on TravisCI
|
45
|
+
def testing_env
|
46
|
+
{
|
47
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
48
|
+
'TRAVIS_PULL_REQUEST' => '800',
|
49
|
+
'TRAVIS_REPO_SLUG' => 'artsy/eigen',
|
50
|
+
'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
51
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
# A stubbed out Dangerfile for use in tests
|
56
|
+
def testing_dangerfile
|
57
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
58
|
+
Danger::Dangerfile.new(env, testing_ui)
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-go
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KennethanCeyer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-04-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger-plugin-api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.49.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.49.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: yard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.9.11
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.9.11
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.14'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.14'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '4.7'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '4.7'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: listen
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 3.0.7
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 3.0.7
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: A Dangerfile for golang developer
|
154
|
+
email:
|
155
|
+
- kenneth@pigno.se
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- ".gitignore"
|
161
|
+
- Gemfile
|
162
|
+
- Gemfile.lock
|
163
|
+
- Guardfile
|
164
|
+
- LICENSE
|
165
|
+
- README.md
|
166
|
+
- Rakefile
|
167
|
+
- danger-go.gemspec
|
168
|
+
- docs/images/gopher.png
|
169
|
+
- lib/danger_golint.rb
|
170
|
+
- lib/danger_plugin.rb
|
171
|
+
- lib/golint/gem_version.rb
|
172
|
+
- lib/golint/plugin.rb
|
173
|
+
- spec/golint_spec.rb
|
174
|
+
- spec/spec_helper.rb
|
175
|
+
homepage: https://github.com/KennethanCeyer/danger-go
|
176
|
+
licenses:
|
177
|
+
- MIT
|
178
|
+
metadata: {}
|
179
|
+
post_install_message:
|
180
|
+
rdoc_options: []
|
181
|
+
require_paths:
|
182
|
+
- lib
|
183
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
requirements: []
|
194
|
+
rubyforge_project:
|
195
|
+
rubygems_version: 2.5.2.3
|
196
|
+
signing_key:
|
197
|
+
specification_version: 4
|
198
|
+
summary: danger-go support toolkit for golang user
|
199
|
+
test_files:
|
200
|
+
- spec/golint_spec.rb
|
201
|
+
- spec/spec_helper.rb
|