Socket
Book a DemoInstallSign in
Socket

learn_linter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

learn_linter

1.7.3
bundlerRubygems
Version published
Maintainers
1
Created
Source

class ReadmeLinter

def self.parse_file(file, learn_error) if has_code_snippets?(file) lines = collect_lines(file) validate_snippets(lines, learn_error) else green_light(learn_error) end end

def self.green_light(learn_error) learn_error.readme_error[:valid_readme] = true learn_error.valid_readme = {message: "valid readme", color: :green} end

def self.has_code_snippets?(file) file_content = File.open(file).read file_content.match(/``/) end

def self.collect_lines(file) lines = {} File.foreach(file) do |line_content| lines["#{$.}"] = line_content end lines end

def self.validate_snippets(lines, learn_error) lint_lines(lines, learn_error) total_errors?(learn_error) end

def self.lint_lines(lines, learn_error) lines.each do |line_num, line_content| if line_content.match(/``/) if !(line_content.match(/^```(ruby|bash|swift|html|erb|js|javascript|objc|java|sql|css|text)?$/)) learn_error.valid_readme[:message] << "INVALID CODE SNIPPET - line #{line_num}: #{line_content}" end end end end

def self.total_errors?(learn_error) if error_free?(learn_error) green_light(learn_error) end end

def self.error_free?(learn_error) learn_error.valid_readme[:message].empty? end end

FAQs

Package last updated on 26 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.