Skip to content

Commit

Permalink
Merge pull request #68 from guibranco/guibranco-patch-1
Browse files Browse the repository at this point in the history
Update issue templates
  • Loading branch information
guibranco committed Jul 24, 2023
2 parents 4bfd088 + b3ec3a7 commit f736144
Show file tree
Hide file tree
Showing 17 changed files with 317 additions and 70 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.25.0",
"commands": [
"dotnet-csharpier"
]
}
}
}
8 changes: 8 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version = 1

[[analyzers]]
name = "csharp"

[[analyzers]]
name = "test-coverage"
enabled = true
18 changes: 18 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
LC_ALL=C

local_branch="$(git rev-parse --abbrev-ref HEAD)"

valid_branch_regex="^(feature|fix|docs|style|refactor|perf|hotfix|test|chore|create)\/[a-zA-Z0-9._-]+$"

message="There is something wrong with your branch name. Branch names in this project must adhere to this contract: $valid_branch_regex. Your commit will be rejected. You should rename your branch to a valid name and try again."

if [[ ! $local_branch =~ $valid_branch_regex ]]
then
echo "$message"
exit 1
fi

dotnet tool restore

dotnet csharpier . --check
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**

* OS: \[e.g. iOS]
* Browser \[e.g. chrome, safari]
* Version \[e.g. 22]

**Smartphone (please complete the following information):**

* Device: \[e.g. iPhone6]
* OS: \[e.g. iOS8.1]
* Browser \[e.g. stock browser, safari]
* Version \[e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when (...)

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
30 changes: 21 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
version: 2

updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10


- package-ecosystem: "nuget"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10

open-pull-requests-limit: 50
assignees:
- "guibranco"
reviewers:
- "guibranco"
labels:
- "nuget"
- "packages"
- ".NET"
- "dependencies"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
open-pull-requests-limit: 50
assignees:
- "guibranco"
reviewers:
- "guibranco"
labels:
- "github-actions"
- "dependencies"
45 changes: 45 additions & 0 deletions .github/workflows/deep-source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deep Source

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
pull_request_target:
types: [opened, synchronize, reopened]

jobs:
DeepSource:
name: Deep Source Coverage report
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install DeepSource scanner
run: curl https://deepsource.io/cli | sh

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'

- name: Build and analyze
if: >-
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) || (
github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository
) || (
github.event_name == 'workflow_dispatch'
)
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
run: |
dotnet build -c Debug --verbosity minimal
dotnet test -c Debug --verbosity minimal --no-build --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat="cobertura"
./bin/deepsource report --analyzer test-coverage --key csharp --value-file ./Tests/ViaCep.Tests/coverage.cobertura.xml
24 changes: 24 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Linter check

on:
workflow_dispatch:
pull_request:

jobs:
linter-check:
runs-on: ubuntu-latest
steps:

- name: Checkout repo
uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3

- name: Dotnet restore
run: dotnet tool restore

- name: CSharpier format check
run: |
dotnet csharpier . --check
echo "run 'dotnet build' to fix the formatting of the code automatically"
11 changes: 11 additions & 0 deletions .github/workflows/size-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Label based on PR size

on:
pull_request:
pull_request_target:
workflow_dispatch:

jobs:
Expand All @@ -12,6 +13,16 @@ jobs:
steps:

