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

Set up partial functions ratchet #2974

Merged
merged 13 commits into from
Jun 24, 2022
Merged
9 changes: 5 additions & 4 deletions .github/workflows/hlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '**'

jobs:
build10:
hlint:
name: "Hlint check run"
runs-on: ubuntu-latest
steps:
Expand All @@ -15,11 +15,12 @@ jobs:
- name: 'Installing'
uses: rwe/actions-hlint-setup@v1
with:
version: '3.3.4'
version: '3.4'

- name: 'Checking code'
uses: rwe/actions-hlint-run@v1
with:
hlint-bin: "hlint --with-group=extra --hint=ghcide/.hlint.yaml"
path: '[ "ghcide/src", "ghcide/exe", "ghcide/bench/lib", "ghcide/bench/exe", "ghcide/bench/hist", "shake-bench/src", "ghcide/test/exe"]'
hlint-bin: "hlint --with-group=extra"
fail-on: error
path: .

185 changes: 185 additions & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
# HLint configuration file
# https://github.com/ndmitchell/hlint
##########################

# To run HLint do:
# $ hlint --git -j4

# Warnings currently triggered by our code
- ignore: {name: "Use <$>"}
- ignore: {name: "Use :"}
- ignore: {name: "Redundant do"}
- ignore: {name: "Avoid lambda"}
- ignore: {name: "Use newtype instead of data"}
- ignore: {name: "Use unless"}
- ignore: {name: "Move brackets to avoid $"}
- ignore: {name: "Eta reduce"}
- ignore: {name: "Parse error"}
- ignore: {name: "Reduce duplication"}
- ignore: {name: "Use ++"}
- ignore: {name: "Use $>"}
- ignore: {name: "Use section"}
- ignore: {name: "Use record patterns"}
- ignore: {name: "Use camelCase"}
- ignore: {name: "Use uncurry"}
- ignore: {name: "Avoid lambda using `infix`"}

# Gives at least one suggestion we don't like.
- ignore: {name: "Use <=<"}
- ignore: {name: "Use zipFrom"}
- ignore: {name: "Use zipWithFrom"}

# We are using the "redundant" return/pure to assign a name. We do not want to
# delete it. In particular, this is not an improvement:
# Found:
# do options <- somethingComplicated
# pure options
# Perhaps:
# do somethingComplicated
- ignore: {name: "Redundant return"}
- ignore: {name: "Redundant pure"}

# Off by default hints we like
- warn: {name: Use module export list}

# Condemn nub and friends
- warn: {lhs: nub (sort x), rhs: Data.List.Extra.nubSort x}
- warn: {lhs: nub, rhs: Data.List.Extra.nubOrd}
- warn: {lhs: nubBy, rhs: Data.List.Extra.nubOrdBy}
- warn: {lhs: Data.List.Extra.nubOn, rhs: Data.List.Extra.nubOrdOn}

- functions:
# Things that are unsafe in Haskell base library
michaelpj marked this conversation as resolved.
Show resolved Hide resolved
- name: unsafePerformIO
within:
- Development.IDE.Core.Shake
- Development.IDE.GHC.Util
- Development.IDE.Graph.Internal.Database
- Development.IDE.Graph.Internal.Paths
- Development.IDE.Graph.Internal.Profile
- Ide.Types
- Test.Hls
- Test.Hls.Command
- Wingman.Debug
- Wingman.Types
- AutoTupleSpec
- name: unsafeInterleaveIO
within:
- Development.IDE.LSP.LanguageServer
- {name: unsafeDupablePerformIO, within: []}
- name: unsafeCoerce
within:
- Ide.Plugin.Eval.Code
- Development.IDE.Core.Compile
- Development.IDE.Types.Shake
- Wingman.Judgements.SYB
- Ide.Plugin.Properties

# Things that are a bit dangerous in the GHC API
- name: nameModule
within:
- Development.IDE.GHC.CoreFile
- Ide.Plugin.CallHierarchy.Internal
- Ide.Plugin.Rename
- Compat.HieBin

# Partial functions
- name: Data.List.head
michaelpj marked this conversation as resolved.
Show resolved Hide resolved
within:
- Main
- Experiments
- Development.IDE.Core.Shake
- Development.IDE.Plugin.CodeAction
- Development.IDE.Plugin.Completions
- Development.IDE.Plugin.CodeAction.ExactPrint
- Development.IDE.Session
- Development.IDE.Spans.Documentation
- Ide.Plugin.CallHierarchy.Internal
- TExpectedActual
- TRigidType
- TRigidType
- Ide.Plugin.Class
- Wingman.Tactics

- name: Data.List.tail
within:
- Main
- Development.Benchmark.Rules
- Development.IDE.Plugin.CodeAction
- Development.IDE.Plugin.CodeAction.ExactPrint
- Development.IDE.Session
- IDE.Plugin.Eval.Code
- IDE.Plugin.Eval.Util
- UnificationSpec

- name: Data.List.last
within:
- GenChangelogs
- Main

- name: Data.List.init
within: []

- name: Data.List.foldl1'
within: []

- name: Data.List.foldr1'
within: []

- name: "Data.List.!!"
within:
- Main
- Experiments
- FunctionalCodeAction
- Development.IDE.Plugin.CodeAction
- Development.IDE.Plugin.Completions.Logic
- Development.IDE.Spans.Documentation
- Wingman.CaseSplit
- Wingman.Simplify


- name: Data.Text.head
within:
- Development.IDE.Plugin.CodeAction
- Development.IDE.Plugin.Completions.Logic

- name: Data.Foldable.foldl1
within: []

- name: Data.Foldable.foldr1
within:
- Wingman.Tactics

- name: Data.Maybe.fromJust
within:
- Experiments
- Main
- MultipleImports
- Progress
- Utils
- Development.IDE.Core.Compile
- Development.IDE.Core.Rules
- Development.IDE.Core.Shake
- Development.IDE.Plugin.Completions
- Development.IDE.Plugin.CodeAction.ExactPrint
- Development.IDE.Test
- Development.IDE.Graph.Internal.Profile
- Development.IDE.Graph.Internal.Rules
- Ide.Plugin.Class

- name: "Data.Map.!"
within:
- Wingman.LanguageServer

- name: "Data.IntMap.!"
within: []

- name: "Data.Vector.!"
within: []

- name: "GHC.Arr.!"
within: []

# We really do not want novel usages of restricted functions, and mere
# Warning is not enough to prevent those consistently; you need a build failure.
- error: {name: Avoid restricted function}
180 changes: 0 additions & 180 deletions ghcide/.hlint.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions plugins/hls-hlint-plugin/.hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This is here so that the tests in this package don't
# pick up the configuration from HLS's own .hlint.yaml
1 change: 1 addition & 0 deletions test/testdata/wErrorTest/src/WError.hs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module WError where
{-# ANN module "HLint: ignore" #-}
main = undefined