codegurureviewer

package
v1.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 35 Imported by: 0

README

Codegurureviewer

Parity grade: B · SDK aws-sdk-go-v2/service/codegurureviewer@v1.43.4 · last audited 2026-10-18 (8d07d8213)

Coverage

Metric Value
PARITY entries audited 14 (14 ok)
Feature families 3 (3 ok)
Known gaps 6
Structural gaps (can't be emulated) 2
Deferred items 0
Resource leaks clean
Known gaps
  • PullRequest reviews: CreateCodeReview only creates RepositoryAnalysis reviews, so ListCodeReviews Type=PullRequest is always empty; the emulator has no provider webhook that opens a pull-request review
  • aws-codeguru-reviewer.yml: ConfigFileState reports Present/Absent by file presence; the contents (excluded paths) are not parsed, so SuppressedLinesOfCodeCount is always 0 and PresentWithErrors is never returned
  • ConnectionArn of Bitbucket/GitHub Enterprise Server associations is stored, not looked up in the CodeConnections/CodeStar Connections emulators
  • KMSKeyDetails.KMSKeyId is stored, not looked up in the KMS emulator
  • Error codes per operation (NotFoundException for associations, ResourceNotFoundException for reviews, feedback and tags) are an emulator choice; the SDK documents the exception set but not which operation raises which
  • ResourceGroupsTaggingAPI does not expose association tags
Structural gaps

These do not block an A grade — no implementation could produce real data here because the underlying data source cannot exist in an emulator.

  • Reviews of Bitbucket, GitHub and GitHub Enterprise Server repositories fail with an explanatory StateReason: there is no emulated source host to clone from.
  • CodeGuru's ML detectors cannot exist here; findings come from the five documented heuristics only, and MeteredLinesOfCodeCount counts non-blank lines of recognised code files.

More

Documentation

Overview

Package codegurureviewer emulates Amazon CodeGuru Reviewer: repository associations, code reviews that run a deterministic static rule set over the repository's real source, recommendations and feedback.

Index

Constants

This section is empty.

Variables

View Source
var ErrNilAppContext = errors.New("codegurureviewer: AppContext must not be nil")

ErrNilAppContext is returned by Init when no AppContext is supplied.

Functions

This section is empty.

Types

type AssociateRepositoryInput

type AssociateRepositoryInput struct {
	Repository         *Repository       `json:"Repository"`
	KMSKeyDetails      *KMSKeyDetails    `json:"KMSKeyDetails,omitempty"`
	Tags               map[string]string `json:"Tags,omitempty"`
	ClientRequestToken string            `json:"ClientRequestToken,omitempty"`
}

AssociateRepositoryInput is the AssociateRepository request.

type AssociationOutput

type AssociationOutput struct {
	RepositoryAssociation *RepositoryAssociation `json:"RepositoryAssociation"`
	Tags                  map[string]string      `json:"Tags,omitempty"`
}

AssociationOutput is the Associate/Describe/DisassociateRepository response.

type CodeArtifacts

type CodeArtifacts struct {
	BuildArtifactsObjectKey      string `json:"BuildArtifactsObjectKey,omitempty"`
	SourceCodeArtifactsObjectKey string `json:"SourceCodeArtifactsObjectKey,omitempty"`
}

CodeArtifacts holds the S3 keys of the source and build archives.

type CodeCommitRepository

type CodeCommitRepository struct {
	Name string `json:"Name"`
}

CodeCommitRepository names a CodeCommit repository.

type CodeReview

type CodeReview struct {
	CreatedTimeStamp     awstime.EpochTime `json:"CreatedTimeStamp"`
	LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
	Metrics              *Metrics          `json:"Metrics,omitempty"`
	SourceCodeType       *SourceCodeType   `json:"SourceCodeType,omitempty"`
	RepositoryName       string            `json:"RepositoryName"`
	AssociationArn       string            `json:"AssociationArn"`
	CodeReviewArn        string            `json:"CodeReviewArn"`
	ConfigFileState      string            `json:"ConfigFileState,omitempty"`
	Name                 string            `json:"Name"`
	Owner                string            `json:"Owner"`
	ProviderType         string            `json:"ProviderType"`
	PullRequestID        string            `json:"PullRequestId,omitempty"`
	State                string            `json:"State"`
	StateReason          string            `json:"StateReason,omitempty"`
	Type                 string            `json:"Type"`
	AnalysisTypes        []string          `json:"AnalysisTypes,omitempty"`
}

CodeReview is the wire shape of a review.

type CodeReviewOutput

type CodeReviewOutput struct {
	CodeReview *CodeReview `json:"CodeReview"`
}

CodeReviewOutput is the Create/DescribeCodeReview response.

type CodeReviewSummary

type CodeReviewSummary struct {
	CreatedTimeStamp     awstime.EpochTime `json:"CreatedTimeStamp"`
	LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
	MetricsSummary       *MetricsSummary   `json:"MetricsSummary,omitempty"`
	SourceCodeType       *SourceCodeType   `json:"SourceCodeType,omitempty"`
	CodeReviewArn        string            `json:"CodeReviewArn"`
	Name                 string            `json:"Name"`
	Owner                string            `json:"Owner"`
	ProviderType         string            `json:"ProviderType"`
	PullRequestID        string            `json:"PullRequestId,omitempty"`
	RepositoryName       string            `json:"RepositoryName"`
	State                string            `json:"State"`
	Type                 string            `json:"Type"`
}

CodeReviewSummary is the list shape of a review.

type CodeReviewType

type CodeReviewType struct {
	RepositoryAnalysis *RepositoryAnalysis `json:"RepositoryAnalysis,omitempty"`
	AnalysisTypes      []string            `json:"AnalysisTypes,omitempty"`
}

CodeReviewType is the CreateCodeReview type; only RepositoryAnalysis can be created.

type CreateCodeReviewInput

type CreateCodeReviewInput struct {
	Type                     *CodeReviewType `json:"Type"`
	Name                     string          `json:"Name"`
	RepositoryAssociationArn string          `json:"RepositoryAssociationArn"`
	ClientRequestToken       string          `json:"ClientRequestToken,omitempty"`
}

CreateCodeReviewInput is the CreateCodeReview request.

type DescribeFeedbackInput

type DescribeFeedbackInput struct {
	CodeReviewArn    string `json:"-" path:"CodeReviewArn"`
	RecommendationID string `json:"-"                      query:"RecommendationId"`
	UserID           string `json:"-"                      query:"UserId"`
}

DescribeFeedbackInput is the DescribeRecommendationFeedback request.

type DescribeFeedbackOutput

type DescribeFeedbackOutput struct {
	RecommendationFeedback *RecommendationFeedback `json:"RecommendationFeedback"`
}

DescribeFeedbackOutput is the DescribeRecommendationFeedback response.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	DefaultRegion string
	// contains filtered or unexported fields
}

