pronto-clang_tidy 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/pronto/clang_tidy/version.rb +1 -1
- data/lib/pronto/clang_tidy.rb +27 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8b2568123ef68b9a13cb451f547eabf93a7deada6854e31fb4d715faf7d84e
|
4
|
+
data.tar.gz: 27f8ca1e59d14a209a2651c47868a58a7ad825ce2badde47199835908762c1b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fb3f5aaa237f15b8ff4558cb641eec7ea664d0dc029ee0fa4edd1d1776c250d42c4ce088001d1a6f0c64af35a22c289326c87e0abc41354c14b3749a82ba884
|
7
|
+
data.tar.gz: 41d2a054d544738db1de3f50a4b205dbfa92061f2dec3ba7ac8d590cf97fe5731cb9ce80eb6391befc92bd437a37372a33fe1252ef786cc8792a9233f0767141
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Code Climate](https://codeclimate.com/github/micjabbour/pronto-clang_tidy.png)](https://codeclimate.com/github/micjabbour/pronto-clang_tidy)
|
4
4
|
[![Build Status](https://travis-ci.org/micjabbour/pronto-clang_tidy.png)](https://travis-ci.org/micjabbour/pronto-clang_tidy)
|
5
5
|
[![Gem Version](https://badge.fury.io/rb/pronto-clang_tidy.png)](http://badge.fury.io/rb/pronto-clang_tidy)
|
6
|
-
[![Dependency Status](https://gemnasium.com/micjabbour/pronto-clang_tidy.png)](https://gemnasium.com/micjabbour/pronto-clang_tidy)
|
7
6
|
|
8
7
|
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
8
|
|
@@ -29,4 +28,10 @@ Pronto will look for clang-tidy output file and submit its contents as soon as t
|
|
29
28
|
|
30
29
|
After configuring and running `clang-tidy` on your codebase, redirect and save its standard output to a file (e.g. `clang-tidy.out`).
|
31
30
|
|
31
|
+
To do that, you can use my [modified version of `run-clang-tidy.py`](https://gist.github.com/micjabbour/948578e0e24ce99aaaf6b32d848c9c18#file-run-clang-tidy-py) to automatically save clang-tidy output into `clang-tidy.out`:
|
32
|
+
```
|
33
|
+
python run-clang-tidy.py -checks=* -p build
|
34
|
+
```
|
35
|
+
where `build` is your build directory (that is, the directory that contains the generated file [`compile_commands.json`](https://clang.llvm.org/docs/JSONCompilationDatabase.html)).
|
36
|
+
|
32
37
|
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/lib/pronto/clang_tidy.rb
CHANGED
@@ -13,7 +13,9 @@ module Pronto
|
|
13
13
|
next if patch.nil?
|
14
14
|
# generate a message for the corresponding added_line in the patch
|
15
15
|
message_for(patch, offence)
|
16
|
-
|
16
|
+
# Header warnings are repeated for every compilation unit that includes
|
17
|
+
# them. Use uniq to ignore repeated messages
|
18
|
+
end.flatten.compact.uniq
|
17
19
|
end
|
18
20
|
|
19
21
|
private
|
@@ -37,23 +39,42 @@ module Pronto
|
|
37
39
|
|
38
40
|
def new_message(offence, line)
|
39
41
|
path = line.patch.delta.new_file[:path]
|
40
|
-
Message.new(path, line,
|
42
|
+
Message.new(path, line, pronto_level(offence.level), offence.msg, nil,
|
43
|
+
self.class)
|
44
|
+
end
|
45
|
+
|
46
|
+
def pronto_level(clang_level)
|
47
|
+
case clang_level
|
48
|
+
when :warning
|
49
|
+
:warning
|
50
|
+
when :error
|
51
|
+
:error
|
52
|
+
when :fatal
|
53
|
+
:fatal
|
54
|
+
else
|
55
|
+
:info
|
56
|
+
end
|
41
57
|
end
|
42
58
|
|
43
59
|
# reads clang-tidy output file and returns an array of offences
|
44
60
|
def read_clang_tidy_output
|
45
61
|
unless FileTest.file? clang_tidy_output_file
|
46
62
|
puts 'WARN: pronto-clang_tidy: clang-tidy output file not found'
|
47
|
-
return
|
63
|
+
return []
|
48
64
|
end
|
49
65
|
clang_tidy_output = File.read clang_tidy_output_file
|
50
|
-
clang_tidy_output.
|
51
|
-
|
66
|
+
clang_tidy_output.each_line.select { |line| line_is_offence? line }
|
67
|
+
.map do |offence|
|
68
|
+
properties = offence.split(':').map(&:strip)
|
52
69
|
OpenStruct.new(file: properties[0], lineno: properties[1].to_i,
|
53
|
-
level: properties[3], msg: properties[4])
|
70
|
+
level: properties[3].to_sym, msg: properties[4])
|
54
71
|
end
|
55
72
|
end
|
56
73
|
|
74
|
+
def line_is_offence?(line)
|
75
|
+
line.start_with?('/') && /:\d+:\d+:/.match(line) && /\[\S+\]/.match(line)
|
76
|
+
end
|
77
|
+
|
57
78
|
def clang_tidy_output_file
|
58
79
|
ENV['PRONTO_CLANG_TIDY_OUTFILE'] || 'clang-tidy.out'
|
59
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto-clang_tidy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Jabbour
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pronto
|