xcop 0.7.2 → 0.9.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.
@@ -1,44 +0,0 @@
1
- # (The MIT License)
2
- #
3
- # Copyright (c) 2017-2025 Yegor Bugayenko
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 all
13
- # 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 THE
21
- # SOFTWARE.
22
- ---
23
- name: rake
24
- on:
25
- push:
26
- branches:
27
- - master
28
- pull_request:
29
- branches:
30
- - master
31
- jobs:
32
- test:
33
- strategy:
34
- matrix:
35
- os: [ubuntu-24.04, macos-15]
36
- ruby: ['2.7', '3.0']
37
- runs-on: ${{ matrix.os }}
38
- steps:
39
- - uses: actions/checkout@v4
40
- - uses: ruby/setup-ruby@v1
41
- with:
42
- ruby-version: ${{ matrix.ruby }}
43
- - run: bundle update
44
- - run: bundle exec rake
@@ -1,33 +0,0 @@
1
- # (The MIT License)
2
- #
3
- # Copyright (c) 2017-2025 Yegor Bugayenko
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 all
13
- # 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 THE
21
- # SOFTWARE.
22
- ---
23
- name: xcop
24
- on:
25
- push:
26
- pull_request:
27
- jobs:
28
- xcop:
29
- timeout-minutes: 15
30
- runs-on: ubuntu-24.04
31
- steps:
32
- - uses: actions/checkout@v4
33
- - uses: g4s8/xcop-action@master
@@ -1,37 +0,0 @@
1
- # (The MIT License)
2
- #
3
- # Copyright (c) 2017-2025 Yegor Bugayenko
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 all
13
- # 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 THE
21
- # SOFTWARE.
22
- ---
23
- name: yamllint
24
- 'on':
25
- push:
26
- branches:
27
- - master
28
- pull_request:
29
- branches:
30
- - master
31
- jobs:
32
- yamllint:
33
- timeout-minutes: 15
34
- runs-on: ubuntu-24.04
35
- steps:
36
- - uses: actions/checkout@v4
37
- - uses: ibiqlik/action-yamllint@v3
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- coverage/
2
- Gemfile.lock
3
- .idea/
4
- *.gem
5
- .bundle/
6
- .DS_Store
7
- rdoc/
data/.pdd DELETED
@@ -1,7 +0,0 @@
1
- --source=.
2
- --verbose
3
- --exclude target/**/*
4
- --exclude coverage/**/*
5
- --rule min-words:20
6
- --rule min-estimate:15
7
- --rule max-estimate:90
data/.rubocop.yml DELETED
@@ -1,45 +0,0 @@
1
- # (The MIT License)
2
- #
3
- # Copyright (c) 2017-2025 Yegor Bugayenko
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 all
13
- # 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 THE
21
- # SOFTWARE.
22
- ---
23
- AllCops:
24
- Exclude:
25
- - 'bin/**/*'
26
- - 'assets/**/*'
27
- DisplayCopNames: true
28
- TargetRubyVersion: 2.2
29
- NewCops: enable
30
- SuggestExtensions: false
31
- Metrics/CyclomaticComplexity:
32
- Max: 10
33
- Metrics/MethodLength:
34
- Enabled: false
35
- Layout/MultilineMethodCallIndentation:
36
- Enabled: false
37
- Metrics/AbcSize:
38
- Enabled: false
39
- Metrics/BlockLength:
40
- Max: 50
41
- Layout/EmptyLineAfterGuardClause:
42
- Enabled: false
43
- Style/ClassAndModuleChildren:
44
- Enabled: false
45
- require: []
data/.rultor.yml DELETED
@@ -1,45 +0,0 @@
1
- # (The MIT License)
2
- #
3
- # Copyright (c) 2017-2025 Yegor Bugayenko
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 all
13
- # 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 THE
21
- # SOFTWARE.
22
- ---
23
- assets:
24
- rubygems.yml: yegor256/home#assets/rubygems.yml
25
- install: |
26
- pdd -f /dev/null
27
- sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
28
- release:
29
- pre: false
30
- script: |-
31
- bundle exec rake
32
- rm -rf *.gem
33
- sed -i "s/0\.0\.0/${tag}/g" lib/xcop/version.rb
34
- git add lib/xcop/version.rb
35
- git commit -m "version set to ${tag}"
36
- gem build xcop.gemspec
37
- chmod 0600 ../rubygems.yml
38
- gem push *.gem --config-file ../rubygems.yml
39
- merge:
40
- script: |-
41
- bundle exec rake
42
- deploy:
43
- script: |-
44
- echo "There is nothing to deploy"
45
- exit -1
data/.simplecov DELETED
@@ -1,38 +0,0 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- if Gem.win_platform?
22
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
23
- SimpleCov::Formatter::HTMLFormatter
24
- ]
25
- SimpleCov.start do
26
- add_filter '/test/'
27
- add_filter '/features/'
28
- end
29
- else
30
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
31
- [SimpleCov::Formatter::HTMLFormatter]
32
- )
33
- SimpleCov.start do
34
- add_filter '/test/'
35
- add_filter '/features/'
36
- minimum_coverage 80
37
- end
38
- end
data/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "config:base"
5
- ]
6
- }
data/test/test__helper.rb DELETED
@@ -1,29 +0,0 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- $stdout.sync = true
22
-
23
- require 'simplecov-cobertura'
24
- SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
25
-
26
- require 'minitest/reporters'
27
- Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
28
-
29
- require 'minitest/autorun'
@@ -1,111 +0,0 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require 'minitest/autorun'
22
- require 'nokogiri'
23
- require 'tmpdir'
24
- require 'slop'
25
- require_relative '../lib/xcop/document'
26
-
27
- # Test for Document class.
28
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
30
- # License:: MIT
31
- class TestXcop < Minitest::Test
32
- def test_basic
33
- Dir.mktmpdir 'test1' do |dir|
34
- f = File.join(dir, 'a.xml')
35
- File.write(f, "<?xml version=\"1.0\"?>\n<hello>Dude!</hello>\n")
36
- assert_equal(Xcop::Document.new(f).diff, '')
37
- File.delete(f)
38
- end
39
- end
40
-
41
- def test_file_without_tail_eol
42
- Dir.mktmpdir 'test9' do |dir|
43
- f = File.join(dir, 'no-eol.xml')
44
- File.write(f, "<?xml version=\"1.0\"?>\n<x/>")
45
- assert(Xcop::Document.new(f).diff != '')
46
- File.delete(f)
47
- end
48
- end
49
-
50
- def test_license_presence
51
- Dir.mktmpdir 'test2' do |dir|
52
- f = File.join(dir, 'a.xml')
53
- license = " Copyright (c) All Good People\n Don't touch it!\n\n"
54
- File.write(
55
- f,
56
- [
57
- '<?xml version="1.0"?>',
58
- '<!--',
59
- ' Copyright (c) All Good People',
60
- ' Don\'t touch it!',
61
- '-->',
62
- '<hello>Dude!</hello>',
63
- ''
64
- ].join("\n")
65
- )
66
- assert_equal(Xcop::Document.new(f).ldiff(license), '')
67
- File.delete(f)
68
- end
69
- end
70
-
71
- def test_license_absence
72
- Dir.mktmpdir 'test3' do |dir|
73
- f = File.join(dir, 'a.xml')
74
- license = "Copyright (c) All Good People\nTouch me!\n\n"
75
- File.write(
76
- f,
77
- [
78
- '<?xml version="1.0"?>',
79
- '<hello>My dear friend!</hello>',
80
- ''
81
- ].join("\n")
82
- )
83
- assert(Xcop::Document.new(f).ldiff(license) != '')
84
- File.delete(f)
85
- end
86
- end
87
-
88
- def test_fixes_document
89
- Dir.mktmpdir 'test3' do |dir|
90
- f = File.join(dir, 'bad.xml')
91
- license = " Copyright (c) Me, Myself, and I\n Like it?\n\n"
92
- File.write(f, '<hello>My friend!</hello>')
93
- Xcop::Document.new(f).fix(license)
94
- assert_equal(Xcop::Document.new(f).diff, '')
95
- assert_equal(Xcop::Document.new(f).ldiff(license), '')
96
- File.delete(f)
97
- end
98
- end
99
-
100
- def test_removes_previous_license
101
- Dir.mktmpdir 'test4' do |dir|
102
- f = File.join(dir, 'bad.xml')
103
- license = "the license to add\n\n\nhey"
104
- File.write(f, '<hello>how do you do?</hello>')
105
- Xcop::Document.new(f).fix(license)
106
- Xcop::Document.new(f).fix(license)
107
- assert_equal(Nokogiri::XML(File.read(f)).xpath('/comment()').length, 1)
108
- File.delete(f)
109
- end
110
- end
111
- end
@@ -1,59 +0,0 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
20
-
21
- require 'minitest/autorun'
22
- require 'tmpdir'
23
- require 'rake'
24
- require_relative '../lib/xcop/rake_task'
25
-
26
- # Xcop rake task.
27
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
29
- # License:: MIT
30
- class TestRakeTask < Minitest::Test
31
- def test_basic
32
- Dir.mktmpdir 'test' do |dir|
33
- Dir.chdir(dir)
34
- f = File.join(dir, 'a.xml')
35
- File.write(f, "<?xml version=\"1.0\"?>\n<x/>\n")
36
- Xcop::RakeTask.new(:xcop1) do |task|
37
- task.quiet = true
38
- # task.license = 'LICENSE.txt'
39
- end
40
- Rake::Task['xcop1'].invoke
41
- File.delete(f)
42
- end
43
- end
44
-
45
- def test_with_broken_xml
46
- Dir.mktmpdir 'test' do |dir|
47
- Dir.chdir(dir)
48
- f = File.join(dir, 'broken.xml')
49
- File.write(f, "<z><a><b></b></a>\n\n</z>")
50
- Xcop::RakeTask.new(:xcop2) do |task|
51
- task.excludes = ['test/**/*']
52
- end
53
- assert_raises SystemExit do
54
- Rake::Task['xcop2'].invoke
55
- end
56
- File.delete(f)
57
- end
58
- end
59
- end