class Danger::DangerGolint

Lint javascript files using [golint](golint.org/). Results are send as inline commen.

@example Run golint with changed files only

golint.filtering = true
golint.lint

@see leonhartX/danger-golint @tags lint, golang, golint

Constants

MARKDOWN_TEMPLATE

Attributes

base_dir[W]

Root directory from where golint will run. Defaults to current directory. @return [String]

Public Instance Methods

base_dir() click to toggle source
# File lib/golint/plugin.rb, line 23
def base_dir
  @base_dir || '.'
end
lint() click to toggle source

Lints go files. Generates `errors` and `warnings` due to golint's config. Will try to send inline comment if supported(Github)

@return [void]

# File lib/golint/plugin.rb, line 33
def lint
  errors = lint_results.reject(&:nil?)

  return if errors.empty?

  print_markdown_table(errors)
end

Private Instance Methods

golint_installed?() click to toggle source

Check existing status golint toolchain # @return [bool]

# File lib/golint/plugin.rb, line 46
def golint_installed?
  `which golint`.strip.empty? == false
end
lint_results() click to toggle source

Get lint result regards the filtering option

return [Hash]

# File lib/golint/plugin.rb, line 53
def lint_results
  bin = 'golint'
  system 'go get -u golang.org/x/lint/golint' unless golint_installed?
  run_lint(bin, base_dir)
end
print_markdown_table(errors=[]) click to toggle source

Print markdown string

@param [List<string>] errors

@return [string]

run_lint(bin, dir) click to toggle source

Run golint aginst a single dir.

@param [String] bin

The binary path of golint

@param [String] dir

Dir to be linted

@return [Output]

# File lib/golint/plugin.rb, line 68
def run_lint(bin, dir)
  `#{bin} #{dir}`.split("\n")
end