{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CodeGuruReviewer.Types.RecommendationSummary
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CodeGuruReviewer.Types.RecommendationSummary where

import Amazonka.CodeGuruReviewer.Types.RecommendationCategory
import Amazonka.CodeGuruReviewer.Types.RuleMetadata
import Amazonka.CodeGuruReviewer.Types.Severity
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Information about recommendations.
--
-- /See:/ 'newRecommendationSummary' smart constructor.
data RecommendationSummary = RecommendationSummary'
  { -- | A description of the recommendation generated by CodeGuru Reviewer for
    -- the lines of code between the start line and the end line.
    RecommendationSummary -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | Last line where the recommendation is applicable in the source commit or
    -- source branch. For a single line comment the start line and end line
    -- values are the same.
    RecommendationSummary -> Maybe Int
endLine :: Prelude.Maybe Prelude.Int,
    -- | Name of the file on which a recommendation is provided.
    RecommendationSummary -> Maybe Text
filePath :: Prelude.Maybe Prelude.Text,
    -- | The type of a recommendation.
    RecommendationSummary -> Maybe RecommendationCategory
recommendationCategory :: Prelude.Maybe RecommendationCategory,
    -- | The recommendation ID that can be used to track the provided
    -- recommendations. Later on it can be used to collect the feedback.
    RecommendationSummary -> Maybe Text
recommendationId :: Prelude.Maybe Prelude.Text,
    -- | Metadata about a rule. Rule metadata includes an ID, a name, a list of
    -- tags, and a short and long description. CodeGuru Reviewer uses rules to
    -- analyze code. A rule\'s recommendation is included in analysis results
    -- if code is detected that violates the rule.
    RecommendationSummary -> Maybe RuleMetadata
ruleMetadata :: Prelude.Maybe RuleMetadata,
    -- | The severity of the issue in the code that generated this
    -- recommendation.
    RecommendationSummary -> Maybe Severity
severity :: Prelude.Maybe Severity,
    -- | Start line from where the recommendation is applicable in the source
    -- commit or source branch.
    RecommendationSummary -> Maybe Int
startLine :: Prelude.Maybe Prelude.Int
  }
  deriving (RecommendationSummary -> RecommendationSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RecommendationSummary -> RecommendationSummary -> Bool
$c/= :: RecommendationSummary -> RecommendationSummary -> Bool
== :: RecommendationSummary -> RecommendationSummary -> Bool
$c== :: RecommendationSummary -> RecommendationSummary -> Bool
Prelude.Eq, ReadPrec [RecommendationSummary]
ReadPrec RecommendationSummary
Int -> ReadS RecommendationSummary
ReadS [RecommendationSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RecommendationSummary]
$creadListPrec :: ReadPrec [RecommendationSummary]
readPrec :: ReadPrec RecommendationSummary
$creadPrec :: ReadPrec RecommendationSummary
readList :: ReadS [RecommendationSummary]
$creadList :: ReadS [RecommendationSummary]
readsPrec :: Int -> ReadS RecommendationSummary
$creadsPrec :: Int -> ReadS RecommendationSummary
Prelude.Read, Int -> RecommendationSummary -> ShowS
[RecommendationSummary] -> ShowS
RecommendationSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RecommendationSummary] -> ShowS
$cshowList :: [RecommendationSummary] -> ShowS
show :: RecommendationSummary -> String
$cshow :: RecommendationSummary -> String
showsPrec :: Int -> RecommendationSummary -> ShowS
$cshowsPrec :: Int -> RecommendationSummary -> ShowS
Prelude.Show, forall x. Rep RecommendationSummary x -> RecommendationSummary
forall x. RecommendationSummary -> Rep RecommendationSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RecommendationSummary x -> RecommendationSummary
$cfrom :: forall x. RecommendationSummary -> Rep RecommendationSummary x
Prelude.Generic)

