Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint YAML especially .hlint.yaml. #5797

Merged
merged 8 commits into from
Jul 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/hlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: hlint

# yamllint disable-line rule:truthy
on: [pull_request, push]

jobs:
style:
name: hlint
runs-on: ubuntu-latest

steps:
- name: Clone project
uses: actions/checkout@v3

- uses: haskell/actions/hlint-setup@v2
name: Set up HLint
with:
version: "3.4"

- name: hlint
run: |
set -ex
hlint src/
hlint src/ --cpp-define=WINDOWS=1
hlint test/ --cpp-simple
16 changes: 1 addition & 15 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,12 @@ on:
workflow_dispatch:

jobs:
style:
name: Style
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v2
- name: hlint
run: |
set -ex
./etc/scripts/get-hlint.sh
export PATH="$(pwd)"/hlint:$PATH
hlint src/
hlint src/ --cpp-define=WINDOWS=1
hlint test/ --cpp-simple
pedantic:
name: Pedantic
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v1
with:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: yamllint
# yamllint disable-line rule:truthy
on: [pull_request, push]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: yaml-lint
uses: ibiqlik/action-yamllint@v3
with:
format: github
98 changes: 54 additions & 44 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,6 @@
# HLint configuration file
# https://github.com/ndmitchell/hlint

# Not considered useful hints
- ignore: {name: "Redundant do"}
- ignore: {name: "Use section"}
- ignore: {name: "Use camelCase"}
- ignore: {name: "Use list comprehension"}
- ignore: {name: "Redundant if"}
- ignore: {name: "Avoid lambda"}
- ignore: {name: "Eta reduce"}
- ignore: {name: "Use fmap"} # specific for GHC 7.8 compat
- ignore: {name: "Parse error"} # we trust the compiler over HLint
- ignore: {name: "Use =="} # Creates infinite loops in `EQ` using expressions
- ignore: {name: "Evaluate"}
- ignore: {name: "Use &&&"}
- ignore: {name: "Redundant compare"}
- ignore: {name: "Use Just"}
- ignore: {name: "Avoid lambda using `infix`"}

# Added in hlint-2.0.10, ignoring for now
- ignore: {name: "Unnecessary hiding"}
- ignore: {name: "Use lambda-case"}

- ignore: {name: "Use fewer imports", within: [
"System.Process.Read", # Related to 'Hide post-AMP warnings' comment
"Stack.Exec" # ifdef for System.Process.Read
]
}

- ignore: {name: "Use fromMaybe", within: [
"Stack.Types.Config.explicitSetupDeps" # Related to 'explicit pattern matching is clearer' comment
]
}

# For clarity (related to do syntax)
- ignore: {name: "Reduce duplication", within: [
"Network.HTTP.Download.VerifiedSpec",
"Stack.PackageDumpSpec",
"Stack.Types.StackT",
"Stack.Docker"
]
}

- error: {lhs: "Network.HTTP.Client.MultipartFormData.formDataBody", rhs: "Network.HTTP.StackClient.formDataBody"}
- error: {lhs: "Network.HTTP.Client.MultipartFormData.partBS", rhs: "Network.HTTP.StackClient.partBS"}
- error: {lhs: "Network.HTTP.Client.MultipartFormData.partFileRequestBody", rhs: "Network.HTTP.StackClient.partFileRequestBody"}
Expand Down Expand Up @@ -83,8 +42,59 @@
- error: {lhs: "Network.HTTP.Types.hContentLength", rhs: "Network.HTTP.StackClient.hContentLength"}
- error: {lhs: "Network.HTTP.Types.hContentMD5", rhs: "Network.HTTP.StackClient.hContentMD5"}
- error: {lhs: "Network.HTTP.Types.methodPut", rhs: "Network.HTTP.StackClient.methodPut"}
- ignore: {name: "Use alternative", within: "Network.HTTP.StackClient"}

# We define the above alternatives but then must ignore these with
# ignore "Use alternative" within Network.HTTP.StackClient.
- ignore:
name: "Use alternative"
within:
- Network.HTTP.StackClient

# Not considered useful hints
- ignore: {name: "Redundant do"}
- ignore: {name: "Use section"}
- ignore: {name: "Use camelCase"}
- ignore: {name: "Use list comprehension"}
- ignore: {name: "Redundant if"}
- ignore: {name: "Avoid lambda"}
- ignore: {name: "Eta reduce"}
- ignore: {name: "Use fmap"} # specific for GHC 7.8 compat
- ignore: {name: "Parse error"} # we trust the compiler over HLint
- ignore: {name: "Use =="} # Creates infinite loops in `EQ` using expressions
- ignore: {name: "Evaluate"}
- ignore: {name: "Use &&&"}
- ignore: {name: "Redundant compare"}
- ignore: {name: "Use Just"}
- ignore: {name: "Avoid lambda using `infix`"}

