{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- 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.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about recommendations.
--
-- /See:/ 'newRecommendationSummary' smart constructor.
data RecommendationSummary = RecommendationSummary'
  { -- | 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,
    -- | Name of the file on which a recommendation is provided.
    RecommendationSummary -> Maybe Text
filePath :: Prelude.Maybe Prelude.Text,
    -- | The severity of the issue in the code that generated this
    -- recommendation.
    RecommendationSummary -> Maybe Severity
severity :: Prelude.Maybe Severity,
    -- | 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,
    -- | Start line from where the recommendation is applicable in the source
    -- commit or source branch.
    RecommendationSummary -> Maybe Int
startLine :: Prelude.Maybe Prelude.Int,
    -- | 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,
    -- | 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,
    -- | The type of a recommendation.
    RecommendationSummary -> Maybe RecommendationCategory
recommendationCategory :: Prelude.Maybe RecommendationCategory
  }
  deriving (RecommendationSummary -> RecommendationSummary -> Bool
(RecommendationSummary -> RecommendationSummary -> Bool)
-> (RecommendationSummary -> RecommendationSummary -> Bool)
-> Eq RecommendationSummary
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]
(Int -> ReadS RecommendationSummary)
-> ReadS [RecommendationSummary]
-> ReadPrec RecommendationSummary
-> ReadPrec [RecommendationSummary]
-> Read 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
(Int -> RecommendationSummary -> ShowS)
-> (RecommendationSummary -> String)
-> ([RecommendationSummary] -> ShowS)
-> Show RecommendationSummary
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. RecommendationSummary -> Rep RecommendationSummary x)
-> (forall x. Rep RecommendationSummary x -> RecommendationSummary)
-> Generic RecommendationSummary
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:
--
-- '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.
--
-- 'filePath', 'recommendationSummary_filePath' - Name of the file on which a recommendation is provided.
--
-- 'severity', 'recommendationSummary_severity' - The severity of the issue in the code that generated this
-- recommendation.
--
-- '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.
--
-- 'startLine', 'recommendationSummary_startLine' - Start line from where the recommendation is applicable in the source
-- commit or source branch.
--
-- '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.
--
-- '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.
--
-- 'recommendationCategory', 'recommendationSummary_recommendationCategory' - The type of a recommendation.
newRecommendationSummary ::
  RecommendationSummary
newRecommendationSummary :: RecommendationSummary
newRecommendationSummary =
  RecommendationSummary' :: Maybe Text
-> Maybe Text
-> Maybe Severity
-> Maybe RuleMetadata
-> Maybe Int
-> Maybe Int
-> Maybe Text
-> Maybe RecommendationCategory
-> RecommendationSummary
RecommendationSummary'
    { $sel:recommendationId:RecommendationSummary' :: Maybe Text
recommendationId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:filePath:RecommendationSummary' :: Maybe Text
filePath = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:severity:RecommendationSummary' :: Maybe Severity
severity = Maybe Severity
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleMetadata:RecommendationSummary' :: Maybe RuleMetadata
ruleMetadata = Maybe RuleMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:startLine:RecommendationSummary' :: Maybe Int
startLine = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:endLine:RecommendationSummary' :: Maybe Int
endLine = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:description:RecommendationSummary' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:recommendationCategory:RecommendationSummary' :: Maybe RecommendationCategory
recommendationCategory = Maybe RecommendationCategory
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_recommendationId = (RecommendationSummary -> Maybe Text)
-> (RecommendationSummary -> Maybe Text -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe Text)
     (Maybe Text)
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)

-- | Name of the file on which a recommendation is provided.
recommendationSummary_filePath :: Lens.Lens' RecommendationSummary (Prelude.Maybe Prelude.Text)
recommendationSummary_filePath :: (Maybe Text -> f (Maybe Text))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_filePath = (RecommendationSummary -> Maybe Text)
-> (RecommendationSummary -> Maybe Text -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe Text)
     (Maybe Text)
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 severity of the issue in the code that generated this
-- recommendation.
recommendationSummary_severity :: Lens.Lens' RecommendationSummary (Prelude.Maybe Severity)
recommendationSummary_severity :: (Maybe Severity -> f (Maybe Severity))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_severity = (RecommendationSummary -> Maybe Severity)
-> (RecommendationSummary
    -> Maybe Severity -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe Severity)
     (Maybe 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)

-- | 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 :: (Maybe RuleMetadata -> f (Maybe RuleMetadata))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_ruleMetadata = (RecommendationSummary -> Maybe RuleMetadata)
-> (RecommendationSummary
    -> Maybe RuleMetadata -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe RuleMetadata)
     (Maybe 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)

-- | 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 :: (Maybe Int -> f (Maybe Int))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_startLine = (RecommendationSummary -> Maybe Int)
-> (RecommendationSummary -> Maybe Int -> RecommendationSummary)
-> Lens
     RecommendationSummary RecommendationSummary (Maybe Int) (Maybe Int)
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)

-- | 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 :: (Maybe Int -> f (Maybe Int))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_endLine = (RecommendationSummary -> Maybe Int)
-> (RecommendationSummary -> Maybe Int -> RecommendationSummary)
-> Lens
     RecommendationSummary RecommendationSummary (Maybe Int) (Maybe Int)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_description = (RecommendationSummary -> Maybe Text)
-> (RecommendationSummary -> Maybe Text -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe Text)
     (Maybe Text)
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)

-- | The type of a recommendation.
recommendationSummary_recommendationCategory :: Lens.Lens' RecommendationSummary (Prelude.Maybe RecommendationCategory)
recommendationSummary_recommendationCategory :: (Maybe RecommendationCategory -> f (Maybe RecommendationCategory))
-> RecommendationSummary -> f RecommendationSummary
recommendationSummary_recommendationCategory = (RecommendationSummary -> Maybe RecommendationCategory)
-> (RecommendationSummary
    -> Maybe RecommendationCategory -> RecommendationSummary)
-> Lens
     RecommendationSummary
     RecommendationSummary
     (Maybe RecommendationCategory)
     (Maybe 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)

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

instance Prelude.Hashable RecommendationSummary

instance Prelude.NFData RecommendationSummary