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

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

-- | Information about the statistics from the code review.
--
-- /See:/ 'newMetrics' smart constructor.
data Metrics = Metrics'
  { -- | Total number of recommendations found in the code review.
    Metrics -> Maybe Integer
findingsCount :: Prelude.Maybe Prelude.Integer,
    -- | @MeteredLinesOfCode@ is the number of lines of code in the repository
    -- where the code review happened. This does not include non-code lines
    -- such as comments and blank lines.
    Metrics -> Maybe Integer
meteredLinesOfCodeCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (Metrics -> Metrics -> Bool
(Metrics -> Metrics -> Bool)
-> (Metrics -> Metrics -> Bool) -> Eq Metrics
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Metrics -> Metrics -> Bool
$c/= :: Metrics -> Metrics -> Bool
== :: Metrics -> Metrics -> Bool
$c== :: Metrics -> Metrics -> Bool
Prelude.Eq, ReadPrec [Metrics]
ReadPrec Metrics
Int -> ReadS Metrics
ReadS [Metrics]
(Int -> ReadS Metrics)
-> ReadS [Metrics]
-> ReadPrec Metrics
-> ReadPrec [Metrics]
-> Read Metrics
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Metrics]
$creadListPrec :: ReadPrec [Metrics]
readPrec :: ReadPrec Metrics
$creadPrec :: ReadPrec Metrics
readList :: ReadS [Metrics]
$creadList :: ReadS [Metrics]
readsPrec :: Int -> ReadS Metrics
$creadsPrec :: Int -> ReadS Metrics
Prelude.Read, Int -> Metrics -> ShowS
[Metrics] -> ShowS
Metrics -> String
(Int -> Metrics -> ShowS)
-> (Metrics -> String) -> ([Metrics] -> ShowS) -> Show Metrics
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Metrics] -> ShowS
$cshowList :: [Metrics] -> ShowS
show :: Metrics -> String
$cshow :: Metrics -> String
showsPrec :: Int -> Metrics -> ShowS
$cshowsPrec :: Int -> Metrics -> ShowS
Prelude.Show, (forall x. Metrics -> Rep Metrics x)
-> (forall x. Rep Metrics x -> Metrics) -> Generic Metrics
forall x. Rep Metrics x -> Metrics
forall x. Metrics -> Rep Metrics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Metrics x -> Metrics
$cfrom :: forall x. Metrics -> Rep Metrics x
Prelude.Generic)

-- |
-- Create a value of 'Metrics' 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', 'metrics_findingsCount' - Total number of recommendations found in the code review.
--
-- 'meteredLinesOfCodeCount', 'metrics_meteredLinesOfCodeCount' - @MeteredLinesOfCode@ is the number of lines of code in the repository
-- where the code review happened. This does not include non-code lines
-- such as comments and blank lines.
newMetrics ::
  Metrics
newMetrics :: Metrics
newMetrics =
  Metrics' :: Maybe Integer -> Maybe Integer -> Metrics
Metrics'
    { $sel:findingsCount:Metrics' :: Maybe Integer
findingsCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:meteredLinesOfCodeCount:Metrics' :: Maybe Integer
meteredLinesOfCodeCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

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

-- | @MeteredLinesOfCode@ is the number of lines of code in the repository
-- where the code review happened. This does not include non-code lines
-- such as comments and blank lines.
metrics_meteredLinesOfCodeCount :: Lens.Lens' Metrics (Prelude.Maybe Prelude.Integer)
metrics_meteredLinesOfCodeCount :: (Maybe Integer -> f (Maybe Integer)) -> Metrics -> f Metrics
metrics_meteredLinesOfCodeCount = (Metrics -> Maybe Integer)
-> (Metrics -> Maybe Integer -> Metrics)
-> Lens Metrics Metrics (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Metrics' {Maybe Integer
meteredLinesOfCodeCount :: Maybe Integer
$sel:meteredLinesOfCodeCount:Metrics' :: Metrics -> Maybe Integer
meteredLinesOfCodeCount} -> Maybe Integer
meteredLinesOfCodeCount) (\s :: Metrics
s@Metrics' {} Maybe Integer
a -> Metrics
s {$sel:meteredLinesOfCodeCount:Metrics' :: Maybe Integer
meteredLinesOfCodeCount = Maybe Integer
a} :: Metrics)

instance Core.FromJSON Metrics where
  parseJSON :: Value -> Parser Metrics
parseJSON =
    String -> (Object -> Parser Metrics) -> Value -> Parser Metrics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Metrics"
      ( \Object
x ->
          Maybe Integer -> Maybe Integer -> Metrics
Metrics'
            (Maybe Integer -> Maybe Integer -> Metrics)
-> Parser (Maybe Integer) -> Parser (Maybe Integer -> Metrics)
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 -> Metrics)
-> Parser (Maybe Integer) -> Parser Metrics
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 Metrics

instance Prelude.NFData Metrics