Handler serves the CodeGuru Reviewer REST-JSON API.

func NewHandler

func NewHandler(backend *InMemoryBackend) *Handler

NewHandler wraps a backend.

func (*Handler) ChaosOperations

func (h *Handler) ChaosOperations() []string

ChaosOperations lists the fault-injectable operations.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions lists the regions served.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns the lowercase service name for fault rules.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation returns the operation name for metrics.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource returns the first path label for metrics.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations lists every routed operation.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns the Echo handler.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns the routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns the service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears all state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher matches by SigV4 signing name (or SDK user agent) plus a known path shape.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend holds associations, reviews and feedback behind one coarse lock.

func NewInMemoryBackend

func NewInMemoryBackend(accountID, region string) *InMemoryBackend

NewInMemoryBackend creates an empty backend.

func (*InMemoryBackend) AssociateRepository

func (b *InMemoryBackend) AssociateRepository(
	ctx context.Context,
	in *AssociateRepositoryInput,
) (*associationRecord, error)

AssociateRepository starts associating a repository; it reads Associated once the lifecycle window passes.

func (*InMemoryBackend) CreateCodeReview

func (b *InMemoryBackend) CreateCodeReview(ctx context.Context, in *CreateCodeReviewInput) (*reviewRecord, error)

