Showing 107 of 107 total issues
Method Manager.cleanupTaskHistory
has 7 return statements (exceeds 4 allowed). Open
func (m *Manager) cleanupTaskHistory(ctx context.Context, req *logical.Request) error {
// define taskHistoryLimit
taskHistoryLimit := fieldDefaultTaskHistoryLimit
{
config, err := getConfiguration(ctx, req.Storage)
Function ReadTarFromImageBuildResponse
has 7 return statements (exceeds 4 allowed). Open
func ReadTarFromImageBuildResponse(tarWriter, buildLogWriter io.Writer, response types.ImageBuildResponse) error {
dec := json.NewDecoder(response.Body)
currentState := checkingStartCode
var codeCursor int
var bufferedData []byte
Function buildReleaseArtifacts
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func buildReleaseArtifacts(ctx context.Context, tarWriter *nio.PipeWriter, gitRepo *git.Repository, fromImage string, runCommands []string, logger hclog.Logger) (error, func() error) {
Method Client.setup
has 7 return statements (exceeds 4 allowed). Open
func (c *Client) setup(rootVersion int64, rootSha512 string) error {
var rootBasename string
if rootVersion == 0 {
rootBasename = "root.json"
} else {
Function addCmd
has 7 return statements (exceeds 4 allowed). Open
func addCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add REPO URL ROOT_VERSION ROOT_SHA512",
Short: "Add a software repository",
DisableFlagsInUseLine: true,
Avoid deeply nested control flow statements. Open
} else if _, err := buildLogWriter.Write([]byte{b}); err != nil {
return fmt.Errorf("build log writer failed: %w", err)
}
Function verifyObjectSignatures
has 7 return statements (exceeds 4 allowed). Open
func verifyObjectSignatures(repo *git.Repository, objectID string, trustedPGPPublicKeys []string, requiredNumberOfVerifiedSignatures int, logger hclog.Logger) error {
signatures, err := objectSignaturesFromNotes(repo, objectID)
if err != nil {
if strings.HasSuffix(err.Error(), plumbing.ErrObjectNotFound.Error()) {
logger.Debug(fmt.Sprintf("[DEBUG-SIGNATURES] git object not found (%s): exiting", err))
Avoid deeply nested control flow statements. Open
if _, err := buildLogWriter.Write(append(startReadCodeSuspectedBytes, b)); err != nil {
return fmt.Errorf("build log writer failed: %w", err)
}
Function dirPathCmd
has 7 return statements (exceeds 4 allowed). Open
func dirPathCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "dir-path REPO GROUP [CHANNEL]",
Short: "Get the directory with software artifacts",
DisableFlagsInUseLine: true,
Identical blocks of code found in 2 locations. Consider refactoring. Open
func indexRuneWithEscaping(s string, r rune) int {
end := strings.IndexRune(s, r)
if end == -1 {
return -1
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 111.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Identical blocks of code found in 2 locations. Consider refactoring. Open
func indexRuneWithEscaping(s string, r rune) int {
end := strings.IndexRune(s, r)
if end == -1 {
return -1
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 111.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function execCmd
has 6 return statements (exceeds 4 allowed). Open
func execCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "exec REPO GROUP [CHANNEL] [BINARY_NAME] [--] [ARGS]",
Short: "Exec a software binary",
DisableFlagsInUseLine: true,
Method Client.findChannelReleaseBinPath
has 6 return statements (exceeds 4 allowed). Open
func (c Client) findChannelReleaseBinPath(group, channel, optionalBinName string) (string, error) {
dir, releaseName, err := c.findChannelReleaseBinDir(group, channel)
if err != nil {
return "", err
}
Function setDefaultChannelCmd
has 6 return statements (exceeds 4 allowed). Open
func setDefaultChannelCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "set-default-channel REPO CHANNEL",
Short: "Set a default channel for a registered repository",
Long: `Set a default channel for a registered repository.
Method Publisher.GetRepository
has 6 return statements (exceeds 4 allowed). Open
func (publisher *Publisher) GetRepository(ctx context.Context, storage logical.Storage, options RepositoryOptions) (RepositoryInterface, error) {
publisher.mu.Lock()
defer publisher.mu.Unlock()
awsConfig := &aws.Config{
Function switchTaskToRunningInStorage
has 6 return statements (exceeds 4 allowed). Open
func switchTaskToRunningInStorage(ctx context.Context, storage logical.Storage, uuid string) error {
// get previous task state from storage
var prevTask *Task
{
t, err := getTaskFromStorage(ctx, storage, taskStateQueued, uuid)
Method Client.initTufClient
has 6 return statements (exceeds 4 allowed). Open
func (c *Client) initTufClient() error {
localDB, err := leveldbstore.FileLocalStore(c.metaLocalStoreDir)
if err != nil {
return fmt.Errorf("unable to init file local store: %w", err)
}
Method Client.CleanReleases
has 6 return statements (exceeds 4 allowed). Open
func (c Client) CleanReleases() error {
actualLocalReleases, err := c.getActualLocalReleases()
if err != nil {
return fmt.Errorf("unable to get actual local releases: %w", err)
}
Function NewCmdGenerateJekyll
has 6 return statements (exceeds 4 allowed). Open
func NewCmdGenerateJekyll() *cobra.Command {
cmd := &cobra.Command{
Use: "generate-jekyll",
Short: "Generate plugin path help as jekyll pages",
Example: "vault-plugin-docs generate-jekyll",
Function removeCmd
has 6 return statements (exceeds 4 allowed). Open
func removeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "remove REPO",
Short: "Remove a software repository",
DisableFlagsInUseLine: true,