code-scanning-rubocop 0.1.1 → 0.2.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 +4 -4
- data/Dockerfile +1 -1
- data/Gemfile.lock +1 -15
- data/code-scanning-rubocop.gemspec +0 -2
- data/entrypoint.sh +14 -2
- data/lib/code_scanning/rubocop/sarif_formatter.rb +6 -28
- data/lib/code_scanning/rubocop/version.rb +1 -1
- data/{rubocop-scan → rubocop-action}/action.yml +0 -0
- metadata +3 -17
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 739a88bd1b19ec2ee128962c43c90c7c3680e2e04ad8cfb98feb9773aa7419d8
         | 
| 4 | 
            +
              data.tar.gz: f7f7aaa9fc8607ffe535494dcbfcd9ea1ac17620bba8073a9a67859064c45e28
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8c48865aedc4968ed50c8d6dfb1ae3e42b8b44fde53a82219e0b47bafcc0b51b84cb29642d7e29db5759caec0345a953a7940928bc85396aacbee393deb35ffe
         | 
| 7 | 
            +
              data.tar.gz: 33a344112b71cba3ab3a77411173cff7bc96a88fb4d2df3db9536edbb86aa6ececf57052950cf4098daf6df5e18bf15c41af1d4e8635102ec300948768f6003c
         | 
    
        data/Dockerfile
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,23 +1,13 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                code-scanning-rubocop (0. | 
| 5 | 
            -
                  activesupport
         | 
| 4 | 
            +
                code-scanning-rubocop (0.2.0)
         | 
| 6 5 | 
             
                  rubocop (~> 0.82.0)
         | 
| 7 6 |  | 
| 8 7 | 
             
            GEM
         | 
| 9 8 | 
             
              remote: https://rubygems.org/
         | 
| 10 9 | 
             
              specs:
         | 
| 11 | 
            -
                activesupport (6.0.2.2)
         | 
| 12 | 
            -
                  concurrent-ruby (~> 1.0, >= 1.0.2)
         | 
| 13 | 
            -
                  i18n (>= 0.7, < 2)
         | 
| 14 | 
            -
                  minitest (~> 5.1)
         | 
| 15 | 
            -
                  tzinfo (~> 1.1)
         | 
| 16 | 
            -
                  zeitwerk (~> 2.2)
         | 
| 17 10 | 
             
                ast (2.4.0)
         | 
| 18 | 
            -
                concurrent-ruby (1.1.6)
         | 
| 19 | 
            -
                i18n (1.8.2)
         | 
| 20 | 
            -
                  concurrent-ruby (~> 1.0)
         | 
| 21 11 | 
             
                jaro_winkler (1.5.4)
         | 
| 22 12 | 
             
                minitest (5.14.0)
         | 
| 23 13 | 
             
                parallel (1.19.1)
         | 
| @@ -35,11 +25,7 @@ GEM | |
| 35 25 | 
             
                  ruby-progressbar (~> 1.7)
         | 
| 36 26 | 
             
                  unicode-display_width (>= 1.4.0, < 2.0)
         | 
| 37 27 | 
             
                ruby-progressbar (1.10.1)
         | 
| 38 | 
            -
                thread_safe (0.3.6)
         | 
| 39 | 
            -
                tzinfo (1.2.7)
         | 
| 40 | 
            -
                  thread_safe (~> 0.1)
         | 
| 41 28 | 
             
                unicode-display_width (1.7.0)
         | 
| 42 | 
            -
                zeitwerk (2.3.0)
         | 
| 43 29 |  | 
| 44 30 | 
             
            PLATFORMS
         | 
| 45 31 | 
             
              ruby
         | 
    
        data/entrypoint.sh
    CHANGED
    
    | @@ -4,5 +4,17 @@ set -x | |
| 4 4 |  | 
| 5 5 | 
             
            cd $GITHUB_WORKSPACE
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 7 | 
            +
            # Install correct bundler version
         | 
| 8 | 
            +
            gem install bundler -v "$(grep -A 1 "BUNDLED WITH" Gemfile.lock | tail -n 1)"
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            bundle install
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            bundle inject code-scanning-rubocop "$(gem list | grep code-scanning-rubocop | tr -cd '0-9.')"
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            bundle exec rubocop --require code_scanning --format CodeScanning::SarifFormatter -o rubocop.sarif
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            if [ ! -f rubocop.sarif ]; then
         | 
| 17 | 
            +
                exit 1
         | 
| 18 | 
            +
            else
         | 
| 19 | 
            +
                exit 0
         | 
| 20 | 
            +
            fi
         | 
| @@ -1,12 +1,8 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            -
             | 
| 3 2 | 
             
            require 'rubocop/formatter/base_formatter'
         | 
| 4 3 | 
             
            require 'json'
         | 
| 5 | 
            -
            require 'active_support/all'
         | 
| 6 4 | 
             
            require 'pathname'
         | 
| 7 5 |  | 
| 8 | 
            -
            # TODO: fix me
         | 
| 9 | 
            -
            ROOT = __dir__
         | 
| 10 6 | 
             
            module CodeScanning
         | 
| 11 7 |  | 
| 12 8 | 
             
              class SarifFormatter < RuboCop::Formatter::BaseFormatter
         | 
| @@ -27,17 +23,9 @@ module CodeScanning | |
| 27 23 | 
             
                      },
         | 
