checkstyle_filter-git 1.0.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: eefefc30a709cd108ff7af5fc8665bdb3e233697
4
- data.tar.gz: 86fd8708b347ac2331d691ec9974fcbbaf589984
2
+ SHA256:
3
+ metadata.gz: 398394838f77852b714bb97c721e3390d8d075b79fd7777a025c74300489d38f
4
+ data.tar.gz: 686e3c314f636b1b42f5ef4555b8c5d577527d78f9a115c4b77e3714d300ae14
5
5
  SHA512:
6
- metadata.gz: 3b44da9604d392b41a91dd785e934ff6cc930a463309ec6ce86d4a30cd0bc51ce4709ddfd355f523ad46b7d9373d51c0f5da03656b1d4ea79df3485776cbf4f0
7
- data.tar.gz: a73d4e34ff10f4e955cce90609c9dc1af28853ae135c5e262483c0d41eebc2688d4c90e9279542e316e15b13144155dc821dea36d656ba0f2c25cdb9e2fd4be7
6
+ metadata.gz: 405300899cf8146e57da9bb8f5ab98e25b55479b205a7d822f0807de20fbc1551230b9eca444d6baaae248a3eb5972608c98d8f0d6da57c8d882a2ad8eb911bd
7
+ data.tar.gz: 741b2a3c9b5831ffdedc60dc1ac726b4e07a454757ba16b4962f499c7978d0f843485559c7ae8cc5e03827e46f480a7feb00ff4447812e48f1f1382ac8bb8137
@@ -0,0 +1,35 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@1.1.2
4
+
5
+ executors:
6
+ linux:
7
+ docker:
8
+ - image: cimg/base:stable
9
+
10
+ jobs:
11
+ test:
12
+ parameters:
13
+ os:
14
+ type: executor
15
+ ruby-version:
16
+ type: string
17
+ executor: << parameters.os >>
18
+ steps:
19
+ - checkout
20
+ - ruby/install:
21
+ version: << parameters.ruby-version >>
22
+ - run:
23
+ name: bundle install
24
+ command: bundle install
25
+ - run:
26
+ name: test
27
+ command: bundle exec rake
28
+ workflows:
29
+ all-tests:
30
+ jobs:
31
+ - test:
32
+ matrix:
33
+ parameters:
34
+ os: [linux]
35
+ ruby-version: ["2.5", "2.6", "2.7", "3.0"]
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+ var execSync = require('child_process').execSync;
3
+ var URI = require('urijs');
4
+
5
+ var gemspec = JSON.parse(execSync('bundle exec parse-gemspec-cli checkstyle_filter-git.gemspec'));
6
+ var homepageUrl = gemspec.homepage;
7
+ var url = new URI(homepageUrl);
8
+ var host = url.protocol() + '://' + url.authority();
9
+ var owner = url.pathname().split('/')[1];
10
+ var repository = url.pathname().split('/')[2];
11
+
12
+ module.exports = {
13
+ version: gemspec.version,
14
+ host: host,
15
+ owner: owner,
16
+ repository: repository
17
+ };
data/.gitignore CHANGED
@@ -7,6 +7,8 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /node_modules/
11
+ /package-lock.json
10
12
 
11
13
  # Ignore bundler binstubs
12
14
  /bundle_bin
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in checkstyle_filter-git.gemspec
4
4
  gemspec
5
5
 
6
- gem 'byebug' if RUBY_VERSION >= '2.0.0'
6
+ gem 'byebug'
7
7
  gem 'pry'
8
+ gem 'parse_gemspec-cli'
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # CheckstyleFilter::Git
2
2
 