CreateCodeReview analyzes the associated repository's source with the static rule set and records the findings. The review reads Pending until the lifecycle window passes, then Completed (or Failed when the source is unreadable).

func (*InMemoryBackend) DescribeRecommendationFeedback

func (b *InMemoryBackend) DescribeRecommendationFeedback(
	ctx context.Context, in *DescribeFeedbackInput,
) (*RecommendationFeedback, error)

DescribeRecommendationFeedback returns one user's feedback; the caller's when UserId is omitted.

func (*InMemoryBackend) DescribeRepositoryAssociation

func (b *InMemoryBackend) DescribeRepositoryAssociation(arn string) (*associationRecord, error)

DescribeRepositoryAssociation returns an association with its current state.

func (*InMemoryBackend) DisassociateRepository

func (b *InMemoryBackend) DisassociateRepository(arn string) (*associationRecord, error)

DisassociateRepository starts disassociating; it reads Disassociated once the lifecycle window passes.

func (*InMemoryBackend) GetCodeReview

func (b *InMemoryBackend) GetCodeReview(arn string) (*reviewRecord, error)

GetCodeReview returns a review by ARN.

func (*InMemoryBackend) ListCodeReviews

func (b *InMemoryBackend) ListCodeReviews(in *ListCodeReviewsInput) ([]CodeReviewSummary, string, error)

ListCodeReviews lists reviews of one type, newest first.

func (*InMemoryBackend) ListRecommendationFeedback

func (b *InMemoryBackend) ListRecommendationFeedback(
	in *ListFeedbackInput,
) ([]RecommendationFeedbackSummary, string, error)

ListRecommendationFeedback lists the feedback given on a review, filtered by user and recommendation.

func (*InMemoryBackend) ListRecommendations

func (b *InMemoryBackend) ListRecommendations(arn, token string, maxResults int32) ([]Recommendation, string, error)

ListRecommendations pages through a completed review's findings; a review still running has none yet.

func (*InMemoryBackend) ListRepositoryAssociations

func (b *InMemoryBackend) ListRepositoryAssociations(
	in *ListAssociationsInput,
) ([]RepositoryAssociationSummary, string, error)

ListRepositoryAssociations lists associations, filtered by provider, state, name and owner.

func (*InMemoryBackend) ListTagsForResource

func (b *InMemoryBackend) ListTagsForResource(arn string) (map[string]string, error)

ListTagsForResource returns a copy of the association's tags.

func (*InMemoryBackend) PutRecommendationFeedback

func (b *InMemoryBackend) PutRecommendationFeedback(ctx context.Context, in *PutFeedbackInput) error

PutRecommendationFeedback records the caller's reactions to a recommendation; an empty list clears them.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset clears every table.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads a snapshot; an incompatible version is discarded.

func (*InMemoryBackend) SetAppConfig

func (b *InMemoryBackend) SetAppConfig(cfg any)

SetAppConfig records the service.AppContext.Config for lazy CodeCommit and S3 lookups.

func (*InMemoryBackend) SetClock

func (b *InMemoryBackend) SetClock(now func() time.Time)

SetClock replaces the time source.

func (*InMemoryBackend) SetLifecycleDelay

func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)

SetLifecycleDelay overrides how long associations and reviews stay in a transitional state.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises the backend state.

func (*InMemoryBackend) TagResource

func (b *InMemoryBackend) TagResource(arn string, add map[string]string) error

TagResource adds or replaces tags on a repository association.

func (*InMemoryBackend) UntagResource

func (b *InMemoryBackend) UntagResource(arn string, keys []string) error

UntagResource removes tags by key.

type KMSKeyDetails

type KMSKeyDetails struct {
	EncryptionOption string `json:"EncryptionOption,omitempty"`
	KMSKeyID         string `json:"KMSKeyId,omitempty"`
}

KMSKeyDetails is the repository encryption setting.

type ListAssociationsInput

type ListAssociationsInput struct {
	NextToken     string   `json:"-" query:"NextToken"`
	ProviderTypes []string `json:"-" query:"ProviderType"`
	States        []string `json:"-" query:"State"`
	Names         []string `json:"-" query:"Name"`
	Owners        []string `json:"-" query:"Owner"`
	MaxResults    int32    `json:"-" query:"MaxResults"`
}

