Skip to content

Commit

Permalink
Technical/Increase project code quality (#60)
Browse files Browse the repository at this point in the history
* Added cspell
* Changed mdlrc to markdownlint
* Updated lefthook, yamlint configs
* Updated rubocop/codeclimate/circleci configs
* Fixed linters issues
* Updated gemspecs, gem version
  • Loading branch information
bestwebua committed Dec 11, 2022
1 parent bdf6806 commit eb11fe4
Show file tree
Hide file tree
Showing 16 changed files with 118 additions and 56 deletions.
31 changes: 14 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,16 @@ references:
command: |
bundle exec smtp_mock -s -i ~
install_yamllint: &install_yamllint
install_linters: &install_linters
run:
name: Installing Yamllint
command: |
sudo apt-get update -y
sudo apt-get install -y yamllint
install_lefthook: &install_lefthook
run:
name: Installing Lefthook
name: Installing bunch of linters
command: |
curl -1sLf 'https://dl.cloudsmith.io/public/evilmartians/lefthook/setup.deb.sh' | sudo -E bash
sudo apt-get install -y lefthook
sudo apt-get update -y
sudo apt-get install -y lefthook shellcheck yamllint
npm install --prefix='~/.local' --global --save-dev git+https://github.com/streetsidesoftware/cspell-cli markdownlint-cli
cp .circleci/linter_configs/.fasterer.yml .fasterer.yml
cp .circleci/linter_configs/.lefthook.yml lefthook.yml
install_codeclimate_reporter: &install_codeclimate_reporter
run:
Expand Down Expand Up @@ -83,24 +80,24 @@ jobs:
- <<: *restore_bundle_cache
- <<: *bundle_install
- <<: *save_bundle_cache
- <<: *install_yamllint
- <<: *install_lefthook
- <<: *install_linters

- run:
name: Running code style linters
command: lefthook run code-style-linters

- run:
name: Running code performance linters
command: |
cp .circleci/linter_configs/.fasterer.yml .fasterer.yml
lefthook run code-performance-linters
rm .fasterer.yml
command: lefthook run code-performance-linters

- run:
name: Running code vulnerability linters
command: lefthook run code-vulnerability-linters

- run:
name: Running code documentation linters
command: lefthook run code-documentation-linters

tests-ruby:
parameters:
ruby-version:
Expand Down Expand Up @@ -186,7 +183,7 @@ workflows:
- linters-ruby:
matrix:
parameters:
ruby-version: ["3.1"]
ruby-version: ["3.1-node"]
- tests-ruby:
matrix:
parameters:
Expand Down
2 changes: 1 addition & 1 deletion .circleci/gemspecs/compatible
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
spec.authors = ['Vladislav Trotsenko']
spec.email = %w[[email protected]]
spec.summary = %(smtp_mock)
spec.description = %(💎 Ruby SMTP mock. Mimic any SMTP server behaviour for your test environment.)
spec.description = %(💎 Ruby SMTP mock. Mimic any SMTP server behavior for your test environment.)
spec.homepage = 'https://github.com/mocktools/ruby-smtp-mock'
spec.license = 'MIT'

Expand Down
5 changes: 2 additions & 3 deletions .circleci/gemspecs/latest
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
spec.authors = ['Vladislav Trotsenko']
spec.email = %w[[email protected]]
spec.summary = %(smtp_mock)
spec.description = %(💎 Ruby SMTP mock. Mimic any SMTP server behaviour for your test environment.)
spec.description = %(💎 Ruby SMTP mock. Mimic any SMTP server behavior for your test environment.)
spec.homepage = 'https://github.com/mocktools/ruby-smtp-mock'
spec.license = 'MIT'

Expand All @@ -22,13 +22,12 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'bundler-audit', '~> 0.9.1'
spec.add_development_dependency 'fasterer', '~> 0.10.0'
spec.add_development_dependency 'ffaker', '~> 2.21'
spec.add_development_dependency 'mdl', '~> 0.12.0'
spec.add_development_dependency 'net-smtp', '~> 0.3.3'
spec.add_development_dependency 'pry-byebug', '~> 3.10', '>= 3.10.1'
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
spec.add_development_dependency 'reek', '~> 6.1', '>= 6.1.1'
spec.add_development_dependency 'rspec', '~> 3.12'
spec.add_development_dependency 'rubocop', '~> 1.39'
spec.add_development_dependency 'rubocop', '~> 1.40'
spec.add_development_dependency 'rubocop-performance', '~> 1.15', '>= 1.15.1'
spec.add_development_dependency 'rubocop-rspec', '~> 2.15'
spec.add_development_dependency 'simplecov', '~> 0.21.2'
Expand Down
29 changes: 29 additions & 0 deletions .circleci/linter_configs/.cspell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

enableGlobDot: true

patterns:
- name: GithubUser
pattern: /\[@.+\]/gmx
- name: MarkdownCode
pattern: /`{1,3}.+`{1,3}/gmx
- name: MarkdownCodeBlock
pattern: /^\s*```[\s\S]*?^\s*```/gmx

languageSettings:
- languageId: markdown
ignoreRegExpList:
- Email
- GithubUser
- MarkdownCode
- MarkdownCodeBlock

words:
- Commiting
- PORO
- Trotsenko
- Vladislav
- bestwebua
- codebases
- gemspecs
- kwarg
17 changes: 14 additions & 3 deletions lefthook.yml → .circleci/linter_configs/.lefthook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,32 @@

skip_output:
- meta

code-style-linters:
commands:
markdownlint:
run: bundle exec mdl . -s './.circleci/linter_configs/.mdlrc'
reek:
run: bundle exec reek
rubocop:
run: bundle exec rubocop -c '.circleci/linter_configs/.rubocop.yml'
shellcheck:
glob: '*.{sh}'
run: shellcheck --norc {all_files}
yamllint:
run: yamllint -c '.circleci/linter_configs/.yamllint.yml' .

code-performance-linters:
commands:
fasterer:
run: bundle exec fasterer

code-vulnerability-linters:
commands:
bundle-audit:
run: bundle exec bundle-audit check --update -c '.circleci/linter_configs/.bundler-audit.yml'
run: bundle exec bundle-audit check -c '.circleci/linter_configs/.bundler-audit.yml' --update

code-documentation-linters:
commands:
cspell:
run: cspell-cli lint -c '.circleci/linter_configs/.cspell.yml' '**/*.{txt,md}'
markdownlint:
run: markdownlint -c '.circleci/linter_configs/.markdownlint.yml' '**/*.md'
9 changes: 9 additions & 0 deletions .circleci/linter_configs/.markdownlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---

default: true

MD013:
line_length: 500

MD024:
siblings_only: true
7 changes: 0 additions & 7 deletions .circleci/linter_configs/.mdlrc

This file was deleted.

3 changes: 3 additions & 0 deletions .circleci/linter_configs/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Style/ParallelAssignment:
Style/RescueStandardError:
Enabled: false

Style/RedundantConstantBase:
Enabled: false

# Layout ----------------------------------------------------------------------

Layout/LineLength:
Expand Down
12 changes: 6 additions & 6 deletions .circleci/scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# !/bin/sh
#!/bin/sh
set -e

GH_CLI_RELEASES_URL="https://github.com/cli/cli/releases"
Expand All @@ -8,7 +8,7 @@ DELIMETER="_"
PACKAGE_FILE="$FILE_NAME$DELIMETER$BUILD_ARCHITECTURE"

gh_cli_latest_release() {
curl -sL -o /dev/null -w %{url_effective} "$GH_CLI_RELEASES_URL/latest" | rev | cut -f1 -d'/'| rev
curl -sL -o /dev/null -w '%{url_effective}' "$GH_CLI_RELEASES_URL/latest" | rev | cut -f1 -d'/'| rev
}

download_gh_cli() {
Expand All @@ -17,7 +17,7 @@ download_gh_cli() {
echo "Unable to get GitHub CLI release." >&2
exit 1
}
curl -s -L -o "$PACKAGE_FILE" "$GH_CLI_RELEASES_URL/download/$VERSION/$FILE_NAME$DELIMETER${VERSION:1}$DELIMETER$BUILD_ARCHITECTURE"
curl -s -L -o "$PACKAGE_FILE" "$GH_CLI_RELEASES_URL/download/$VERSION/$FILE_NAME$DELIMETER$(printf '%s' "$VERSION" | cut -c 2-100)$DELIMETER$BUILD_ARCHITECTURE"
}

install_gh_cli() {
Expand All @@ -26,7 +26,7 @@ install_gh_cli() {
}

get_release_candidate_version() {
echo $(ruby -r rubygems -e "puts Gem::Specification::load('$(ls *.gemspec)').version")
ruby -r rubygems -e "puts Gem::Specification::load('$(ls -- *.gemspec)').version"
}

release_candidate_tag="v$(get_release_candidate_version)"
Expand All @@ -39,8 +39,8 @@ release_to_rubygems() {
echo "Setting RubyGems publisher credentials..."
./.circleci/scripts/set_publisher_credentials.sh
echo "Preparation for release..."
git config --global user.email ${PUBLISHER_EMAIL}
git config --global user.name ${PUBLISHER_NAME}
git config --global user.email "${PUBLISHER_EMAIL}"
git config --global user.name "${PUBLISHER_NAME}"
git stash
git checkout develop
gem install yard gem-ctags
Expand Down
2 changes: 1 addition & 1 deletion .circleci/scripts/set_publisher_credentials.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# !/bin/sh
#!/bin/sh
set -e
set +x
mkdir -p ~/.gem
Expand Down
6 changes: 3 additions & 3 deletions .github/BRANCH_NAMING_CONVENTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bugfix/fix-some-bug-name

### Squash commits

Please squash all branch commits into the one before openning your PR from your fork. It's simple to do with the git:
Please squash all branch commits into the one before opening your PR from your fork. It's simple to do with the git:

```bash
git rebase -i [hash your first commit of your branch]~1
Expand All @@ -25,9 +25,9 @@ git rebase -i 6467fe36232401fa740af067cfd8ac9ec932fed2~1 # example

### Add commit description

Please complete your commit description folowing next pattern:
Please complete your commit description following next pattern:

```
```code
Technical/Add info files # should be the same name as your branch name
* Added license, changelog, contributing, code of conduct docs
Expand Down
35 changes: 28 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.3.2] - 2022-12-12

### Added

- Added [`cspell`](https://cspell.org) linter
- Added [`markdownlint`](https://github.com/DavidAnson/markdownlint) linter
- Added [`shellcheck`](https://www.shellcheck.net) linter
- Added [`yamllint`](https://yamllint.readthedocs.io) linter

### Fixed

- Fixed typos in project's codebase
- Fixed new project's linter issues

### Updated

- Updated `CircleCI` config
- Updated [`lefthook`](https://github.com/evilmartians/lefthook) linters aggregator config
- Updated releasing script, gemspecs
- Updated gem version

## [1.3.1] - 2022-12-01

### Added
Expand All @@ -13,7 +34,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Updated

- Updated gemspecs
- Updated codeclimate/circleci configs
- Updated `codeclimate`/`circleci` configs
- Updated gem development dependencies
- Updated gem version

Expand All @@ -30,7 +51,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Updated

- Updated `SmtpMock::Types::Bool`, tests
- Updated codeclimate/circleci configs
- Updated `codeclimate`/`circleci` configs
- Updated gemspecs
- Updated gem runtime/development dependencies
- Updated gem documentation, version
Expand All @@ -45,7 +66,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Updated gemspecs
- Updated tests
- Updated codeclimate/circleci configs
- Updated `codeclimate`/`circleci` configs
- Updated gem development dependencies
- Updated gem version

Expand All @@ -71,7 +92,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Updated gemspecs
- Updated tests
- Updated rubocop/codeclimate/circleci configs
- Updated `rubocop`/`codeclimate`/`circleci` configs
- Updated gem development dependencies
- Updated gem documentation, version

Expand All @@ -84,7 +105,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Updated

- Updated gemspecs
- Updated codeclimate/circleci configs
- Updated `codeclimate`/`circleci` configs
- Updated gem development dependencies
- Updated gem version

Expand All @@ -97,7 +118,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Updated

- Updated gemspecs
- Updated codeclimate/circleci configs
- Updated `codeclimate`/`circleci` configs
- Updated gem development dependencies
- Updated gem version

Expand Down Expand Up @@ -128,7 +149,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Updated

- Updated gem documentation
- Updated codeclimate config
- Updated `codeclimate` config

## [0.1.0] - 2022-01-18

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform

## Feature requests

Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to *you* to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.
Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and aims of the project. It's up to _you_ to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible.

## Questions

Expand Down
Loading

0 comments on commit eb11fe4

Please sign in to comment.