-- |
-- Create a value of 'RecommendationSummary' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'description', 'recommendationSummary_description' - A description of the recommendation generated by CodeGuru Reviewer for
-- the lines of code between the start line and the end line.
--
-- 'endLine', 'recommendationSummary_endLine' - Last line where the recommendation is applicable in the source commit or
-- source branch. For a single line comment the start line and end line
-- values are the same.
--
-- 'filePath', 'recommendationSummary_filePath' - Name of the file on which a recommendation is provided.
--
-- 'recommendationCategory', 'recommendationSummary_recommendationCategory' - The type of a recommendation.
--
-- 'recommendationId', 'recommendationSummary_recommendationId' - The recommendation ID that can be used to track the provided
-- recommendations. Later on it can be used to collect the feedback.
--
-- 'ruleMetadata', 'recommendationSummary_ruleMetadata' - Metadata about a rule. Rule metadata includes an ID, a name, a list of
-- tags, and a short and long description. CodeGuru Reviewer uses rules to
-- analyze code. A rule\'s recommendation is included in analysis results
-- if code is detected that violates the rule.
--
-- 'severity', 'recommendationSummary_severity' - The severity of the issue in the code that generated this
-- recommendation.
--
-- 'startLine', 'recommendationSummary_startLine' - Start line from where the recommendation is applicable in the source
-- commit or source branch.
newRecommendationSummary ::
  RecommendationSummary
newRecommendationSummary :: RecommendationSummary
newRecommendationSummary =
  RecommendationSummary'
    { $sel:description:RecommendationSummary' :: Maybe Text
description =
        forall a. Maybe a
Prelude.Nothing,
      $sel:endLine:RecommendationSummary' :: Maybe Int
endLine = forall a. Maybe a
Prelude.Nothing,
      $sel:filePath:RecommendationSummary' :: Maybe Text
filePath = forall a. Maybe a
Prelude.Nothing,
      $sel:recommendationCategory:RecommendationSummary' :: Maybe RecommendationCategory
recommendationCategory = forall a. Maybe a
Prelude.Nothing,
      $sel:recommendationId:RecommendationSummary' :: Maybe Text
recommendationId = forall a. Maybe a
Prelude.Nothing,
      $sel:ruleMetadata:RecommendationSummary' :: Maybe RuleMetadata
ruleMetadata = forall a. Maybe a
Prelude.Nothing,
      $sel:severity:RecommendationSummary' :: Maybe Severity
severity = forall a. Maybe a
Prelude.Nothing,
      $sel:startLine:RecommendationSummary' :: Maybe Int
startLine = forall a. Maybe a
Prelude.Nothing
    }

-- | A description of the recommendation generated by CodeGuru Reviewer for
-- the lines of code between the start line and the end line.
recommendationSummary_description :: Lens.Lens' RecommendationSummary (Prelude.Maybe Prelude.Text)
recommendationSummary_description :: Lens' RecommendationSummary (Maybe Text)
recommendationSummary_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe Text
description :: Maybe Text
$sel:description:RecommendationSummary' :: RecommendationSummary -> Maybe Text
description} -> Maybe Text
description) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe Text
a -> RecommendationSummary
s {$sel:description:RecommendationSummary' :: Maybe Text
description = Maybe Text
a} :: RecommendationSummary)

-- | Last line where the recommendation is applicable in the source commit or
-- source branch. For a single line comment the start line and end line
-- values are the same.
recommendationSummary_endLine :: Lens.Lens' RecommendationSummary (Prelude.Maybe Prelude.Int)
recommendationSummary_endLine :: Lens' RecommendationSummary (Maybe Int)
recommendationSummary_endLine = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe Int
endLine :: Maybe Int
$sel:endLine:RecommendationSummary' :: RecommendationSummary -> Maybe Int
endLine} -> Maybe Int
endLine) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe Int
a -> RecommendationSummary
s {$sel:endLine:RecommendationSummary' :: Maybe Int
endLine = Maybe Int
a} :: RecommendationSummary)

