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

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 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,
    -- | Lines of code suppressed in the code review based on the @excludeFiles@
    -- element in the @aws-codeguru-reviewer.yml@ file. For full repository
    -- analyses, this number includes all lines of code in the files that are
    -- suppressed. For pull requests, this number only includes the /changed/
    -- lines of code that are suppressed. In both cases, this number does not
    -- include non-code lines such as comments and import statements. For
    -- example, if you initiate a full repository analysis on a repository
    -- containing 5 files, each file with 100 lines of code, and 2 files are
    -- listed as excluded in the @aws-codeguru-reviewer.yml@ file, then
    -- @SuppressedLinesOfCodeCount@ returns 200 (2 * 100) as the total number
    -- of lines of code suppressed. However, if you submit a pull request for
    -- the same repository, then @SuppressedLinesOfCodeCount@ only includes the
    -- lines in the 2 files that changed. If only 1 of the 2 files changed in
    -- the pull request, then @SuppressedLinesOfCodeCount@ returns 100 (1 *
    -- 100) as the total number of lines of code suppressed.
    MetricsSummary -> Maybe Integer
suppressedLinesOfCodeCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (MetricsSummary -> MetricsSummary -> Bool
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]
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
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. 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.
--
-- 'suppressedLinesOfCodeCount', 'metricsSummary_suppressedLinesOfCodeCount' - Lines of code suppressed in the code review based on the @excludeFiles@
-- element in the @aws-codeguru-reviewer.yml@ file. For full repository
-- analyses, this number includes all lines of code in the files that are
-- suppressed. For pull requests, this number only includes the /changed/
-- lines of code that are suppressed. In both cases, this number does not
-- include non-code lines such as comments and import statements. For
-- example, if you initiate a full repository analysis on a repository
-- containing 5 files, each file with 100 lines of code, and 2 files are
-- listed as excluded in the @aws-codeguru-reviewer.yml@ file, then
-- @SuppressedLinesOfCodeCount@ returns 200 (2 * 100) as the total number
-- of lines of code suppressed. However, if you submit a pull request for
-- the same repository, then @SuppressedLinesOfCodeCount@ only includes the
-- lines in the 2 files that changed. If only 1 of the 2 files changed in
-- the pull request, then @SuppressedLinesOfCodeCount@ returns 100 (1 *
-- 100) as the total number of lines of code suppressed.
newMetricsSummary ::
  MetricsSummary
newMetricsSummary :: MetricsSummary
newMetricsSummary =
  MetricsSummary'
    { $sel:findingsCount:MetricsSummary' :: Maybe Integer
findingsCount = forall a. Maybe a
Prelude.Nothing,
      $sel:meteredLinesOfCodeCount:MetricsSummary' :: Maybe Integer
meteredLinesOfCodeCount = forall a. Maybe a
Prelude.Nothing,
      $sel:suppressedLinesOfCodeCount:MetricsSummary' :: Maybe Integer
suppressedLinesOfCodeCount = 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 :: Lens' MetricsSummary (Maybe Integer)
metricsSummary_findingsCount = 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 :: Lens' MetricsSummary (Maybe Integer)
metricsSummary_meteredLinesOfCodeCount = 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)

-- | Lines of code suppressed in the code review based on the @excludeFiles@
-- element in the @aws-codeguru-reviewer.yml@ file. For full repository
-- analyses, this number includes all lines of code in the files that are
-- suppressed. For pull requests, this number only includes the /changed/
-- lines of code that are suppressed. In both cases, this number does not
-- include non-code lines such as comments and import statements. For
-- example, if you initiate a full repository analysis on a repository
-- containing 5 files, each file with 100 lines of code, and 2 files are
-- listed as excluded in the @aws-codeguru-reviewer.yml@ file, then
-- @SuppressedLinesOfCodeCount@ returns 200 (2 * 100) as the total number
-- of lines of code suppressed. However, if you submit a pull request for
-- the same repository, then @SuppressedLinesOfCodeCount@ only includes the
-- lines in the 2 files that changed. If only 1 of the 2 files changed in
-- the pull request, then @SuppressedLinesOfCodeCount@ returns 100 (1 *
-- 100) as the total number of lines of code suppressed.
metricsSummary_suppressedLinesOfCodeCount :: Lens.Lens' MetricsSummary (Prelude.Maybe Prelude.Integer)
metricsSummary_suppressedLinesOfCodeCount :: Lens' MetricsSummary (Maybe Integer)
metricsSummary_suppressedLinesOfCodeCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MetricsSummary' {Maybe Integer
suppressedLinesOfCodeCount :: Maybe Integer
$sel:suppressedLinesOfCodeCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
suppressedLinesOfCodeCount} -> Maybe Integer
suppressedLinesOfCodeCount) (\s :: MetricsSummary
s@MetricsSummary' {} Maybe Integer
a -> MetricsSummary
s {$sel:suppressedLinesOfCodeCount:MetricsSummary' :: Maybe Integer
suppressedLinesOfCodeCount = Maybe Integer
a} :: MetricsSummary)

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

instance Prelude.Hashable MetricsSummary where
  hashWithSalt :: Int -> MetricsSummary -> Int
hashWithSalt Int
_salt MetricsSummary' {Maybe Integer
suppressedLinesOfCodeCount :: Maybe Integer
meteredLinesOfCodeCount :: Maybe Integer
findingsCount :: Maybe Integer
$sel:suppressedLinesOfCodeCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
$sel:meteredLinesOfCodeCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
$sel:findingsCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
findingsCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
meteredLinesOfCodeCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
suppressedLinesOfCodeCount

instance Prelude.NFData MetricsSummary where
  rnf :: MetricsSummary -> ()
rnf MetricsSummary' {Maybe Integer
suppressedLinesOfCodeCount :: Maybe Integer
meteredLinesOfCodeCount :: Maybe Integer
findingsCount :: Maybe Integer
$sel:suppressedLinesOfCodeCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
$sel:meteredLinesOfCodeCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
$sel:findingsCount:MetricsSummary' :: MetricsSummary -> Maybe Integer
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
findingsCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
meteredLinesOfCodeCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
suppressedLinesOfCodeCount