# Added in hlint-2.0.10, ignoring for now
- ignore: {name: "Unnecessary hiding"}
- ignore: {name: "Use lambda-case"}

- ignore:
name: "Use fewer imports"
within:
- System.Process.Read # Related to 'Hide post-AMP warnings' comment
- Stack.Exec # ifdef for System.Process.Read

# Related to 'explicit pattern matching is clearer' comment
- ignore:
name: "Use fromMaybe"
within:
- Stack.Types.Config.explicitSetupDeps

# For clarity (related to do syntax)
- ignore:
name: "Reduce duplication"
within:
- Network.HTTP.Download.VerifiedSpec
- Stack.PackageDumpSpec
- Stack.Types.StackT
- Stack.Docker

# Gives an incorrect hint that breaks type checking due to mismatched types
- ignore: {name: "Too strict maybe", within: "Stack.Package" }
- ignore: {name: "Too strict maybe", within: "Stack.Config" }
- ignore:
name: "Too strict maybe"
within:
- Stack.Config
- Stack.Package
10 changes: 10 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
extends: default
rules:
document-start: disable
line-length: disable
ignore: |
.github/workflows/arm64-release.yml
.github/workflows/integration-tests.yml
.github/workflows/unit-tests.yml
doc
test
74 changes: 37 additions & 37 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ docs_dir: doc
site_dir: _site
theme: readthedocs
extra_css:
- css/extra.css
- css/extra.css
extra_javascript:
- js/searchhack.js
- js/searchhack.js

pages:
- Home: README.md
- Changelog: ChangeLog.md
- Tool documentation:
- Install/upgrade: install_and_upgrade.md
- User guide: GUIDE.md
- FAQ: faq.md
- Configuration (project and global): yaml_configuration.md
- stack.yaml vs cabal package files: stack_yaml_vs_cabal_package_file.md
- Build command: build_command.md
- Developing on Windows: developing_on_windows.md
- Dependency visualization: dependency_visualization.md
- Docker integration: docker_integration.md
- Nix integration: nix_integration.md
- Non-standard project initialization: nonstandard_project_init.md
- Shell auto-completion: shell_autocompletion.md
- Travis CI: travis_ci.md
- Azure CI: azure_ci.md
- Custom snapshots: custom_snapshot.md
- Code coverage: coverage.md
- GHCi: ghci.md
- Pantry: pantry.md
- Lock files: lock_files.md
- Advanced documentation:
- Build overview: build_overview.md
- Project documentation:
- Contributors guide: CONTRIBUTING.md
- Maintainer guide:
- Releases: maintainers/releases.md
- Maintainer team process: maintainers/team_process.md
- Add GHC version: maintainers/ghc.md
- Docker images: maintainers/docker.md
- Upgrading MSYS2: maintainers/msys.md
- Signing key: SIGNING_KEY.md
- Home: README.md
- Changelog: ChangeLog.md
- Tool documentation:
- Install/upgrade: install_and_upgrade.md
- User guide: GUIDE.md
- FAQ: faq.md
- Configuration (project and global): yaml_configuration.md
- stack.yaml vs cabal package files: stack_yaml_vs_cabal_package_file.md
- Build command: build_command.md
- Developing on Windows: developing_on_windows.md
- Dependency visualization: dependency_visualization.md
- Docker integration: docker_integration.md
- Nix integration: nix_integration.md
- Non-standard project initialization: nonstandard_project_init.md
- Shell auto-completion: shell_autocompletion.md
- Travis CI: travis_ci.md
- Azure CI: azure_ci.md
- Custom snapshots: custom_snapshot.md
- Code coverage: coverage.md
- GHCi: ghci.md
- Pantry: pantry.md
- Lock files: lock_files.md
- Advanced documentation:
- Build overview: build_overview.md
- Project documentation:
- Contributors guide: CONTRIBUTING.md
- Maintainer guide:
- Releases: maintainers/releases.md
- Maintainer team process: maintainers/team_process.md
- Add GHC version: maintainers/ghc.md
- Docker images: maintainers/docker.md
- Upgrading MSYS2: maintainers/msys.md
- Signing key: SIGNING_KEY.md

markdown_extensions:
- toc:
permalink: true
- toc:
permalink: true