danger-resharper_inspectcode 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: dfa37447f7493ff33aeda9d52528706ced6d759d810651cfb12a83dd51743a0e
4
+ data.tar.gz: 6b535695212a4ae430268ca13f037aee28e51e67221edd5bc4152b1906361bdc
5
+ SHA512:
6
+ metadata.gz: '08bc2c8c9e4806768b9f8fbfc5f2d5129d01492f320f5877c449f2be04e0073de7631a94795f4329c9104270e6759bb17c44dda48399b19b148d76cda2596265'
7
+ data.tar.gz: da1a18edca47a604a1d85f3c1548140d7ffc77662e5fc7bc8436ec5d215fd018ccbc902936a4e3960b8b0757a19e6f937d3a1e60f89be694b9fb9487b85643af
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc
5
+ Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,152 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.5
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+ Enabled: true
11
+
12
+ # kind_of? is a good way to check a type
13
+ Style/ClassCheck:
14
+ EnforcedStyle: kind_of?
15
+
16
+ # It's better to be more explicit about the type
17
+ Style/BracesAroundHashParameters:
18
+ Enabled: false
19
+
20
+ # specs sometimes have useless assignments, which is fine
21
+ Lint/UselessAssignment:
22
+ Exclude:
23
+ - '**/spec/**/*'
24
+
25
+ # We could potentially enable the 2 below:
26
+ Layout/IndentHash:
27
+ Enabled: false
28
+
29
+ Layout/AlignHash:
30
+ Enabled: false
31
+
32
+ # HoundCI doesn't like this rule
33
+ Layout/DotPosition:
34
+ Enabled: false
35
+
36
+ # We allow !! as it's an easy way to convert ot boolean
37
+ Style/DoubleNegation:
38
+ Enabled: false
39
+
40
+ # Cop supports --auto-correct.
41
+ Lint/UnusedBlockArgument:
42
+ Enabled: false
43
+
44
+ # We want to allow class Fastlane::Class
45
+ Style/ClassAndModuleChildren:
46
+ Enabled: false
47
+
48
+ Metrics/AbcSize:
49
+ Max: 60
50
+
51
+ # The %w might be confusing for new users
52
+ Style/WordArray:
53
+ MinSize: 19
54
+
55
+ # raise and fail are both okay
56
+ Style/SignalException:
57
+ Enabled: false
58
+
59
+ # Better too much 'return' than one missing
60
+ Style/RedundantReturn:
61
+ Enabled: false
62
+
63
+ # Having if in the same line might not always be good
64
+ Style/IfUnlessModifier:
65
+ Enabled: false
66
+
67
+ # and and or is okay
68
+ Style/AndOr:
69
+ Enabled: false
70
+
71
+ # Configuration parameters: CountComments.
72
+ Metrics/ClassLength:
73
+ Max: 350
74
+
75
+ Metrics/CyclomaticComplexity:
76
+ Max: 17
77
+
78
+ # Configuration parameters: AllowURI, URISchemes.
79
+ Metrics/LineLength:
80
+ Max: 400
81
+
82
+ # Configuration parameters: CountKeywordArgs.
83
+ Metrics/ParameterLists:
84
+ Max: 10
85
+
86
+ Metrics/PerceivedComplexity:
87
+ Max: 18
88
+
89
+ # Sometimes it's easier to read without guards
90
+ Style/GuardClause:
91
+ Enabled: false
92
+
93
+ # something = if something_else
94
+ # that's confusing
95
+ Style/ConditionalAssignment:
96
+ Enabled: false
97
+
98
+ # Better to have too much self than missing a self
99
+ Style/RedundantSelf:
100
+ Enabled: false
101
+
102
+ Metrics/MethodLength:
103
+ Max: 60
104
+
105
+ # We're not there yet
106
+ Style/Documentation:
107
+ Enabled: false
108
+
109
+ # Adds complexity
110
+ Style/IfInsideElse:
111
+ Enabled: false
112
+
113
+ # danger specific
114
+
115
+ Style/BlockComments:
116
+ Enabled: false
117
+
118
+ Layout/MultilineMethodCallIndentation:
119
+ EnforcedStyle: indented
120
+
121
+ # FIXME: 25
122
+ Metrics/BlockLength:
123
+ Max: 345
124
+ Exclude:
125
+ - "**/*_spec.rb"
126
+
127
+ Style/MixinGrouping:
128
+ Enabled: false
129
+
130
+ Style/FileName:
131
+ Enabled: false
132
+
133
+ Layout/IndentHeredoc:
134
+ Enabled: false
135
+
136
+ Style/SpecialGlobalVars:
137
+ Enabled: false
138
+
139
+ PercentLiteralDelimiters:
140
+ PreferredDelimiters:
141
+ "%": ()
142
+ "%i": ()
143
+ "%q": ()
144
+ "%Q": ()
145
+ "%r": "{}"
146
+ "%s": ()
147
+ "%w": ()
148
+ "%W": ()
149
+ "%x": ()
150
+
151
+ Security/YAMLLoad:
152
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.5.3
8
+
9
+ script:
10
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-resharper_inspectcode.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2018 Kazuki Oishi <oishikazuki@gmail.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # danger-resharper_inspectcode
2
+
3
+ Danger plugin for JetBrains ReSharper InspectCode.
4
+
5
+ ## Installation
6
+
7
+ PS> gem install danger-resharper_inspectcode
8
+
9
+ ## Usage
10
+ Before running Danger, you need to setup your CI service to run InspectCode Command-Line Tool to generate report XML file.
11
+ ```
12
+ PS> /PATH/TO/TOOLS/InspectCode.exe YourSolution.sln; -o=report.xml
13
+ ```
14
+
15
+ Set your report file path on `Dangerfile` like this.
16
+ ```Ruby
17
+ resharper_inspectcode.base_path = Dir.pwd
18
+ resharper_inspectcode.report 'report.xml'
19
+ ```
20
+
21
+ #### Attributes
22
+
23
+ `base_path` - Base path of report file
24
+
25
+ #### Methods
26
+
27
+ `report` - Report warnings
28
+
29
+ ## Development
30
+
31
+ 1. Clone this repo
32
+ 2. Run `bundle install` to setup dependencies.
33
+ 3. Run `bundle exec rake spec` to run the tests.
34
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
35
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "resharper_inspectcode/gem_version.rb"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "danger-resharper_inspectcode"
9
+ spec.version = ResharperInspectcode::VERSION
10
+ spec.authors = ["tumugin"]
11
+ spec.email = ["tumugin@users.noreply.github.com"]
12
+ spec.summary = "Danger plugin for JetBrains ReSharper InspectCode."
13
+ spec.homepage = "https://github.com/tumugin/danger-resharper_inspectcode"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "danger-plugin-api", "~> 1.0"
22
+ spec.add_runtime_dependency "oga", "~> 2.15"
23
+
24
+ # General ruby development
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+
28
+ # Testing support
29
+ spec.add_development_dependency "rspec", "~> 3.4"
30
+
31
+ # Linting code and docs
32
+ spec.add_development_dependency "rubocop"
33
+ spec.add_development_dependency "yard"
34
+
35
+ # Makes testing easy via `bundle exec guard`
36
+ spec.add_development_dependency "guard", "~> 2.14"
37
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
38
+
39
+ # If you want to work on older builds of ruby
40
+ spec.add_development_dependency "listen", "3.0.7"
41
+
42
+ # This gives you the chance to run a REPL inside your tests
43
+ # via:
44
+ #
45
+ # require 'pry'
46
+ # binding.pry
47
+ #
48
+ # This will stop test execution and let you inspect the results
49
+ spec.add_development_dependency "pry"
50
+ end
@@ -0,0 +1 @@
1
+ require "resharper_inspectcode/plugin"
@@ -0,0 +1 @@
1
+ require "resharper_inspectcode/gem_version"
@@ -0,0 +1,3 @@
1
+ module ResharperInspectcode
2
+ VERSION = "1.0.0".freeze
3
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "report_parser"
4
+
5
+ module Danger
6
+ # Danger plugin for JetBrains ReSharper InspectCode.
7
+ # @example Parse the report XML file and do reporting
8
+ # resharper_inspectcode.base_path = Dir.pwd
9
+ # resharper_inspectcode.report 'report.xml'
10
+ # @see tumugin/danger-resharper_inspectcode
11
+ # @tags C#, InspectCode, lint
12
+ class DangerResharperInspectcode < Plugin
13
+ # Base path of report file
14
+ #
15
+ # @return [String]
16
+ attr_accessor :base_path
17
+
18
+ # Report warnings
19
+ # @param file [String] File path of ReSharper InspectCode report file
20
+ def report(file)
21
+ raise "Please specify file name." if file.empty?
22
+ raise "No report file was found at #{file}" if File.exist?(file)
23
+
24
+ filepath = @base_path + (@base_path.end_with?("/") ? "" : "/") + file
25
+ issues = ReportParser.parse_report_xml(filepath)
26
+ issues.each do |issue|
27
+ warn(issue.message, file: issue.file, line: issue.line)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "oga"
4
+
5
+ Issue = Struct.new(:file, :offset, :line, :message)
6
+
7
+ class ReportParser
8
+ def self.parse_report_xml(filepath)
9
+ xml_file = open(filepath)
10
+ document = Oga.parse_xml(xml_file)
11
+ issues = []
12
+ document.xpath("//Report/Issues/Project").each do |project|
13
+ project.children.each do |issue|
14
+ next unless issue.kind_of?(Oga::XML::Element)
15
+
16
+ file = issue.get("File").tr("\\", "/")
17
+ offset = issue.get("Offset")
18
+ line = (issue.get("Line") || "1").to_i
19
+ message = issue.get("Message")
20
+ issues << Issue.new(file, offset, line, message)
21
+ end
22
+ end
23
+ return issues
24
+ end
25
+ end
@@ -0,0 +1,81 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generated by JetBrains Inspect Code 2018.2.3 -->
3
+ <Report ToolsVersion="182.0.20180912.160234">
4
+ <Information>
5
+ <Solution>Hoge.sln</Solution>
6
+ <InspectionScope>
7
+ <Element>Solution</Element>
8
+ </InspectionScope>
9
+ </Information>
10
+ <IssueTypes>
11
+ <IssueType Id="AccessToStaticMemberViaDerivedType" Category="Common Practices and Code Improvements" CategoryId="BestPractice" Description="Access to a static member of a type via a derived type" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=AccessToStaticMemberViaDerivedType" />
12
+ <IssueType Id="ArrangeAccessorOwnerBody" Category="Code Style" CategoryId="CodeStyleIssues" SubCategory="Use preferred body style" Description="Use preferred body style: Convert to property, indexer or event with preferred body style" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ArrangeAccessorOwnerBody" />
13
+ <IssueType Id="ArrangeStaticMemberQualifier" Category="Code Style" CategoryId="CodeStyleIssues" Description="Add/remove qualifier for static members" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ArrangeStaticMemberQualifier" />
14
+ <IssueType Id="ArrangeThisQualifier" Category="Code Style" CategoryId="CodeStyleIssues" Description="Add/remove 'this.' qualifier" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ArrangeThisQualifier" />
15
+ <IssueType Id="AssignNullToNotNullAttribute" Category="Constraints Violations" CategoryId="ConstraintViolation" Description="Possible 'null' assignment to entity with '[NotNull]' attribute" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=AssignNullToNotNullAttribute" />
16
+ <IssueType Id="AutoPropertyCanBeMadeGetOnly.Global" Category="Common Practices and Code Improvements" CategoryId="BestPractice" SubCategory="Auto-property can be made get-only" Description="Auto-property can be made get-only: Non-private accessibility" Severity="SUGGESTION" Global="True" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=AutoPropertyCanBeMadeGetOnly.Global" />
17
+ <IssueType Id="AutoPropertyCanBeMadeGetOnly.Local" Category="Common Practices and Code Improvements" CategoryId="BestPractice" SubCategory="Auto-property can be made get-only" Description="Auto-property can be made get-only: Private accessibility" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=AutoPropertyCanBeMadeGetOnly.Local" />
18
+ <IssueType Id="CSharpErrors" Category="C# Compiler Errors" CategoryId="CSharpErrors" Description="" Severity="ERROR" />
19
+ <IssueType Id="CheckNamespace" Category="Constraints Violations" CategoryId="ConstraintViolation" Description="Namespace does not correspond to file location" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=CheckNamespace" />
20
+ <IssueType Id="ClassNeverInstantiated.Global" Category="Potential Code Quality Issues" CategoryId="CodeSmell" SubCategory="Class is never instantiated" Description="Class is never instantiated: Non-private accessibility" Severity="SUGGESTION" Global="True" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ClassNeverInstantiated.Global" />
21
+ <IssueType Id="ClassWithVirtualMembersNeverInherited.Global" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" SubCategory="Class with virtual(overridable) members never inherited" Description="Class with virtual(overridable) members never inherited: Non-private accessibility" Severity="SUGGESTION" Global="True" />
22
+ <IssueType Id="CompareOfFloatsByEqualityOperator" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Equality comparison of floating point numbers" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=CompareOfFloatsByEqualityOperator" />
23
+ <IssueType Id="ConditionIsAlwaysTrueOrFalse" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Expression is always 'true' or always 'false'" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ConditionIsAlwaysTrueOrFalse" />
24
+ <IssueType Id="ConstantConditionalAccessQualifier" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Conditional access qualifier expression is known to be null or not null" Severity="WARNING" />
25
+ <IssueType Id="ConstantNullCoalescingCondition" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="'??' condition is known to be null or not null" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ConstantNullCoalescingCondition" />
26
+ <IssueType Id="ConvertIfStatementToConditionalTernaryExpression" Category="Language Usage Opportunities" CategoryId="LanguageUsage" Description="'if' statement can be re-written as '?:' expression" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=ConvertIfStatementToConditionalTernaryExpression" />
27
+ <IssueType Id="EmptyConstructor" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" Description="Empty constructor" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=EmptyConstructor" />
28
+ <IssueType Id="EmptyGeneralCatchClause" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Empty general catch clause" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=EmptyGeneralCatchClause" />
29
+ <IssueType Id="EmptyNamespace" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" Description="Empty namespace declaration" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=EmptyNamespace" />
30
+ <IssueType Id="FieldCanBeMadeReadOnly.Global" Category="Common Practices and Code Improvements" CategoryId="BestPractice" SubCategory="Field can be made readonly" Description="Field can be made readonly: Non-private accessibility" Severity="SUGGESTION" Global="True" />
31
+ <IssueType Id="FieldCanBeMadeReadOnly.Local" Category="Common Practices and Code Improvements" CategoryId="BestPractice" SubCategory="Field can be made readonly" Description="Field can be made readonly: Private accessibility" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=FieldCanBeMadeReadOnly.Local" />
32
+ <IssueType Id="InconsistentNaming" Category="Constraints Violations" CategoryId="ConstraintViolation" Description="Inconsistent Naming" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=InconsistentNaming" />
33
+ <IssueType Id="LocalizableElement" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Element is localizable" Severity="WARNING" />
34
+ <IssueType Id="MemberCanBePrivate.Global" Category="Common Practices and Code Improvements" CategoryId="BestPractice" SubCategory="Member can be made private" Description="Member can be made private: Non-private accessibility" Severity="SUGGESTION" Global="True" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=MemberCanBePrivate.Global" />
35
+ <IssueType Id="MemberCanBeProtected.Global" Category="Common Practices and Code Improvements" CategoryId="BestPractice" SubCategory="Member can be made protected" Description="Member can be made protected: Non-private accessibility" Severity="SUGGESTION" Global="True" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=MemberCanBeProtected.Global" />
36
+ <IssueType Id="MemberHidesStaticFromOuterClass" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Member hides static member from outer class" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=MemberHidesStaticFromOuterClass" />
37
+ <IssueType Id="MergeCastWithTypeCheck" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Type check and casts can be merged" Severity="SUGGESTION" />
38
+ <IssueType Id="MergeSequentialChecks" Category="Language Usage Opportunities" CategoryId="LanguageUsage" Description="Merge sequential checks in &amp;&amp; or || expressions" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=MergeSequentialChecks" />
39
+ <IssueType Id="NotAccessedField.Global" Category="Potential Code Quality Issues" CategoryId="CodeSmell" SubCategory="Non-accessed field" Description="Non-accessed field: Non-private accessibility" Severity="SUGGESTION" Global="True" />
40
+ <IssueType Id="ObjectCreationAsStatement" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Possible unassigned object created by 'new' expression" Severity="WARNING" />
41
+ <IssueType Id="PossibleInvalidCastExceptionInForeachLoop" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Possible 'System.InvalidCastException' in foreach loop" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=PossibleInvalidCastExceptionInForeachLoop" />
42
+ <IssueType Id="PossibleInvalidOperationException" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Possible 'System.InvalidOperationException'" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=PossibleInvalidOperationException" />
43
+ <IssueType Id="PossibleNullReferenceException" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Possible 'System.NullReferenceException'" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=PossibleNullReferenceException" />
44
+ <IssueType Id="RedundantAssignment" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Assignment is not used" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantAssignment" />
45
+ <IssueType Id="RedundantCast" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant cast" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantCast" />
46
+ <IssueType Id="RedundantDefaultMemberInitializer" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" Description="Redundant member initializer" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantDefaultMemberInitializer" />
47
+ <IssueType Id="RedundantExplicitArrayCreation" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant explicit type in array creation" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantExplicitArrayCreation" />
48
+ <IssueType Id="RedundantExtendsListEntry" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" Description="Redundant class or interface specification in base types list" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantExtendsListEntry" />
49
+ <IssueType Id="RedundantNameQualifier" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant name qualifier" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantNameQualifier" />
50
+ <IssueType Id="RedundantStringInterpolation" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant string interpolation" Severity="SUGGESTION" />
51
+ <IssueType Id="RedundantUsingDirective" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant using directive" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=RedundantUsingDirective" />
52
+ <IssueType Id="UnassignedField.Global" Category="Potential Code Quality Issues" CategoryId="CodeSmell" SubCategory="Unassigned field" Description="Unassigned field: Non-private accessibility" Severity="SUGGESTION" Global="True" />
53
+ <IssueType Id="UnusedAutoPropertyAccessor.Global" Category="Potential Code Quality Issues" CategoryId="CodeSmell" SubCategory="Auto-property accessor is never used" Description="Auto-property accessor is never used: Non-private accessibility" Severity="WARNING" Global="True" />
54
+ <IssueType Id="UnusedMember.Global" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" SubCategory="Type or member is never used" Description="Type or member is never used: Non-private accessibility" Severity="SUGGESTION" Global="True" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=UnusedMember.Global" />
55
+ <IssueType Id="UnusedMember.Local" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" SubCategory="Type or member is never used" Description="Type or member is never used: Private accessibility" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=UnusedMember.Local" />
56
+ <IssueType Id="UnusedParameter.Global" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" SubCategory="Unused parameter" Description="Unused parameter: Non-private accessibility" Severity="SUGGESTION" Global="True" />
57
+ <IssueType Id="UnusedVariable" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" Description="Unused local variable" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=UnusedVariable" />
58
+ <IssueType Id="UseCollectionCountProperty" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Use collection's count property" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=UseCollectionCountProperty" />
59
+ <IssueType Id="UseMethodAny.0" Category="Common Practices and Code Improvements" CategoryId="BestPractice" SubCategory="Use method Any()" Description="Use method Any(): Use method Any()" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=UseMethodAny.0" />
60
+ <IssueType Id="UseObjectOrCollectionInitializer" Category="Language Usage Opportunities" CategoryId="LanguageUsage" Description="Use object or collection initializer when possible" Severity="SUGGESTION" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=UseObjectOrCollectionInitializer" />
61
+ <IssueType Id="UsePatternMatching" Category="Language Usage Opportunities" CategoryId="LanguageUsage" Description="Convert 'as' expression type check and the following null check into pattern matching" Severity="SUGGESTION" />
62
+ <IssueType Id="VirtualMemberCallInConstructor" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Virtual member call in constructor" Severity="WARNING" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=VirtualMemberCallInConstructor" />
63
+ <IssueType Id="VirtualMemberNeverOverridden.Global" Category="Redundancies in Symbol Declarations" CategoryId="DeclarationRedundancy" SubCategory="Virtual(overridable) member is never overridden" Description="Virtual(overridable) member is never overridden: Non-private accessibility" Severity="SUGGESTION" Global="True" WikiUrl="https://www.jetbrains.com/resharperplatform/help?Keyword=VirtualMemberNeverOverridden.Global" />
64
+ <IssueType Id="XAMLErrors" Category="XAML Errors" CategoryId="XAMLErrors" Description="" Severity="ERROR" />
65
+ <IssueType Id="Xaml.BindingWithContextNotResolved" Category="Code Notification" CategoryId="CodeInfo" Description="Unresolved binding path when DataContext is known" Severity="WARNING" />
66
+ <IssueType Id="Xaml.MissingGridIndex" Category="Potential Code Quality Issues" CategoryId="CodeSmell" Description="Missing grid column/row setter for non-first child" Severity="WARNING" />
67
+ <IssueType Id="Xaml.RedundantAttachedProperty" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Remove redundant attached property setter" Severity="WARNING" />
68
+ <IssueType Id="Xaml.RedundantNamespaceAlias" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant namespace alias" Severity="WARNING" />
69
+ <IssueType Id="Xaml.RedundantResource" Category="Redundancies in Code" CategoryId="CodeRedundancy" Description="Redundant resource" Severity="WARNING" />
70
+ </IssueTypes>
71
+ <Issues>
72
+ <Project Name="MatsuriHime">
73
+ <Issue TypeId="RedundantUsingDirective" File="MatsuriHime\Ho.cs" Offset="14-47" Line="2" Message="Matsuri Hime is very cute." />
74
+ <Issue TypeId="RedundantUsingDirective" File="MatsuriHime\NanoDesu.cs" Offset="16-47" Line="3" Message="Matsuri only eats sweet and fluffy things." />
75
+ </Project>
76
+ <Project Name="Tsumugi">
77
+ <Issue TypeId="RedundantUsingDirective" File="Tsumugi\Nanyaine.cs" Offset="18-47" Message="Nanyaine, is this!?" />
78
+ <Issue TypeId="RedundantUsingDirective" File="Tsumugi\Anmitsu.cs" Offset="19-47" Line="2" Message="Tsumugi usually forgive anything when you treat Anmitsu." />
79
+ </Project>
80
+ </Issues>
81
+ </Report>
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("spec_helper", __dir__)
4
+
5
+ module Danger
6
+ describe Danger::DangerResharperInspectcode do
7
+ it "should be a plugin" do
8
+ expect(Danger::DangerResharperInspectcode.new(nil)).to be_a Danger::Plugin
9
+ end
10
+
11
+ describe "Report Parser Test" do
12
+ before do
13
+ require_relative "../lib/resharper_inspectcode/report_parser"
14
+ end
15
+
16
+ it "Parse report.xml" do
17
+ report = ReportParser.parse_report_xml("spec/fixtures/report.xml")
18
+ expect(report.first).to(
19
+ eq Issue.new("MatsuriHime/Ho.cs", "14-47", 2, "Matsuri Hime is very cute.")
20
+ )
21
+ expect(report.select { |item| item.file == "Tsumugi/Nanyaine.cs" }.first).to(
22
+ eq Issue.new("Tsumugi/Nanyaine.cs", "18-47", 1, "Nanyaine, is this!?")
23
+ )
24
+ end
25
+ end
26
+
27
+ describe "with Dangerfile" do
28
+ before do
29
+ @dangerfile = testing_dangerfile
30
+ @my_plugin = @dangerfile.resharper_inspectcode
31
+ end
32
+
33
+ it "Parse XML report file with plugin" do
34
+ @my_plugin.base_path = __dir__
35
+ @my_plugin.report("fixtures/report.xml")
36
+ expect(@my_plugin.violation_report[:warnings][0]).to(
37
+ eq Violation.new("Matsuri Hime is very cute.", false, "MatsuriHime/Ho.cs", 2)
38
+ )
39
+ expect(@my_plugin.violation_report[:warnings][2]).to(
40
+ eq Violation.new("Nanyaine, is this!?", false, "Tsumugi/Nanyaine.cs", 1)
41
+ )
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,65 @@
1
+ require "pathname"
2
+ ROOT = Pathname.new(File.expand_path("../../", __FILE__))
3
+ $:.unshift((ROOT + "lib").to_s)
4
+ $:.unshift((ROOT + "spec").to_s)
5
+
6
+ require "bundler/setup"
7
+ require "pry"
8
+
9
+ require "rspec"
10
+ require "danger"
11
+
12
+ if `git remote -v` == ''
13
+ puts "You cannot run tests without setting a local git remote on this repo"
14
+ puts "It's a weird side-effect of Danger's internals."
15
+ exit(0)
16
+ end
17
+
18
+ # Use coloured output, it's the best.
19
+ RSpec.configure do |config|
20
+ config.filter_gems_from_backtrace "bundler"
21
+ config.color = true
22
+ config.tty = true
23
+ end
24
+
25
+ require "danger_plugin"
26
+
27
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
28
+ # If you are expanding these files, see if it's already been done ^.
29
+
30
+ # A silent version of the user interface,
31
+ # it comes with an extra function `.string` which will
32
+ # strip all ANSI colours from the string.
33
+
34
+ # rubocop:disable Lint/NestedMethodDefinition
35
+ def testing_ui
36
+ @output = StringIO.new
37
+ def @output.winsize
38
+ [20, 9999]
39
+ end
40
+
41
+ cork = Cork::Board.new(out: @output)
42
+ def cork.string
43
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
44
+ end
45
+ cork
46
+ end
47
+ # rubocop:enable Lint/NestedMethodDefinition
48
+
49
+ # Example environment (ENV) that would come from
50
+ # running a PR on TravisCI
51
+ def testing_env
52
+ {
53
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
54
+ "TRAVIS_PULL_REQUEST" => "800",
55
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
56
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
57
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
58
+ }
59
+ end
60
+
61
+ # A stubbed out Dangerfile for use in tests
62
+ def testing_dangerfile
63
+ env = Danger::EnvironmentManager.new(testing_env)
64
+ Danger::Dangerfile.new(env, testing_ui)
65
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-resharper_inspectcode
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - tumugin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: oga
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.15'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.14'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.14'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '4.7'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '4.7'
139
+ - !ruby/object:Gem::Dependency
140
+ name: listen
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 3.0.7
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 3.0.7
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description:
168
+ email:
169
+ - tumugin@users.noreply.github.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rubocop.yml"
176
+ - ".travis.yml"
177
+ - Gemfile
178
+ - Guardfile
179
+ - LICENSE.txt
180
+ - README.md
181
+ - Rakefile
182
+ - danger-resharper_inspectcode.gemspec
183
+ - lib/danger_plugin.rb
184
+ - lib/danger_resharper_inspectcode.rb
185
+ - lib/resharper_inspectcode/gem_version.rb
186
+ - lib/resharper_inspectcode/plugin.rb
187
+ - lib/resharper_inspectcode/report_parser.rb
188
+ - spec/fixtures/report.xml
189
+ - spec/resharper_inspectcode_spec.rb
190
+ - spec/spec_helper.rb
191
+ homepage: https://github.com/tumugin/danger-resharper_inspectcode
192
+ licenses:
193
+ - MIT
194
+ metadata: {}
195
+ post_install_message:
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project:
211
+ rubygems_version: 2.7.6
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Danger plugin for JetBrains ReSharper InspectCode.
215
+ test_files:
216
+ - spec/fixtures/report.xml
217
+ - spec/resharper_inspectcode_spec.rb
218
+ - spec/spec_helper.rb