janritter/aws-lambda-live-tuner

View on GitHub

Showing 3 of 5 total issues

Function pricing_for_region_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def pricing_for_region_list(response):
    results = []
    for price in response["PriceList"]:
        product = json.loads(price)['product']
        terms  = json.loads(price)['terms']
Severity: Minor
Found in scripts/lambda-cost.py - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method Analyzer.CheckInvocations has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
Open

func (a *Analyzer) CheckInvocations(memory int) (map[string]float64, error) {
    startTimeDiff := getStartTimeDiff(a.waitTime)

    output, err := a.cloudwatch.StartQuery(&cloudwatchlogs.StartQueryInput{
        QueryString:  aws.String(fmt.Sprintf(`filter @type = "REPORT" and @message like "Memory Size: %d MB"`, memory)),
Severity: Minor
Found in analyzer/cloudwatch.go - About 1 hr to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method Analyzer.CheckInvocations has 5 return statements (exceeds 4 allowed).
Open

func (a *Analyzer) CheckInvocations(memory int) (map[string]float64, error) {
    startTimeDiff := getStartTimeDiff(a.waitTime)

    output, err := a.cloudwatch.StartQuery(&cloudwatchlogs.StartQueryInput{
        QueryString:  aws.String(fmt.Sprintf(`filter @type = "REPORT" and @message like "Memory Size: %d MB"`, memory)),
Severity: Major
Found in analyzer/cloudwatch.go - About 35 mins to fix
    Severity
    Category
    Status
    Source
    Language