danger-danger_plugin_lint 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/lib/danger/danger_plugin_lint.rb +46 -0
 - data/lib/danger_plugin.rb +4 -0
 - data/lib/danger_plugin_lint/version.rb +5 -0
 - metadata +62 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b4aadd85462ff4126981b6bfc38d37a53b24dd105ad8d110e4ab6e301814287d
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: ab819488ca07c850a927b6d34cd3818c1a8378d71f4ec943bc7ab8360ff89f4d
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 29dea3cebac8c2eb9b72f701c93ead9dae5a54ce49ce1c587bf0d6439df796826014a6659f3afe7fe0e159e347f0e2d16e81a7ba16edeeecd820a5cef9f70454
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5640c96ba572b85cd22e5e10ac251e6647394f6975883b28d1cfa4b4412bd7afdba689418a18cfc1be6e5cf7fa2f76da9494ac22e6405784f430d6a6e8850f41
         
     | 
| 
         @@ -0,0 +1,46 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require 'danger'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            module Danger
         
     | 
| 
      
 6 
     | 
    
         
            +
              # Analyze Danger plugin or files and report problems.
         
     | 
| 
      
 7 
     | 
    
         
            +
              # This plugin does the almost same as `danger plugins lint` but it runs on Danger.
         
     | 
| 
      
 8 
     | 
    
         
            +
              #
         
     | 
| 
      
 9 
     | 
    
         
            +
              # @example To run this plugin on your plugin's repo, you just run it in your Dangerfile.
         
     | 
| 
      
 10 
     | 
    
         
            +
              #
         
     | 
| 
      
 11 
     | 
    
         
            +
              #          plugin_lint.lint_docs
         
     | 
| 
      
 12 
     | 
    
         
            +
              #
         
     | 
| 
      
 13 
     | 
    
         
            +
              # @see file:README.md
         
     | 
| 
      
 14 
     | 
    
         
            +
              # @tags danger, plugin, lint
         
     | 
| 
      
 15 
     | 
    
         
            +
              class DangerPluginLint < Plugin
         
     | 
| 
      
 16 
     | 
    
         
            +
                # Analyze plugin files and detect documentation problems.
         
     | 
| 
      
 17 
     | 
    
         
            +
                #
         
     | 
| 
      
 18 
     | 
    
         
            +
                # @param [Array] refs                 Paths to files or gems to be linted.
         
     | 
| 
      
 19 
     | 
    
         
            +
                #                                     If `nil` is given, it automatically finds files.
         
     | 
| 
      
 20 
     | 
    
         
            +
                # @param [Boolean] warnings_as_errors If `true`, treat all warnings as errors.
         
     | 
| 
      
 21 
     | 
    
         
            +
                # @return [void]
         
     | 
| 
      
 22 
     | 
    
         
            +
                def lint_docs(*refs, warnings_as_errors: false)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  file_resolver = PluginFileResolver.new(refs.empty? ? nil : refs.flatten)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  data = file_resolver.resolve
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  parser = PluginParser.new(data[:paths], verbose: true)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  parser.parse
         
     | 
| 
      
 28 
     | 
    
         
            +
                  json = parser.to_json
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  linter = PluginLinter.new(json)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  linter.lint
         
     | 
| 
      
 32 
     | 
    
         
            +
                  display_rules(:fail, linter.errors)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  display_rules(warnings_as_errors ? :fail : :warn, linter.warnings)
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                private
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                def display_rules(method, rules)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  rules.each do |rule|
         
     | 
| 
      
 40 
     | 
    
         
            +
                    abs_file, line = rule.metadata[:files][0]
         
     | 
| 
      
 41 
     | 
    
         
            +
                    file = Pathname.new(abs_file).relative_path_from(Dir.pwd).to_s
         
     | 
| 
      
 42 
     | 
    
         
            +
                    public_send(method, rule.description, file: file, line: line)
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,62 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: danger-danger_plugin_lint
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Ryosuke Ito
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-11-06 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 
     | 
    
         
            +
            description: A Danger plugin to lint Danger plugin
         
     | 
| 
      
 28 
     | 
    
         
            +
            email:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - rito.0305@gmail.com
         
     | 
| 
      
 30 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 33 
     | 
    
         
            +
            files:
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/danger/danger_plugin_lint.rb
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/danger_plugin.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/danger_plugin_lint/version.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            homepage: https://github.com/manicmaniac/danger-danger_plugin_lint
         
     | 
| 
      
 38 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 39 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 40 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 41 
     | 
    
         
            +
              source_code_uri: https://github.com/manicmaniac/danger-danger_plugin_lint
         
     | 
| 
      
 42 
     | 
    
         
            +
              rubygems_mfa_required: 'true'
         
     | 
| 
      
 43 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 44 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 45 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 46 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 47 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 48 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 49 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 50 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 51 
     | 
    
         
            +
                  version: 2.7.0
         
     | 
| 
      
 52 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 53 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 54 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 55 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 56 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 57 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 58 
     | 
    
         
            +
            rubygems_version: 3.1.2
         
     | 
| 
      
 59 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 60 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 61 
     | 
    
         
            +
            summary: A Danger plugin to lint Danger plugin
         
     | 
| 
      
 62 
     | 
    
         
            +
            test_files: []
         
     |