ListAssociationsInput is the ListRepositoryAssociations request.

type ListAssociationsOutput

type ListAssociationsOutput struct {
	NextToken                      string `json:",omitempty"`
	RepositoryAssociationSummaries []RepositoryAssociationSummary
}

ListAssociationsOutput is the ListRepositoryAssociations response.

type ListCodeReviewsInput

type ListCodeReviewsInput struct {
	Type            string   `json:"-" query:"Type"`
	NextToken       string   `json:"-" query:"NextToken"`
	ProviderTypes   []string `json:"-" query:"ProviderTypes"`
	States          []string `json:"-" query:"States"`
	RepositoryNames []string `json:"-" query:"RepositoryNames"`
	MaxResults      int32    `json:"-" query:"MaxResults"`
}

ListCodeReviewsInput is the ListCodeReviews request.

type ListCodeReviewsOutput

type ListCodeReviewsOutput struct {
	NextToken           string `json:",omitempty"`
	CodeReviewSummaries []CodeReviewSummary
}

ListCodeReviewsOutput is the ListCodeReviews response.

type ListFeedbackInput

type ListFeedbackInput struct {
	CodeReviewArn     string   `json:"-" path:"CodeReviewArn"`
	NextToken         string   `json:"-"                      query:"NextToken"`
	UserIDs           []string `json:"-"                      query:"UserIds"`
	RecommendationIDs []string `json:"-"                      query:"RecommendationIds"`
	MaxResults        int32    `json:"-"                      query:"MaxResults"`
}

ListFeedbackInput is the ListRecommendationFeedback request.

type ListFeedbackOutput

type ListFeedbackOutput struct {
	NextToken                       string `json:",omitempty"`
	RecommendationFeedbackSummaries []RecommendationFeedbackSummary
}

ListFeedbackOutput is the ListRecommendationFeedback response.

type Metrics

type Metrics struct {
	FindingsCount              int64 `json:"FindingsCount"`
	MeteredLinesOfCodeCount    int64 `json:"MeteredLinesOfCodeCount"`
	SuppressedLinesOfCodeCount int64 `json:"SuppressedLinesOfCodeCount"`
}

Metrics are the totals of a completed review.

type MetricsSummary

type MetricsSummary = Metrics

MetricsSummary is the list shape of Metrics.

type Provider

type Provider struct{}

Provider implements service.Provider.

func (*Provider) Init

Init builds the backend and handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

type PutFeedbackInput

type PutFeedbackInput struct {
	CodeReviewArn    string   `json:"CodeReviewArn"`
	RecommendationID string   `json:"RecommendationId"`
	Reactions        []string `json:"Reactions"`
}

PutFeedbackInput is the PutRecommendationFeedback request.

type Recommendation

type Recommendation struct {
	RuleMetadata           *RuleMetadata `json:"RuleMetadata,omitempty"`
	Description            string        `json:"Description"`
	FilePath               string        `json:"FilePath"`
	RecommendationCategory string        `json:"RecommendationCategory"`
	RecommendationID       string        `json:"RecommendationId"`
	Severity               string        `json:"Severity"`
	StartLine              int32         `json:"StartLine"`
	EndLine                int32         `json:"EndLine"`
}

Recommendation is one finding of a review (wire RecommendationSummary).

type RecommendationFeedback

type RecommendationFeedback struct {
	CreatedTimeStamp     awstime.EpochTime `json:"CreatedTimeStamp"`
	LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
	CodeReviewArn        string            `json:"CodeReviewArn"`
	RecommendationID     string            `json:"RecommendationId"`
	UserID               string            `json:"UserId"`
	Reactions            []string          `json:"Reactions"`
}

RecommendationFeedback is one user's reactions to one recommendation.

type RecommendationFeedbackSummary

type RecommendationFeedbackSummary struct {
	RecommendationID string   `json:"RecommendationId"`
	UserID           string   `json:"UserId"`
	Reactions        []string `json:"Reactions"`
}

RecommendationFeedbackSummary is the list shape of feedback.