-- | Name of the file on which a recommendation is provided.
recommendationSummary_filePath :: Lens.Lens' RecommendationSummary (Prelude.Maybe Prelude.Text)
recommendationSummary_filePath :: Lens' RecommendationSummary (Maybe Text)
recommendationSummary_filePath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe Text
filePath :: Maybe Text
$sel:filePath:RecommendationSummary' :: RecommendationSummary -> Maybe Text
filePath} -> Maybe Text
filePath) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe Text
a -> RecommendationSummary
s {$sel:filePath:RecommendationSummary' :: Maybe Text
filePath = Maybe Text
a} :: RecommendationSummary)

-- | The type of a recommendation.
recommendationSummary_recommendationCategory :: Lens.Lens' RecommendationSummary (Prelude.Maybe RecommendationCategory)
recommendationSummary_recommendationCategory :: Lens' RecommendationSummary (Maybe RecommendationCategory)
recommendationSummary_recommendationCategory = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe RecommendationCategory
recommendationCategory :: Maybe RecommendationCategory
$sel:recommendationCategory:RecommendationSummary' :: RecommendationSummary -> Maybe RecommendationCategory
recommendationCategory} -> Maybe RecommendationCategory
recommendationCategory) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe RecommendationCategory
a -> RecommendationSummary
s {$sel:recommendationCategory:RecommendationSummary' :: Maybe RecommendationCategory
recommendationCategory = Maybe RecommendationCategory
a} :: RecommendationSummary)

-- | The recommendation ID that can be used to track the provided
-- recommendations. Later on it can be used to collect the feedback.
recommendationSummary_recommendationId :: Lens.Lens' RecommendationSummary (Prelude.Maybe Prelude.Text)
recommendationSummary_recommendationId :: Lens' RecommendationSummary (Maybe Text)
recommendationSummary_recommendationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe Text
recommendationId :: Maybe Text
$sel:recommendationId:RecommendationSummary' :: RecommendationSummary -> Maybe Text
recommendationId} -> Maybe Text
recommendationId) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe Text
a -> RecommendationSummary
s {$sel:recommendationId:RecommendationSummary' :: Maybe Text
recommendationId = Maybe Text
a} :: RecommendationSummary)

-- | Metadata about a rule. Rule metadata includes an ID, a name, a list of
-- tags, and a short and long description. CodeGuru Reviewer uses rules to
-- analyze code. A rule\'s recommendation is included in analysis results
-- if code is detected that violates the rule.
recommendationSummary_ruleMetadata :: Lens.Lens' RecommendationSummary (Prelude.Maybe RuleMetadata)
recommendationSummary_ruleMetadata :: Lens' RecommendationSummary (Maybe RuleMetadata)
recommendationSummary_ruleMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe RuleMetadata
ruleMetadata :: Maybe RuleMetadata
$sel:ruleMetadata:RecommendationSummary' :: RecommendationSummary -> Maybe RuleMetadata
ruleMetadata} -> Maybe RuleMetadata
ruleMetadata) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe RuleMetadata
a -> RecommendationSummary
s {$sel:ruleMetadata:RecommendationSummary' :: Maybe RuleMetadata
ruleMetadata = Maybe RuleMetadata
a} :: RecommendationSummary)

-- | The severity of the issue in the code that generated this
-- recommendation.
recommendationSummary_severity :: Lens.Lens' RecommendationSummary (Prelude.Maybe Severity)
recommendationSummary_severity :: Lens' RecommendationSummary (Maybe Severity)
recommendationSummary_severity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe Severity
severity :: Maybe Severity
$sel:severity:RecommendationSummary' :: RecommendationSummary -> Maybe Severity
severity} -> Maybe Severity
severity) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe Severity
a -> RecommendationSummary
s {$sel:severity:RecommendationSummary' :: Maybe Severity
severity = Maybe Severity
a} :: RecommendationSummary)

