Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ jobs:
run: npx elm-test
- name: Check documentation
run: elm make --docs=docs.json
- name: elm-review
run: npx elm-review
- name: Verify documentation
run: npx elm-verify-examples --run-tests
run: npx elm-verify-examples --run-tests
38 changes: 38 additions & 0 deletions review/elm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"type": "application",
"source-directories": ["src"],
"elm-version": "0.19.1",
"dependencies": {
"direct": {
"elm/core": "1.0.5",
"elm/json": "1.1.3",
"jfmengels/elm-review": "2.15.1",
"jfmengels/elm-review-code-style": "1.2.0",
"jfmengels/elm-review-common": "1.3.3",
"jfmengels/elm-review-debug": "1.0.8",
"jfmengels/elm-review-documentation": "2.0.4",
"jfmengels/elm-review-simplify": "2.1.8",
"jfmengels/elm-review-unused": "1.2.4",
"miniBill/elm-review-no-broken-elm-parser-functions": "1.0.0"
},
"indirect": {
"elm/bytes": "1.0.8",
"elm/html": "1.0.0",
"elm/parser": "1.1.0",
"elm/project-metadata-utils": "1.0.2",
"elm/random": "1.0.0",
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/virtual-dom": "1.0.3",
"elm-explorations/test": "2.2.0",
"pzp1997/assoc-list": "1.0.0",
"rtfeldman/elm-hex": "1.0.0",
"stil4m/elm-syntax": "7.3.9",
"stil4m/structured-writer": "1.0.3"
}
},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
60 changes: 60 additions & 0 deletions review/src/ReviewConfig.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
module ReviewConfig exposing (config)

import Docs.NoMissing exposing (exposedModules, onlyExposed)
import Docs.ReviewAtDocs
import Docs.ReviewLinksAndSections
import Docs.UpToDateReadmeLinks
import NoBrokenParserFunctions
import NoConfusingPrefixOperator
import NoDebug.Log
import NoDebug.TodoOrToString
import NoExposingEverything
import NoImportingEverything
import NoMissingTypeAnnotation
import NoMissingTypeAnnotationInLetIn
import NoMissingTypeExpose
import NoPrematureLetComputation
import NoSimpleLetBody
import NoUnused.CustomTypeConstructorArgs
import NoUnused.CustomTypeConstructors
import NoUnused.Dependencies
import NoUnused.Exports
import NoUnused.Parameters
import NoUnused.Patterns
import NoUnused.Variables
import Review.Rule as Rule exposing (Rule)
import Simplify


config : List Rule
config =
[ Docs.NoMissing.rule
{ document = onlyExposed
, from = exposedModules
}
, Docs.ReviewLinksAndSections.rule
|> Rule.ignoreErrorsForFiles [ "README.md" ]
, Docs.ReviewAtDocs.rule
, NoConfusingPrefixOperator.rule
, NoDebug.Log.rule
, NoDebug.TodoOrToString.rule
|> Rule.ignoreErrorsForDirectories [ "tests/" ]
, NoExposingEverything.rule
, NoImportingEverything.rule []
, NoMissingTypeAnnotation.rule
, NoMissingTypeAnnotationInLetIn.rule
|> Rule.ignoreErrorsForDirectories [ "tests/" ]
, NoMissingTypeExpose.rule
, NoSimpleLetBody.rule
, NoPrematureLetComputation.rule
, NoUnused.CustomTypeConstructors.rule []
, NoUnused.CustomTypeConstructorArgs.rule
, NoUnused.Dependencies.rule
, NoUnused.Exports.rule
, NoUnused.Parameters.rule
, NoUnused.Patterns.rule
, NoUnused.Variables.rule
|> Rule.ignoreErrorsForDirectories [ "tests/" ]
, Simplify.rule (Simplify.defaults |> Simplify.expectNaN)
, NoBrokenParserFunctions.rule
]
8 changes: 8 additions & 0 deletions review/suppressed/Docs.ReviewLinksAndSections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 1,
"automatically created by": "elm-review suppress",
"learn more": "elm-review suppress --help",
"suppressions": [
{ "count": 1, "filePath": "src/Yaml/Decode.elm" }
]
}
13 changes: 13 additions & 0 deletions review/suppressed/NoMissingTypeAnnotationInLetIn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"automatically created by": "elm-review suppress",
"learn more": "elm-review suppress --help",
"suppressions": [
{ "count": 12, "filePath": "src/Yaml/Parser.elm" },
{ "count": 7, "filePath": "src/Yaml/Parser/Util.elm" },
{ "count": 4, "filePath": "src/Yaml/Encode.elm" },
{ "count": 1, "filePath": "src/Yaml/Decode.elm" },
{ "count": 1, "filePath": "src/Yaml/Parser/Ast.elm" },
{ "count": 1, "filePath": "src/Yaml/Parser/String.elm" }
]
}
8 changes: 8 additions & 0 deletions review/suppressed/NoMissingTypeExpose.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 1,
"automatically created by": "elm-review suppress",
"learn more": "elm-review suppress --help",
"suppressions": [
{ "count": 1, "filePath": "src/Yaml/Encode.elm" }
]
}
8 changes: 8 additions & 0 deletions review/suppressed/NoUnused.Exports.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 1,
"automatically created by": "elm-review suppress",
"learn more": "elm-review suppress --help",
"suppressions": [
{ "count": 5, "filePath": "src/Yaml/Parser/Util.elm" }
]
}
13 changes: 5 additions & 8 deletions src/Yaml/Encode.elm
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,16 @@ int i =
float : Float -> Encoder
float f =
let
sign =
if f < 0 then
"-"

else
""

val =
if isNaN f then
".nan"

else if isInfinite f then
sign ++ ".inf"
if f < 0 then
"-.inf"

else
".inf"

else
String.fromFloat f
Expand Down
10 changes: 2 additions & 8 deletions src/Yaml/Parser.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Yaml.Parser exposing (Value, fromString, parser, toString)
module Yaml.Parser exposing (Value, fromString, parser)

import Dict exposing (Dict)
import Parser as P exposing ((|.), (|=))
Expand All @@ -14,12 +14,6 @@ type alias Value =
Ast.Value


{-| -}
toString : Value -> String
toString =
Ast.toString



-- ERROR REPORTING

Expand Down Expand Up @@ -479,7 +473,7 @@ duplicatedPropertyKeysCheck properties =
duplicates =
duplicatedPropertyKeys properties
in
if List.length duplicates == 0 then
if List.isEmpty duplicates then
P.succeed properties

else
Expand Down
8 changes: 4 additions & 4 deletions src/Yaml/Parser/Ast.elm
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ fromString string =
Float_ (0 / 0)

( mult, ".inf" ) ->
Float_ (mult * 1 / 0)
Float_ (mult / 0)

( mult, ".Inf" ) ->
Float_ (mult * 1 / 0)
Float_ (mult / 0)

( mult, ".INF" ) ->
Float_ (mult * 1 / 0)
Float_ (mult / 0)

_ ->
case String.toInt trimmed of
Expand Down Expand Up @@ -233,7 +233,7 @@ fold f value z =
Record_ r ->
f value (List.foldl (fold f) z (Dict.values r))

Anchor_ nm a ->
Anchor_ _ a ->
f value (fold f a z)


Expand Down
2 changes: 1 addition & 1 deletion tests/Expectations.elm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ expectFail expected got =
-}
expectOneOf : List comparable -> comparable -> Expect.Expectation
expectOneOf expected got =
if List.any (\x -> x == got) expected then
if List.member got expected then
Expect.pass

else
Expand Down
11 changes: 5 additions & 6 deletions tests/TestEncoder.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module TestEncoder exposing (suite)

import Dict
import Expect
import Format exposing (formatFloat, formatFloatOutput)
import Format exposing (formatFloatOutput)
import Fuzz exposing (bool, float, int, list, map2, string)
import Test
import Yaml.Decode as Decode
Expand Down Expand Up @@ -323,12 +323,11 @@ suite =
let
boolToString : Bool -> String
boolToString b =
case b of
True ->
"true"
if b then
"true"

False ->
"false"
else
"false"
in
Expect.equal
("{x: "
Expand Down