Skip to content

Commit

Permalink
Technical/Increase project code quality (#98)
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 authored Dec 11, 2022
1 parent aac67a2 commit 6287da6
Show file tree
Hide file tree
Showing 17 changed files with 133 additions and 67 deletions.
31 changes: 14 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,16 @@ references:
paths:
- ~/vendor/bundle

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 @@ -77,24 +74,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 @@ -177,7 +174,7 @@ workflows:
- linters-ruby:
matrix:
parameters:
ruby-version: ["3.1"]
ruby-version: ["3.1-node"]
- tests-ruby:
matrix:
parameters:
Expand Down
3 changes: 1 addition & 2 deletions .circleci/gemspecs/latest
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ 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-ftp', '~> 0.2.0'
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.2'
spec.add_development_dependency 'rspec', '~> 3.12'
spec.add_development_dependency 'rspec-dns', '~> 0.1.8'
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
30 changes: 30 additions & 0 deletions .circleci/linter_configs/.cspell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

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
- Punycode
- PORO
- RDNS
- Trotsenko
- Vladislav
- bestwebua
- codebases
- gemspecs
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
8 changes: 0 additions & 8 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
2 changes: 2 additions & 0 deletions .circleci/linter_configs/.yamllint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---

extends: default

rules:
line-length:
max: 200
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
2 changes: 1 addition & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ checks:
plugins:
rubocop:
enabled: true
channel: rubocop-1-39
channel: rubocop-1-40
config:
file: .circleci/linter_configs/.rubocop.yml

Expand Down
4 changes: 2 additions & 2 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,7 +25,7 @@ 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:

```
Technical/Add info files # should be the same name as your branch name
Expand Down
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
---

github: [bestwebua]
Loading

0 comments on commit 6287da6

Please sign in to comment.