-- | Start line from where the recommendation is applicable in the source
-- commit or source branch.
recommendationSummary_startLine :: Lens.Lens' RecommendationSummary (Prelude.Maybe Prelude.Int)
recommendationSummary_startLine :: Lens' RecommendationSummary (Maybe Int)
recommendationSummary_startLine = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RecommendationSummary' {Maybe Int
startLine :: Maybe Int
$sel:startLine:RecommendationSummary' :: RecommendationSummary -> Maybe Int
startLine} -> Maybe Int
startLine) (\s :: RecommendationSummary
s@RecommendationSummary' {} Maybe Int
a -> RecommendationSummary
s {$sel:startLine:RecommendationSummary' :: Maybe Int
startLine = Maybe Int
a} :: RecommendationSummary)

instance Data.FromJSON RecommendationSummary where
  parseJSON :: Value -> Parser RecommendationSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"RecommendationSummary"
      ( \Object
x ->
          Maybe Text
-> Maybe Int
-> Maybe Text
-> Maybe RecommendationCategory
-> Maybe Text
-> Maybe RuleMetadata
-> Maybe Severity
-> Maybe Int
-> RecommendationSummary
RecommendationSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Description")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"EndLine")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"FilePath")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RecommendationCategory")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RecommendationId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RuleMetadata")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Severity")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"StartLine")
      )

instance Prelude.Hashable RecommendationSummary where
  hashWithSalt :: Int -> RecommendationSummary -> Int
hashWithSalt Int
_salt RecommendationSummary' {Maybe Int
Maybe Text
Maybe RecommendationCategory
Maybe RuleMetadata
Maybe Severity
startLine :: Maybe Int
severity :: Maybe Severity
ruleMetadata :: Maybe RuleMetadata
recommendationId :: Maybe Text
recommendationCategory :: Maybe RecommendationCategory
filePath :: Maybe Text
endLine :: Maybe Int
description :: Maybe Text
$sel:startLine:RecommendationSummary' :: RecommendationSummary -> Maybe Int
$sel:severity:RecommendationSummary' :: RecommendationSummary -> Maybe Severity
$sel:ruleMetadata:RecommendationSummary' :: RecommendationSummary -> Maybe RuleMetadata
$sel:recommendationId:RecommendationSummary' :: RecommendationSummary -> Maybe Text
$sel:recommendationCategory:RecommendationSummary' :: RecommendationSummary -> Maybe RecommendationCategory
$sel:filePath:RecommendationSummary' :: RecommendationSummary -> Maybe Text
$sel:endLine:RecommendationSummary' :: RecommendationSummary -> Maybe Int
$sel:description:RecommendationSummary' :: RecommendationSummary -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
endLine
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
filePath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RecommendationCategory
recommendationCategory
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recommendationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RuleMetadata
ruleMetadata
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Severity
severity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
startLine

instance Prelude.NFData RecommendationSummary where
  rnf :: RecommendationSummary -> ()
rnf RecommendationSummary' {Maybe Int
Maybe Text
Maybe RecommendationCategory
Maybe RuleMetadata
Maybe Severity
startLine :: Maybe Int
severity :: Maybe Severity
ruleMetadata :: Maybe RuleMetadata
recommendationId :: Maybe Text
recommendationCategory :: Maybe RecommendationCategory
filePath :: Maybe Text
endLine :: Maybe Int
description :: Maybe Text
$sel:startLine:RecommendationSummary' :: RecommendationSummary -> Maybe Int
$sel:severity:RecommendationSummary' :: RecommendationSummary -> Maybe Severity
$sel:ruleMetadata:RecommendationSummary' :: RecommendationSummary -> Maybe RuleMetadata
$sel:recommendationId:RecommendationSummary' :: RecommendationSummary -> Maybe Text
$sel:recommendationCategory:RecommendationSummary' :: RecommendationSummary -> Maybe RecommendationCategory
$sel:filePath:RecommendationSummary' :: RecommendationSummary -> Maybe Text
$sel:endLine:RecommendationSummary' :: RecommendationSummary -> Maybe Int
$sel:description:RecommendationSummary' :: RecommendationSummary -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
endLine
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
filePath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RecommendationCategory
recommendationCategory
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recommendationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe RuleMetadata
ruleMetadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Severity
severity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
startLine