{-# 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.MetricsSummary
-- 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.MetricsSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about metrics summaries.
--
-- /See:/ 'newMetricsSummary' smart constructor.
data MetricsSummary = MetricsSummary'
  { -- | Total number of recommendations found in the code review.
    MetricsSummary -> Maybe Integer
findingsCount :: Prelude.Maybe Prelude.Integer,
    -- | Lines of code metered in the code review. For the initial code review
    -- pull request and all subsequent revisions, this includes all lines of
    -- code in the files added to the pull request. In subsequent revisions,
    -- for files that already existed in the pull request, this includes only
    -- the changed lines of code. In both cases, this does not include non-code
    -- lines such as comments and import statements. For example, if you submit
    -- a pull request containing 5 files, each with 500 lines of code, and in a
    -- subsequent revision you added a new file with 200 lines of code, and
    -- also modified a total of 25 lines across the initial 5 files,
    -- @MeteredLinesOfCodeCount@ includes the first 5 files (5 * 500 = 2,500
    -- lines), the new file (200 lines) and the 25 changed lines of code for a
    -- total of 2,725 lines of code.
    MetricsSummary -> Maybe Integer
meteredLinesOfCodeCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (MetricsSummary -> MetricsSummary -> Bool
(MetricsSummary -> MetricsSummary -> Bool)
-> (MetricsSummary -> MetricsSummary -> Bool) -> Eq MetricsSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MetricsSummary -> MetricsSummary -> Bool
$c/= :: MetricsSummary -> MetricsSummary -> Bool
== :: MetricsSummary -> MetricsSummary -> Bool
$c== :: MetricsSummary -> MetricsSummary -> Bool
Prelude.Eq, ReadPrec [MetricsSummary]
ReadPrec MetricsSummary
Int -> ReadS MetricsSummary
ReadS [MetricsSummary]
(Int -> ReadS MetricsSummary)
-> ReadS [MetricsSummary]
-> ReadPrec MetricsSummary
-> ReadPrec [MetricsSummary]
-> Read MetricsSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MetricsSummary]
$creadListPrec :: ReadPrec [MetricsSummary]
readPrec :: ReadPrec MetricsSummary
$creadPrec :: ReadPrec MetricsSummary
readList :: ReadS [MetricsSummary]
$creadList :: ReadS [MetricsSummary]
readsPrec :: Int -> ReadS MetricsSummary
$creadsPrec :: Int -> ReadS MetricsSummary
Prelude.Read, Int -> MetricsSummary -> ShowS
[MetricsSummary] -> ShowS
MetricsSummary -> String
(Int -> MetricsSummary -> ShowS)
-> (MetricsSummary -> String)
-> ([MetricsSummary] -> ShowS)
-> Show MetricsSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MetricsSummary] -> ShowS
$cshowList :: [MetricsSummary] -> ShowS
show :: MetricsSummary -> String
$cshow :: MetricsSummary -> String
showsPrec :: Int -> MetricsSummary -> ShowS
$cshowsPrec :: Int -> MetricsSummary -> ShowS
Prelude.Show, (forall x. MetricsSummary -> Rep MetricsSummary x)
-> (forall x. Rep MetricsSummary x -> MetricsSummary)
-> Generic MetricsSummary
forall x. Rep MetricsSummary x -> MetricsSummary
forall x. MetricsSummary -> Rep MetricsSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MetricsSummary x -> MetricsSummary
$cfrom :: forall x. MetricsSummary -> Rep MetricsSummary x
Prelude.Generic)

-- |
-- Create a value of 'MetricsSummary' 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:
--
-- 'findingsCount', 'metricsSummary_findingsCount' - Total number of recommendations found in the code review.
--
-- 'meteredLinesOfCodeCount', 'metricsSummary_meteredLinesOfCodeCount' - Lines of code metered in the code review. For the initial code review
-- pull request and all subsequent revisions, this includes all lines of
-- code in the files added to the pull request. In subsequent revisions,
-- for files that already existed in the pull request, this includes only
-- the changed lines of code. In both cases, this does not include non-code
-- lines such as comments and import statements. For example, if you submit
-- a pull request containing 5 files, each with 500 lines of code, and in a
-- subsequent revision you added a new file with 200 lines of code, and
-- also modified a total of 25 lines across the initial 5 files,
-- @MeteredLinesOfCodeCount@ includes the first 5 files (5 * 500 = 2,500
-- lines), the new file (200 lines) and the 25 changed lines of code for a
-- total of 2,725 lines of code.
newMetricsSummary ::
  MetricsSummary