3
3
  [![Gem Version](http://img.shields.io/gem/v/checkstyle_filter-git.svg?style=flat)](http://badge.fury.io/rb/checkstyle_filter-git)
4
- [![Build Status](http://img.shields.io/travis/packsaddle/ruby-checkstyle_filter-git/master.svg?style=flat)](https://travis-ci.org/packsaddle/ruby-checkstyle_filter-git)
4
+ [![Build Status](https://img.shields.io/circleci/build/github/packsaddle/ruby-checkstyle_filter-git?style=flat)](https://circleci.com/gh/packsaddle/ruby-checkstyle_filter-git)
5
5
 
6
6
  ## What is this?
7
7
 
@@ -20,7 +20,8 @@
20
20
  <file name='/Users/sane/work/ruby-study/checkstyle_filter-git/lib/checkstyle_filter/git/cli.rb'>
21
21
  <error line='14' column='6' severity='info' message='Assignment Branch Condition size for diff is too high. [54.73/15]' source='com.puppycrawl.tools.checkstyle.Metrics/AbcSize'/>
22
22
  </file>
23
- <checkstyle>
23
+ </checkstyle>
24
+
24
25
  ```
25
26
 
26
27
  2. git diff
@@ -125,6 +126,7 @@ Or install it yourself as:
125
126
  $ checkstyle_filter-git
126
127
  Commands:
127
128
  checkstyle_filter-git diff # Filter using `git diff`
129
+ checkstyle_filter-git exec # Exec command `"git diff --no-color origin/master | iconv -f EUCJP -t UTF8"`
128
130
  checkstyle_filter-git help [COMMAND] # Describe available commands or one specific command
129
131
  checkstyle_filter-git version # Show the CheckstyleFilter/Git version
130
132
 
@@ -137,6 +139,12 @@ Options:
137
139
  [--file=FILE]
138
140
 
139
141
  Filter using `git diff`
142
+
143
+ $ checkstyle_filter-git help exec
144
+ Usage:
145
+ checkstyle_filter-git exec
146
+
147
+ Exec command `"git diff --no-color origin/master | iconv -f EUCJP -t UTF8"`
140
148
  ```
141
149
 
142
150
  ## Development
data/changelog.md ADDED
@@ -0,0 +1,24 @@
1
+ <a name="1.2.0"></a>
2
+ # [1.2.0](https://github.com/packsaddle/ruby-checkstyle_filter-git/compare/v1.1.0...v1.2.0) (2021-04-13)
3
+
4
+
5
+ ### Features
6
+
7
+ * **deps:** add rexml for ruby 3.0 compatibility ([0ec9d95](https://github.com/packsaddle/ruby-checkstyle_filter-git/commit/0ec9d95))
8
+
9
+
10
+
11
+ # ChangeLog
12
+
13
+ <a name="1.1.0"></a>
14
+ # [1.1.0](https://github.com/packsaddle/ruby-checkstyle_filter-git/compare/v1.0.3...v1.1.0) (2016-06-25)
15
+
16
+
17
+ ### Features
18
+
19
+ * **command:** inmpement exec command([a11c3c7](https://github.com/packsaddle/ruby-checkstyle_filter-git/commit/a11c3c7f4daf1ddf26c0ab4f4ae9d8b1b78bda4b)), closes [#11](https://github.com/packsaddle/ruby-checkstyle_filter-git/pull/11)
20
+
21
+
22
+ ## 1.0.3
23
+
24
+ * Relax dependencies
@@ -23,10 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ['lib']
24
24
 
25
25
  spec.add_runtime_dependency 'thor'
26
- spec.add_runtime_dependency 'git-diff-parser'
26
+ spec.add_runtime_dependency 'git_diff_parser'
27
+ spec.add_runtime_dependency 'rexml'
27
28
 
28
- spec.add_development_dependency 'bundler', '~> 1.8'
29
- spec.add_development_dependency 'rake', '~> 10.0'
29
+ spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'rake'
30
31
  spec.add_development_dependency 'test-unit'
31
32
  spec.add_development_dependency 'nori'
32
33
  end
data/example/example1.xml CHANGED
@@ -1,9 +1,9 @@
1
1
  <?xml version='1.0'?>
2
2
  <checkstyle>
3
- <file name='/Users/sane/work/ruby-study/checkstyle_filter-git/checkstyle_filter-git.gemspec'/>
4
- <file name='/Users/sane/work/ruby-study/checkstyle_filter-git/example/invalid.rb'>
3
+ <file name='checkstyle_filter-git.gemspec'/>
4
+ <file name='example/invalid.rb'>
5
5
  <error line='3' column='100' severity='info' message='Line is too long. [188/100]' source='com.puppycrawl.tools.checkstyle.Metrics/LineLength'/>
6
6
  </file>
7
- <file name='/Users/sane/work/ruby-study/checkstyle_filter-git/exe/checkstyle_filter-git'/>
8
- <file name='/Users/sane/work/ruby-study/checkstyle_filter-git/lib/checkstyle_filter/git/cli.rb'/>
9
- </checkstyle>
7
+ <file name='exe/checkstyle_filter-git'/>
8
+ <file name='lib/checkstyle_filter/git/cli.rb'/>
9
+ </checkstyle>
@@ -1,4 +1,4 @@
1
- require 'git/diff/parser'
1
+ require 'git_diff_parser'
2
2
  require 'checkstyle_filter/git/version'
3
3
  require 'checkstyle_filter/git/filter'
4
4
 
@@ -29,6 +29,19 @@ module CheckstyleFilter
29
29
  puts ::CheckstyleFilter::Git::Filter.filter(data, git_diff)
30
30
  end
31
31
 
32
+ desc 'exec', 'Exec command `"git diff --no-color origin/master | iconv -f EUCJP -t UTF8"`'
33
+ def exec(command)
34
+ data = if !$stdin.tty?
35
+ ARGV.clear
36
+ ARGF.read
37
+ end
38
+
39
+ abort if !data || data.empty?
40
+
41
+ git_diff, _, _ = Open3.capture3(command)
42
+ puts ::CheckstyleFilter::Git::Filter.filter(data, git_diff)
43
+ end
44
+
32
45
  desc 'version', 'Show the CheckstyleFilter/Git version'
33
46
  map %w(-v --version) => :version
34
47
 
@@ -5,15 +5,17 @@ module CheckstyleFilter
5
5
  module Git
6
6
  class Filter
7
7
  def self.filter(data, git_diff)
8
- patches = ::Git::Diff::Parser.parse(git_diff)
8
+ patches = ::GitDiffParser.parse(git_diff)
9
9
 
10
10
  document = REXML::Document.new data
11
11
  document.elements.each('/checkstyle/file') do |file_element|
12
12
  file_name = file_element.attribute('name') && file_element.attribute('name').value
13
- if file_in_patches?(file_name, patches)
13
+ file = file_relative_path_string(file_name)
14
+ patch = patches.find_patch_by_file(file)
15
+ if patch
14
16
  file_element.elements.each('error') do |error_element|
15
17
  line = error_element.attribute('line') && error_element.attribute('line').value.to_i
16
- unless file_element_error_line_no_in_patches?(file_name, patches, line)
18
+ unless patch.changed_line_numbers.include?(line)
17
19
  error_element.remove
18
20
  end
19
21
  end
@@ -27,30 +29,12 @@ module CheckstyleFilter
27
29
  document.to_s
28
30
  end
29
31
 
30
- def self.file_in_patches?(file_name, patches)
31
- patches
32
- .map(&:file)
33
- .map { |file| Pathname.new(file).expand_path }
34
- .include?(Pathname.new(file_name).expand_path)
35
- end
36
-
37
- def self.file_element_error_line_no_in_patches?(file_name, patches, line_no)
38
- diff_patches = patches
39
- .select { |patch| same_file?(patch.file, file_name) }
40
- return false if diff_patches.empty?
41
-
42
- modified_lines = Set.new
43
- diff_patches.map do |patch|
44
- patch.changed_lines.map do |line|
45
- modified_lines << line.number
46
- end
32
+ def self.file_relative_path_string(file_name)
33
+ if Pathname.new(file_name).absolute?
34
+ Pathname.new(file_name).relative_path_from(Pathname.new(Dir.pwd)).to_s
35
+ else
36
+ Pathname.new(file_name).relative_path_from(Pathname.new('.')).to_s
47
37
  end
48
-
49
- modified_lines.include?(line_no)
50
- end
51
-
52
- def self.same_file?(one, other)
53
- Pathname.new(one).expand_path == Pathname.new(other).expand_path
54
38
  end
55
39
  end
56
40
  end
@@ -1,5 +1,5 @@
1
1
  module CheckstyleFilter
2
2
  module Git
3
- VERSION = '1.0.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
data/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "devDependencies": {
3
+ "conventional-changelog-cli": "^1.1.1",
4
+ "npm-check-updates": "^2.2.3",
5
+ "urijs": "^1.16.1"
6
+ },
7
+ "scripts": {
8
+ "changelog": "conventional-changelog -i changelog.md --same-file --preset angular --context .conventional-changelog.context.js",
9
+ "ncu": "ncu -u"
10
+ }
11
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkstyle_filter-git
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-02-21 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -25,7 +25,21 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: git-diff-parser
28
+ name: git_diff_parser
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
+ - !ruby/object:Gem::Dependency
42
+ name: rexml
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -42,30 +56,30 @@ dependencies:
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - "~>"
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
- version: '1.8'
61
+ version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - "~>"
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
- version: '1.8'
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '10.0'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '10.0'
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: test-unit
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -102,9 +116,10 @@ executables:
102
116
  extensions: []
103
117
  extra_rdoc_files: []
104
118
  files:
119
+ - ".circleci/config.yml"
120
+ - ".conventional-changelog.context.js"
105
121
  - ".gitignore"
106
122
  - ".rubocop.yml"
107
- - ".travis.yml"
108
123
  - CODE_OF_CONDUCT.md
109
124
  - Gemfile
110
125
  - LICENSE.txt
@@ -112,6 +127,7 @@ files:
112
127
  - Rakefile
113
128
  - bin/console
114
129
  - bin/setup
130
+ - changelog.md
115
131
  - checkstyle_filter-git.gemspec
116
132
  - example/example1.xml
117
133
  - example/invalid.rb
@@ -121,6 +137,7 @@ files:
121
137
  - lib/checkstyle_filter/git/cli.rb
122
138
  - lib/checkstyle_filter/git/filter.rb
123
139
  - lib/checkstyle_filter/git/version.rb
140
+ - package.json
124
141
  homepage: https://github.com/packsaddle/ruby-checkstyle_filter-git
125
142
  licenses:
126
143
  - MIT
@@ -140,8 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
157
  - !ruby/object:Gem::Version
141
158
  version: '0'
142
159
  requirements: []
143
- rubyforge_project:
144
- rubygems_version: 2.4.5
160
+ rubygems_version: 3.1.4
145
161
  signing_key:
146
162
  specification_version: 4
147
163
  summary: Filter checkstyle format errors on ONLY modified lines.
data/.travis.yml DELETED
@@ -1,15 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- - 1.9
5
- - 2.0
6
- - 2.1
7
- - 2.2
8
- before_install:
9
- - gem update bundler
10
- notifications:
11
- email:
12
- - ogataken@gmail.com
13
- branches:
14
- only:
15
- - master