pronto-clang_tidy 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/.gitignore +8 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +32 -0
- data/Rakefile +6 -0
- data/lib/pronto/clang_tidy/version.rb +5 -0
- data/lib/pronto/clang_tidy.rb +53 -0
- data/pronto-clang_tidy.gemspec +29 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 912e8cbd46b44243e4e4b8826fdd92a3b5188bd34a7308249182546e317df741
|
4
|
+
data.tar.gz: 3f01a9758d7c41795a9dcc92bbd340399eeef9fa582fa40151721fcc4828e26d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6e80c9ea8d9eb51df711ed959709e7354b31067222e4016ee332657a2143a729839f93de88571d71f7a147362d2f02fd7a99a6ea8d2822f5b8376ef5eaaff6c0
|
7
|
+
data.tar.gz: 94faf438e390e41c506535442307631b1e39219e42708875cd9422440ad6ffee3fbd200685a1fcd9af6239c919e2d58ba8f099e0481da0e0e2280c38de062178
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Michael Jabbour
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Pronto runner for clang-tidy
|
2
|
+
|
3
|
+
[](https://codeclimate.com/github/micjabbour/pronto-clang_tidy)
|
4
|
+
[](https://travis-ci.org/micjabbour/pronto-clang_tidy)
|
5
|
+
[](http://badge.fury.io/rb/pronto-clang_tidy)
|
6
|
+
[](https://gemnasium.com/micjabbour/pronto-clang_tidy)
|
7
|
+
|
8
|
+
Pronto runner for [clang-tidy](http://clang.llvm.org/extra/clang-tidy), a clang-based C++ "linter" tool. [What is Pronto?](https://github.com/prontolabs/pronto)
|
9
|
+
|
10
|
+
This runner can be used after running clang-tidy on a codebase to submit the reported offences to web-based git repo managers (e.g. github, gitlab, ...) as comments using Pronto.
|
11
|
+
|
12
|
+
## Installation:
|
13
|
+
|
14
|
+
First, the following prerequisites need to be installed:
|
15
|
+
|
16
|
+
1. clang-tidy
|
17
|
+
2. Ruby
|
18
|
+
3. Pronto, this can be done after installing Ruby using:
|
19
|
+
```
|
20
|
+
gem install pronto
|
21
|
+
```
|
22
|
+
After that, pronto-clang_tidy can be installed using:
|
23
|
+
```
|
24
|
+
gem install pronto-clang_tidy
|
25
|
+
```
|
26
|
+
Pronto will look for clang-tidy output file and submit its contents as soon as this runner is installed.
|
27
|
+
|
28
|
+
## Configuration:
|
29
|
+
|
30
|
+
After configuring and running `clang-tidy` on your codebase, redirect and save its standard output to a file (e.g. `clang-tidy.out`).
|
31
|
+
|
32
|
+
The name of the clang-tidy output file can be configured by setting the environment variable `PRONTO_CLANG_TIDY_OUTFILE` prior to running pronto. If it is not set, the runner will assume the file name is `clang-tidy.out`.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative 'clang_tidy/version'
|
2
|
+
require 'pronto'
|
3
|
+
|
4
|
+
module Pronto
|
5
|
+
class ClangTidyRunner < Runner
|
6
|
+
def run
|
7
|
+
return [] if !@patches || @patches.count.zero?
|
8
|
+
# loop through all offences in clang-tidy output
|
9
|
+
offences = read_clang_tidy_output
|
10
|
+
return [] if !offences || offences.length.zero?
|
11
|
+
offences.map do |offence|
|
12
|
+
# find the patch that corresponds to the current offence
|
13
|
+
patch = patch_for(offence.file)
|
14
|
+
next if patch.nil?
|
15
|
+
# generate a message for the corresponding added_line in the patch
|
16
|
+
patch.added_lines
|
17
|
+
.select { |added_line| added_line.new_lineno == offence.lineno }
|
18
|
+
.map { |line| new_message(offence, line) }
|
19
|
+
end.flatten.compact
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def patch_for(filename)
|
25
|
+
@patches.find do |p|
|
26
|
+
p.new_file_full_path == Pathname.new(filename)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def new_message(offence, line)
|
31
|
+
path = line.patch.delta.new_file[:path]
|
32
|
+
Message.new(path, line, :warning, offence.msg, nil, self.class)
|
33
|
+
end
|
34
|
+
|
35
|
+
# reads clang-tidy output file and returns an array of offences
|
36
|
+
def read_clang_tidy_output
|
37
|
+
unless FileTest.file? clang_tidy_output_file
|
38
|
+
puts 'WARN: pronto-clang_tidy: clang-tidy output file not found'
|
39
|
+
return ''
|
40
|
+
end
|
41
|
+
clang_tidy_output = File.read clang_tidy_output_file
|
42
|
+
clang_tidy_output.split("\n").each_slice(3).map do |offence|
|
43
|
+
properties = offence[0].split(':').map(&:strip)
|
44
|
+
OpenStruct.new(file: properties[0], lineno: properties[1].to_i,
|
45
|
+
level: properties[3], msg: properties[4])
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def clang_tidy_output_file
|
50
|
+
ENV['PRONTO_CLANG_TIDY_OUTFILE'] || 'clang-tidy.out'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pronto/clang_tidy/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'pronto-clang_tidy'
|
8
|
+
spec.version = Pronto::ClangTidy::VERSION
|
9
|
+
spec.authors = ['Michael Jabbour']
|
10
|
+
spec.email = ['micjabbour@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Pronto runner for clang-tidy, a clang-based C++ ' \
|
13
|
+
'"linter" tool.'
|
14
|
+
spec.homepage = 'https://github.com/micjabbour/pronto-clang_tidy'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.extra_rdoc_files = ['LICENSE.txt', 'README.md']
|
23
|
+
spec.require_paths = ['lib']
|
24
|
+
|
25
|
+
spec.add_dependency 'pronto', '~> 0.9.0'
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
spec.add_development_dependency 'rspec', '~> 3.4'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pronto-clang_tidy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Jabbour
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pronto
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.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.16'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.16'
|
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
|
+
description:
|
70
|
+
email:
|
71
|
+
- micjabbour@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files:
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.md
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/pronto/clang_tidy.rb
|
84
|
+
- lib/pronto/clang_tidy/version.rb
|
85
|
+
- pronto-clang_tidy.gemspec
|
86
|
+
homepage: https://github.com/micjabbour/pronto-clang_tidy
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.7.4
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Pronto runner for clang-tidy, a clang-based C++ "linter" tool.
|
110
|
+
test_files: []
|