newMetricsSummary :: MetricsSummary
newMetricsSummary =
  MetricsSummary' :: Maybe Integer -> Maybe Integer -> MetricsSummary
MetricsSummary'
    { $sel:findingsCount:MetricsSummary' :: Maybe Integer
findingsCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:meteredLinesOfCodeCount:MetricsSummary' :: Maybe Integer
meteredLinesOfCodeCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | Total number of recommendations found in the code review.
metricsSummary_findingsCount :: Lens.Lens' MetricsSummary (Prelude.Maybe Prelude.Integer)
metricsSummary_findingsCount :: (Maybe Integer -> f (Maybe Integer))
-> MetricsSummary -> f MetricsSummary
metricsSummary_findingsCount = (MetricsSummary -> Maybe Integer)
-> (MetricsSummary -> Maybe Integer -> MetricsSummary)
-> Lens
     MetricsSummary MetricsSummary (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricsSummary' {Maybe Integer
findingsCount :: Maybe Integer
$sel:findingsCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
findingsCount} -> Maybe Integer
findingsCount) (\s :: MetricsSummary
s@MetricsSummary' {} Maybe Integer
a -> MetricsSummary
s {$sel:findingsCount:MetricsSummary' :: Maybe Integer
findingsCount = Maybe Integer
a} :: MetricsSummary)

-- | Lines of code metered in the code review. For the initial code review
-- pull request and all subsequent revisions, this includes all lines of
-- code in the files added to the pull request. In subsequent revisions,
-- for files that already existed in the pull request, this includes only
-- the changed lines of code. In both cases, this does not include non-code
-- lines such as comments and import statements. For example, if you submit
-- a pull request containing 5 files, each with 500 lines of code, and in a
-- subsequent revision you added a new file with 200 lines of code, and
-- also modified a total of 25 lines across the initial 5 files,
-- @MeteredLinesOfCodeCount@ includes the first 5 files (5 * 500 = 2,500
-- lines), the new file (200 lines) and the 25 changed lines of code for a
-- total of 2,725 lines of code.
metricsSummary_meteredLinesOfCodeCount :: Lens.Lens' MetricsSummary (Prelude.Maybe Prelude.Integer)
metricsSummary_meteredLinesOfCodeCount :: (Maybe Integer -> f (Maybe Integer))
-> MetricsSummary -> f MetricsSummary
metricsSummary_meteredLinesOfCodeCount = (MetricsSummary -> Maybe Integer)
-> (MetricsSummary -> Maybe Integer -> MetricsSummary)
-> Lens
     MetricsSummary MetricsSummary (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricsSummary' {Maybe Integer
meteredLinesOfCodeCount :: Maybe Integer
$sel:meteredLinesOfCodeCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
meteredLinesOfCodeCount} -> Maybe Integer
meteredLinesOfCodeCount) (\s :: MetricsSummary
s@MetricsSummary' {} Maybe Integer
a -> MetricsSummary
s {$sel:meteredLinesOfCodeCount:MetricsSummary' :: Maybe Integer
meteredLinesOfCodeCount = Maybe Integer
a} :: MetricsSummary)

instance Core.FromJSON MetricsSummary where
  parseJSON :: Value -> Parser MetricsSummary
parseJSON =
    String
-> (Object -> Parser MetricsSummary)
-> Value
-> Parser MetricsSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MetricsSummary"
      ( \Object
x ->
          Maybe Integer -> Maybe Integer -> MetricsSummary
MetricsSummary'
            (Maybe Integer -> Maybe Integer -> MetricsSummary)
-> Parser (Maybe Integer)
-> Parser (Maybe Integer -> MetricsSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FindingsCount")
            Parser (Maybe Integer -> MetricsSummary)
-> Parser (Maybe Integer) -> Parser MetricsSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MeteredLinesOfCodeCount")
      )

instance Prelude.Hashable MetricsSummary

instance Prelude.NFData MetricsSummary