| 28 24 | 
             
                      'results' => @results }
         | 
| 29 25 | 
             
                  ]
         | 
| 30 | 
            -
                  # TODO: under runs
         | 
| 31 | 
            -
                  #    "tool" : {
         | 
| 32 | 
            -
                  #      "driver" : {
         | 
| 33 | 
            -
                  #        "name" : "CodeQL command-line toolchain",
         | 
| 34 | 
            -
                  #        "organization" : "GitHub",
         | 
| 35 | 
            -
                  #        "semanticVersion" : "2.0.0",
         | 
| 36 | 
            -
                  #        "rules" : [ {
         | 
| 37 26 | 
             
                end
         | 
| 38 27 |  | 
| 39 | 
            -
                Rule = Struct.new(:name, :index | 
| 40 | 
            -
                end
         | 
| 28 | 
            +
                Rule = Struct.new(:name, :index)
         | 
| 41 29 |  | 
| 42 30 | 
             
                def set_rule(cop_name, severity)
         | 
| 43 31 | 
             
                  if r = @rules_map[cop_name]
         | 
| @@ -59,14 +47,13 @@ module CodeScanning | |
| 59 47 | 
             
                    'properties' => {}
         | 
| 60 48 | 
             
                  }
         | 
| 61 49 | 
             
                  @rules << h
         | 
| 62 | 
            -
                  @rules_map[cop_name] = Rule.new(cop_name, @rules.size - 1 | 
| 50 | 
            +
                  @rules_map[cop_name] = Rule.new(cop_name, @rules.size - 1)
         | 
| 63 51 | 
             
                end
         | 
| 64 52 |  | 
| 65 53 | 
             
                def sarif_severity(cop_severity)
         | 
| 66 | 
            -
                  return cop_severity if  | 
| 67 | 
            -
                  return 'note' if  | 
| 68 | 
            -
                  return 'error' if cop_severity | 
| 69 | 
            -
             | 
| 54 | 
            +
                  return cop_severity if %w[warning error].include?(cop_severity)
         | 
| 55 | 
            +
                  return 'note' if %w[refactor convention].include?(cop_severity)
         | 
| 56 | 
            +
                  return 'error' if cop_severity == 'fatal'
         | 
| 70 57 | 
             
                  'none'
         | 
| 71 58 | 
             
                end
         | 
| 72 59 |  | 
| @@ -99,18 +86,9 @@ module CodeScanning | |
| 99 86 | 
             
                        }
         | 
| 100 87 | 
             
                      ],
         | 
| 101 88 | 
             
                      'partialFingerprints' => {
         | 
| 102 | 
            -
                        # | 
| 103 | 
            -
                        #        "primaryLocationStartColumnFingerprint" : "4"
         | 
| 89 | 
            +
                        # This will be computed by the upload action for now
         | 
| 104 90 | 
             
                      }
         | 
| 105 91 | 
             
                    }
         | 
| 106 | 
            -
             | 
| 107 | 
            -
                    #      #       "%<path>s:%<line>d:%<column>d: %<severity>s: %<message>s\n",
         | 
| 108 | 
            -
                    #      #       path: file,
         | 
| 109 | 
            -
                    #      #       line: o.line,
         | 
| 110 | 
            -
                    #      #       column: o.real_column,
         | 
| 111 | 
            -
                    #      #       severity: o.severity.code,
         | 
| 112 | 
            -
                    #      #       message: message(o)
         | 
| 113 | 
            -
                    #      #     )
         | 
| 114 92 | 
             
                  end
         | 
| 115 93 | 
             
                end
         | 
| 116 94 |  | 
| 
            File without changes
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: code-scanning-rubocop
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Arthur Neves
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020-05- | 
| 11 | 
            +
            date: 2020-05-05 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rubocop
         | 
| @@ -24,20 +24,6 @@ dependencies: | |
| 24 24 | 
             
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 26 | 
             
                    version: 0.82.0
         | 
| 27 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            -
              name: activesupport
         | 
| 29 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            -
                requirements:
         | 
| 31 | 
            -
                - - ">="
         | 
| 32 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: '0'
         | 
| 34 | 
            -
              type: :runtime
         | 
| 35 | 
            -
              prerelease: false
         | 
| 36 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            -
                requirements:
         | 
| 38 | 
            -
                - - ">="
         | 
| 39 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: '0'
         | 
| 41 27 | 
             
            description: This gem adds a SARIF formatter to rubocop, so we can export alerts to
         | 
| 42 28 | 
             
              code-scanning inside GitHub.
         | 
| 43 29 | 
             
            email:
         | 
| @@ -61,7 +47,7 @@ files: | |
| 61 47 | 
             
            - lib/code_scanning.rb
         | 
| 62 48 | 
             
            - lib/code_scanning/rubocop/sarif_formatter.rb
         | 
| 63 49 | 
             
            - lib/code_scanning/rubocop/version.rb
         | 
| 64 | 
            -
            - rubocop- | 
| 50 | 
            +
            - rubocop-action/action.yml
         | 
| 65 51 | 
             
            homepage: https://github.com/arthurnn/code-scanning-rubocop
         | 
| 66 52 | 
             
            licenses:
         | 
| 67 53 | 
             
            - MIT
         |