type Repository

type Repository struct {
	Bitbucket              *ThirdPartySourceRepository `json:"Bitbucket,omitempty"`
	CodeCommit             *CodeCommitRepository       `json:"CodeCommit,omitempty"`
	GitHubEnterpriseServer *ThirdPartySourceRepository `json:"GitHubEnterpriseServer,omitempty"`
	S3Bucket               *S3Repository               `json:"S3Bucket,omitempty"`
}

Repository is the AssociateRepository union.

type RepositoryAnalysis

type RepositoryAnalysis struct {
	RepositoryHead *RepositoryHead `json:"RepositoryHead,omitempty"`
	SourceCodeType *SourceCodeType `json:"SourceCodeType,omitempty"`
}

RepositoryAnalysis is the CreateCodeReview repository-analysis request.

type RepositoryAssociation

type RepositoryAssociation struct {
	CreatedTimeStamp     awstime.EpochTime    `json:"CreatedTimeStamp"`
	LastUpdatedTimeStamp awstime.EpochTime    `json:"LastUpdatedTimeStamp"`
	KMSKeyDetails        *KMSKeyDetails       `json:"KMSKeyDetails,omitempty"`
	S3RepositoryDetails  *S3RepositoryDetails `json:"S3RepositoryDetails,omitempty"`
	AssociationArn       string               `json:"AssociationArn"`
	AssociationID        string               `json:"AssociationId"`
	ConnectionArn        string               `json:"ConnectionArn,omitempty"`
	Name                 string               `json:"Name"`
	Owner                string               `json:"Owner"`
	ProviderType         string               `json:"ProviderType"`
	State                string               `json:"State"`
	StateReason          string               `json:"StateReason,omitempty"`
}

RepositoryAssociation is the wire shape of an association.

type RepositoryAssociationSummary

type RepositoryAssociationSummary struct {
	LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
	AssociationArn       string            `json:"AssociationArn"`
	AssociationID        string            `json:"AssociationId"`
	ConnectionArn        string            `json:"ConnectionArn,omitempty"`
	Name                 string            `json:"Name"`
	Owner                string            `json:"Owner"`
	ProviderType         string            `json:"ProviderType"`
	State                string            `json:"State"`
}

RepositoryAssociationSummary is the list shape of an association.

type RepositoryHead

type RepositoryHead struct {
	BranchName string `json:"BranchName"`
}

RepositoryHead selects a branch.

type RuleMetadata

type RuleMetadata struct {
	LongDescription  string   `json:"LongDescription,omitempty"`
	RuleID           string   `json:"RuleId,omitempty"`
	RuleName         string   `json:"RuleName,omitempty"`
	ShortDescription string   `json:"ShortDescription,omitempty"`
	RuleTags         []string `json:"RuleTags,omitempty"`
}

RuleMetadata describes the rule behind a recommendation.

type S3BucketRepository

type S3BucketRepository struct {
	Details *S3RepositoryDetails `json:"Details,omitempty"`
	Name    string               `json:"Name"`
}

S3BucketRepository is the S3 member of SourceCodeType.

type S3Repository

type S3Repository struct {
	BucketName string `json:"BucketName"`
	Name       string `json:"Name"`
}

S3Repository names an S3 repository to associate.

type S3RepositoryDetails

type S3RepositoryDetails struct {
	CodeArtifacts *CodeArtifacts `json:"CodeArtifacts,omitempty"`
	BucketName    string         `json:"BucketName,omitempty"`
}

S3RepositoryDetails locates an S3 repository's archives.

type SourceCodeType

type SourceCodeType struct {
	RepositoryHead     *RepositoryHead     `json:"RepositoryHead,omitempty"`
	S3BucketRepository *S3BucketRepository `json:"S3BucketRepository,omitempty"`
}

SourceCodeType says which code a review analyzes.

type ThirdPartySourceRepository

type ThirdPartySourceRepository struct {
	ConnectionArn string `json:"ConnectionArn"`
	Name          string `json:"Name"`
	Owner         string `json:"Owner"`
}

ThirdPartySourceRepository names a Bitbucket or GitHub Enterprise Server repository.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL