Remove unnecessary Rule.ruleExtractsData

This commit is contained in:
Jeroen Engels 2022-11-05 18:08:57 +01:00
parent f468a45984
commit 6fb09e5647
3 changed files with 10 additions and 32 deletions

File diff suppressed because one or more lines are too long

View File

@ -23,7 +23,7 @@ module Review.Rule exposing
, ReviewError, errorRuleName, errorMessage, errorDetails, errorRange, errorFixes, errorFilePath, errorTarget
, withDataExtractor, preventExtract
, ignoreErrorsForDirectories, ignoreErrorsForFiles, filterErrorsForFiles
, reviewV3, reviewV2, review, ProjectData, ruleName, ruleExtractsData, ruleProvidesFixes, getConfigurationError
, reviewV3, reviewV2, review, ProjectData, ruleName, ruleProvidesFixes, getConfigurationError
, Required, Forbidden
)
@ -275,7 +275,7 @@ reason or seemingly inappropriately.
# Running rules
@docs reviewV3, reviewV2, review, ProjectData, ruleName, ruleExtractsData, ruleProvidesFixes, getConfigurationError
@docs reviewV3, reviewV2, review, ProjectData, ruleName, ruleProvidesFixes, getConfigurationError
# Internals
@ -835,17 +835,6 @@ ruleName (Rule rule) =
rule.name
{-| Indicates whether the rule has a data extractor.
You should not have to use this when writing a rule.
-}
ruleExtractsData : Rule -> Bool
ruleExtractsData (Rule rule) =
-- TODO Breaking change: This should be an internal detail, not shown to the user
rule.extractsData
{-| Indicates whether the rule provides fixes.
You should not have to use this when writing a rule.

View File

@ -181,9 +181,8 @@ type alias CodeInspector =
}
type ExtractResult
= RuleHasNoExtractor
| Extracted (Maybe Encode.Value)
type alias ExtractResult =
Maybe Encode.Value
{-| An expectation for an error. Use [`error`](#error) to create one.
@ -434,11 +433,7 @@ runOnModulesWithProjectDataHelp project rule sources =
extract : ExtractResult
extract =
if Rule.ruleExtractsData rule then
Extracted (Dict.get (Rule.ruleName rule) extracts)
else
RuleHasNoExtractor
Dict.get (Rule.ruleName rule) extracts
in
case ListExtra.find (\err -> Rule.errorTarget err == Error.Global) errors of
Just globalError_ ->
@ -1581,13 +1576,10 @@ expectConfigurationErrorDetailsMatch expectedError configurationError =
expectNoDataExtract : ExtractResult -> Expectation
expectNoDataExtract maybeExtract =
case maybeExtract of
Extracted (Just _) ->
Just _ ->
Expect.fail FailureMessage.needToUsedExpectErrorsForModules
Extracted Nothing ->
Expect.pass
RuleHasNoExtractor ->
Nothing ->
Expect.pass
@ -1637,13 +1629,10 @@ expectDataExtract expectedExtract reviewResult =
expectDataExtractContent : String -> ExtractResult -> Expectation
expectDataExtractContent rawExpected maybeActualExtract =
case maybeActualExtract of
RuleHasNoExtractor ->
Nothing ->
Expect.fail FailureMessage.missingExtract
Extracted Nothing ->
Expect.fail FailureMessage.missingExtract
Extracted (Just actual) ->
Just actual ->
case Decode.decodeString Decode.value rawExpected of
Err parsingError ->
Expect.fail (FailureMessage.invalidJsonForExpectedDataExtract parsingError)