Skip to content
This repository has been archived by the owner on Dec 28, 2017. It is now read-only.

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Apr 12, 2017
2 parents 4b26cda + d654a1a commit f093c84
Show file tree
Hide file tree
Showing 20 changed files with 274 additions and 159 deletions.
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contribution Guidelines

This repository uses [GitFlow] with default configuration.
Development is happening on `develop` branch.

To contribute:

* Fork this repository.
* Create a feature branch from `develop`.
* Implement your changes.
* Push your feature branch.
* Create a pull request.

## Build

To build this package we are using Cake.

On Windows PowerShell run:

```powershell
./build
```

On OSX/Linux run:

```bash
./build.sh
```

## Release

See [Cake.Recipe documentation] how to create a new release of this addin.

[GitFlow]: (http://nvie.com/posts/a-successful-git-branching-model/)
[Cake.Recipe documentation]: https://cake-contrib.github.io/Cake.Recipe/docs/usage/creating-release
21 changes: 5 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ More about Cake at http://cakebuild.net

|Develop|Master|
|:--:|:--:|
|[![Build status](https://ci.appveyor.com/api/projects/status/xxx/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-prca-issues-inspectcode/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/xxx/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-prca-issues-inspectcode/branch/master)|
|[![Build status](https://ci.appveyor.com/api/projects/status/oofyaxwbgeajkkog/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-prca-issues-inspectcode/branch/develop)|[![Build status](https://ci.appveyor.com/api/projects/status/oofyaxwbgeajkkog/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-prca-issues-inspectcode/branch/master)|

## Code Coverage

Expand All @@ -33,20 +33,9 @@ Come join in the conversation about Cake Pull Request Code Analysis in our Gitte

[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Build
## Contributing

To build this package we are using Cake.
Contributions are welcome. See [Contribution Guidelines].

On Windows PowerShell run:

```powershell
./build
```

On OSX/Linux run:

```bash
./build.sh
```

[Cake Pull Request Code Analysis Addin]: https://github.com/cake-contrib/Cake.Prca
[Cake Pull Request Code Analysis Addin]: https://github.com/cake-contrib/Cake.Prca
[Contribution Guidelines]: CONTRIBUTING.md
6 changes: 3 additions & 3 deletions nuspec/nuget/Cake.Prca.Issues.InspectCode.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Cake.Prca.Issues.InspectCode</id>
<title>JetBrains Inspect Code support for Cake Pull Request Code Analysis</title>
<title>Cake.Prca.Issues.InspectCode</title>
<version>0.0.0</version>
<authors>BBT Software AG</authors>
<owners>bbtsoftware, pascalberger, cake-contrib</owners>
Expand All @@ -14,9 +14,9 @@
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright © 2017 BBT Software AG, Root/Zermatt, Switzerland</copyright>
<tags>Cake Script PullRequest CodeAnalysis Cake-Prca-IssueProvider Linting InspectCode</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Prca.Issues.InspectCode/releases/tag/0.2.1</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Prca.Issues.InspectCode/releases/tag/0.3.0</releaseNotes>
<dependencies>
<dependency id="Cake.Prca" version="[0.2,0.3)" />
<dependency id="Cake.Prca" version="[0.3,0.4)" />
</dependencies>
</metadata>
<files>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Cake.Prca, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Prca.0.2.1\lib\net45\Cake.Prca.dll</HintPath>
<HintPath>..\packages\Cake.Prca.0.3.0\lib\net45\Cake.Prca.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Cake.Testing, Version=0.16.2.0, Culture=neutral, processorArchitecture=MSIL">
Expand Down Expand Up @@ -78,6 +78,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ExceptionAssertExtensions.cs" />
<Compile Include="ExtensionsTests.cs" />
<Compile Include="InspectCodeProviderFixture.cs" />
<Compile Include="InspectCodeProviderTests.cs" />
<Compile Include="InspectCodeSettingsTests.cs" />
Expand Down Expand Up @@ -105,6 +106,9 @@
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Testfiles\WithWikiUrl.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand Down
63 changes: 63 additions & 0 deletions src/Cake.Prca.Issues.InspectCode.Tests/ExtensionsTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
namespace Cake.Prca.Issues.InspectCode.Tests
{
using Shouldly;
using Xunit;

public sealed class ExtensionsTests
{
public sealed class TheToUriExtension
{
[Fact]
public void Should_Throw_If_Value_Is_Null()
{
// Given
string value = null;

// When
var result = Record.Exception(() => value.ToUri());

// Then
result.IsArgumentNullException("value");
}

[Fact]
public void Should_Throw_If_Value_Is_Empty()
{
// Given
var value = string.Empty;

// When
var result = Record.Exception(() => value.ToUri());

// Then
result.IsArgumentOutOfRangeException("value");
}

[Fact]
public void Should_Throw_If_Value_Is_WhiteSpace()
{
// Given
const string value = " ";

// When
var result = Record.Exception(() => value.ToUri());

// Then
result.IsArgumentOutOfRangeException("value");
}

[Fact]
public void Should_Return_Uri()
{
// Given
const string value = "https://google.com/";

// When
var result = value.ToUri();

// Then
result.ToString().ShouldBe(value);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,39 @@ public class InspectCodeProviderFixture
{
public InspectCodeProviderFixture(string fileResourceName)
{
this.Log = new FakeLog();
this.Log.Verbosity = Verbosity.Normal;
this.Log = new FakeLog { Verbosity = Verbosity.Normal };

using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Prca.Issues.InspectCode.Tests.Testfiles." + fileResourceName))
{
using (var sr = new StreamReader(stream))
{
this.Settings =
InspectCodeSettings.FromContent(
sr.ReadToEnd(),
new Core.IO.DirectoryPath(@"c:\Source\Cake.Prca"));
sr.ReadToEnd());
}
}

this.PrcaSettings =
new ReportCodeAnalysisIssuesToPullRequestSettings(@"c:\Source\Cake.Prca");
}

public FakeLog Log { get; set; }

public InspectCodeSettings Settings { get; set; }

public ReportCodeAnalysisIssuesToPullRequestSettings PrcaSettings { get; set; }

public InspectCodeProvider Create()
{
return new InspectCodeProvider(this.Log, this.Settings);
var provider = new InspectCodeProvider(this.Log, this.Settings);
provider.Initialize(this.PrcaSettings);
return provider;
}

public IEnumerable<ICodeAnalysisIssue> ReadIssues()
{
var codeAnalysisProvider = this.Create();
return codeAnalysisProvider.ReadIssues();
return codeAnalysisProvider.ReadIssues(PrcaCommentFormat.PlainText);
}
}
}
52 changes: 47 additions & 5 deletions src/Cake.Prca.Issues.InspectCode.Tests/InspectCodeProviderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Should_Throw_If_Log_Is_Null()
var result = Record.Exception(() =>
new InspectCodeProvider(
null,
InspectCodeSettings.FromContent(@"foo", @"c:\src")));
InspectCodeSettings.FromContent(@"foo")));

// Then
result.IsArgumentNullException("log");
Expand All @@ -43,32 +43,74 @@ public void Should_Read_Issue_Correct()
var fixture = new InspectCodeProviderFixture("inspectcode.xml");

// When
var issues = fixture.ReadIssues();
var issues = fixture.ReadIssues().ToList();

// Then
issues.Count().ShouldBe(1);
issues.Count.ShouldBe(1);
var issue = issues.Single();
CheckIssue(
issue,
@"src\Cake.Prca\CakeAliasConstants.cs",
16,
"UnusedMember.Global",
null,
0,
@"Constant 'PullRequestSystemCakeAliasCategory' is never used");
}

[Fact]
public void Should_Read_Rule_Url()
{
// Given
var fixture = new InspectCodeProviderFixture("WithWikiUrl.xml");

// When
var issues = fixture.ReadIssues().ToList();

// Then
issues.Count.ShouldBe(1);
var issue = issues.Single();
CheckIssue(
issue,
@"src\Cake.CodeAnalysisReporting\CodeAnalysisReportingAliases.cs",
3,
"RedundantUsingDirective",
"http://www.jetbrains.com/resharperplatform/help?Keyword=RedundantUsingDirective",
0,
@"Using directive is not required by the code and can be safely removed");
}

private static void CheckIssue(
ICodeAnalysisIssue issue,
string affectedFileRelativePath,
int? line,
string rule,
string ruleUrl,
int priority,
string message)
{
issue.AffectedFileRelativePath.ToString().ShouldBe(new FilePath(affectedFileRelativePath).ToString());
issue.AffectedFileRelativePath.IsRelative.ShouldBe(true, "Issue path is not relative");
if (issue.AffectedFileRelativePath == null)
{
affectedFileRelativePath.ShouldBeNull();
}
else
{
issue.AffectedFileRelativePath.ToString().ShouldBe(new FilePath(affectedFileRelativePath).ToString());
issue.AffectedFileRelativePath.IsRelative.ShouldBe(true, "Issue path is not relative");
}

issue.Line.ShouldBe(line);
issue.Rule.ShouldBe(rule);

if (issue.RuleUrl == null)
{
ruleUrl.ShouldBeNull();
}
else
{
issue.RuleUrl.ToString().ShouldBe(ruleUrl);
}

issue.Priority.ShouldBe(priority);
issue.Message.ShouldBe(message);
}
Expand Down

0 comments on commit f093c84

Please sign in to comment.