- name: size-label
if: >-
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) || (
github.event_name == 'pull_request_target' &&
github.event.pull_request.head.repo.full_name != github.repository
) || (
github.event_name == 'workflow_dispatch'
)
uses: "pascalgn/[email protected]"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,32 @@ A .NET client wrapper for both .NET Core & .NET Framework projects of [Via CEP A

| Build status | Last commit | Tests | Coverage | Code Smells | LOC |
|--------------|-------------|-------|----------|-------------|-----|
| [![Build status](https://ci.appveyor.com/api/projects/status/9jnsy1e08jhyxl7j/branch/main?svg=true)](https://ci.appveyor.com/project/guibranco/ViaCEP) | [![GitHub last commit](https://img.shields.io/github/last-commit/guibranco/ViaCEP/main)](https://github.com/guibranco/ViaCEP) | [![AppVeyor tests (branch)](https://img.shields.io/appveyor/tests/guibranco/ViaCEP/main?compact_message)](https://ci.appveyor.com/project/guibranco/ViaCEP) | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=coverage)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=code_smells)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) | [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=ncloc)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
| [![Build status](https://ci.appveyor.com/api/projects/status/9jnsy1e08jhyxl7j/branch/main?svg=true)](https://ci.appveyor.com/project/guibranco/ViaCEP) | [![GitHub last commit](https://img.shields.io/github/last-commit/guibranco/ViaCEP/main)](https://github.com/guibranco/ViaCEP) | [![AppVeyor tests (branch)](https://img.shields.io/appveyor/tests/guibranco/ViaCEP/main?compact_message)](https://ci.appveyor.com/project/guibranco/ViaCEP) | [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=coverage)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) | [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=code_smells)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP) | [![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=ncloc)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)

## Code Quality

[![Codacy Badge](https://app.codacy.com/project/badge/Grade/483c4901f0ea4a0d99e69be931ced362)](https://www.codacy.com/gh/guibranco/ViaCEP/dashboard?utm_source=github.com&utm_medium=referral&utm_content=guibranco/ViaCEP&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/483c4901f0ea4a0d99e69be931ced362)](https://www.codacy.com/gh/guibranco/ViaCEP/dashboard?utm_source=github.com&utm_medium=referral&utm_content=guibranco/ViaCEP&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/483c4901f0ea4a0d99e69be931ced362)](https://www.codacy.com/gh/guibranco/ViaCEP/dashboard?utm_source=github.com\&utm_medium=referral\&utm_content=guibranco/ViaCEP\&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/483c4901f0ea4a0d99e69be931ced362)](https://www.codacy.com/gh/guibranco/ViaCEP/dashboard?utm_source=github.com\&utm_medium=referral\&utm_content=guibranco/ViaCEP\&utm_campaign=Badge_Grade)

[![codecov](https://codecov.io/gh/guibranco/ViaCEP/branch/main/graph/badge.svg)](https://codecov.io/gh/guibranco/ViaCEP)
[![CodeFactor](https://www.codefactor.io/repository/github/guibranco/ViaCEP/badge)](https://www.codefactor.io/repository/github/guibranco/ViaCEP)

[![Maintainability](https://api.codeclimate.com/v1/badges/93ba8c7ae3e86ca7e2a7/maintainability)](https://codeclimate.com/github/guibranco/ViaCEP/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/93ba8c7ae3e86ca7e2a7/test_coverage)](https://codeclimate.com/github/guibranco/ViaCEP/test_coverage)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=alert_status)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=alert_status)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)

[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=sqale_index)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=sqale_index)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)

[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=security_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=security_rating)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)

[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=bugs)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=bugs)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=guibranco_ViaCEP\&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=guibranco_ViaCEP)

[![DeepSource](https://app.deepsource.com/gh/guibranco/ViaCEP.svg/?label=active+issues\&show_trend=true\&token=84Hhxk-J1hIHiVC_ojm17J3q)](https://app.deepsource.com/gh/guibranco/ViaCEP/?ref=repository-badge)

---

Expand All @@ -58,8 +60,8 @@ Download the latest zip file from the [Release](https://github.com/GuiBranco/Via

The package has two classes:

- [ViaCepClient](https://github.com/guibranco/ViaCEP/blob/main/ViaCEP/ViaCepClient.cs): The main class (methods).
- [ViaCepResult](https://github.com/guibranco/ViaCEP/blob/main/ViaCEP/ViaCepResult.cs): The result class (data).
* [ViaCepClient](https://github.com/guibranco/ViaCEP/blob/main/ViaCEP/ViaCepClient.cs): The main class (methods).
* [ViaCepResult](https://github.com/guibranco/ViaCEP/blob/main/ViaCEP/ViaCepResult.cs): The result class (data).

This package is fully compatible with Dependency Injection. Use the interface *IViaCepClient* and the constructor with HttpClient parameter with a IHttpClientFactory instance.

Expand Down Expand Up @@ -97,6 +99,6 @@ foreach(var result in results){

## Changelog

- 2023-03-03: Update dependencies, change branch name, update logo. [@guibranco](https://github.com/guibranco)
- 2021-06-21: Update dependencies version. [@guibranco](https://github.com/guibranco)
- 2020-10-23: Add support to .NET Standard 2.0 and .NET Framework v4.6.1 and above. [@guibranco](https://github.com/guibranco)
* 2023-03-03: Update dependencies, change branch name, update logo. [@guibranco](https://github.com/guibranco)
* 2021-06-21: Update dependencies version. [@guibranco](https://github.com/guibranco)
* 2020-10-23: Add support to .NET Standard 2.0 and .NET Framework v4.6.1 and above. [@guibranco](https://github.com/guibranco)
7 changes: 6 additions & 1 deletion Src/ViaCep/IViaCepClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public interface IViaCepClient
/// <param name="address">The address.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task<IEnumerable<ViaCepResult>> SearchAsync(string stateInitials, string city, string address, CancellationToken cancellationToken);
Task<IEnumerable<ViaCepResult>> SearchAsync(
string stateInitials,
string city,
string address,
CancellationToken cancellationToken
);
}
}
27 changes: 21 additions & 6 deletions Src/ViaCep/ViaCepClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,18 @@ public IEnumerable<ViaCepResult> Search(string stateInitials, string city, strin
/// <param name="zipCode">The zip code.</param>
/// <param name="cancellationToken">The token.</param>
/// <returns></returns>
public async Task<ViaCepResult> SearchAsync(string zipCode, CancellationToken cancellationToken)
public async Task<ViaCepResult> SearchAsync(
string zipCode,
CancellationToken cancellationToken
)
{
var response = await _httpClient.GetAsync($"/ws/{zipCode}/json", cancellationToken).ConfigureAwait(false);
var response = await _httpClient
.GetAsync($"/ws/{zipCode}/json", cancellationToken)
.ConfigureAwait(false);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsAsync<ViaCepResult>(cancellationToken).ConfigureAwait(false);
return await response.Content
.ReadAsAsync<ViaCepResult>(cancellationToken)
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -93,11 +100,19 @@ public async Task<ViaCepResult> SearchAsync(string zipCode, CancellationToken ca
/// <param name="cancellationToken">The token.</param>
/// <returns></returns>
public async Task<IEnumerable<ViaCepResult>> SearchAsync(
string stateInitials, string city, string address, CancellationToken cancellationToken)
string stateInitials,
string city,
string address,
CancellationToken cancellationToken
)
{
var response = await _httpClient.GetAsync($"/ws/{stateInitials}/{city}/{address}/json", cancellationToken).ConfigureAwait(false);
var response = await _httpClient
.GetAsync($"/ws/{stateInitials}/{city}/{address}/json", cancellationToken)
.ConfigureAwait(false);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsAsync<List<ViaCepResult>>(cancellationToken).ConfigureAwait(false);
return await response.Content
.ReadAsAsync<List<ViaCepResult>>(cancellationToken)
.ConfigureAwait(false);
}

#endregion
Expand Down
Loading

0 comments on commit f736144

Please sign in to comment.