Showing 1,235 of 1,235 total issues
Similar blocks of code found in 3 locations. Consider refactoring. Open
await expect(
page
.getByTestId("consumer-table")
.locator("tr")
.getByRole("textbox")
- 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 49.
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
Similar blocks of code found in 3 locations. Consider refactoring. Open
await expect(
page
.getByTestId("consumer-table")
.locator("tr")
.getByRole("textbox")
- 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 49.
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
Method uploader.createFileItem
has 6 return statements (exceeds 4 allowed). Open
func (u *uploader) createFileItem(path, method string, obj fileObject) error {
parent := path
parent = strings.ReplaceAll(parent, "\\", "/")
if method == "POST" {
Function fetchSecret
has 6 return statements (exceeds 4 allowed). Open
func fetchSecret(db *database.SQLStore, namespace string, callExpression string) (string, error) {
callExpression = strings.TrimSpace(callExpression)
if !strings.HasPrefix(callExpression, "fetchSecret") {
return callExpression, nil
}
Method forEachLogic.scheduleRetryAction
has 6 return statements (exceeds 4 allowed). Open
func (logic *forEachLogic) scheduleRetryAction(ctx context.Context, retry *actionRetryInfo) error {
logic.Log(ctx, log.Info, "Retrying...")
x, err := jqOne(logic.GetInstanceData(), logic.Array) //nolint:contextcheck
if err != nil {
Method forEachLogic.scheduleFirstActions
has 6 return statements (exceeds 4 allowed). Open
func (logic *forEachLogic) scheduleFirstActions(ctx context.Context) (*Transition, error) {
x, err := jqOne(logic.GetInstanceData(), logic.Array) //nolint:contextcheck
if err != nil {
return nil, err
}
Method forEachLogic.scheduleAction
has 6 return statements (exceeds 4 allowed). Open
func (logic *forEachLogic) scheduleAction(ctx context.Context, inputSource interface{}, attempt, iterator int) (*ChildInfo, error) {
action := logic.Action
input, files, err := generateActionInput(ctx, &generateActionInputArgs{
Instance: logic.Instance,
Method parallelLogic.scheduleAction
has 6 return statements (exceeds 4 allowed). Open
func (logic *parallelLogic) scheduleAction(ctx context.Context, action *model.ActionDefinition, attempt int) (*ChildInfo, error) {
input, files, err := generateActionInput(ctx, &generateActionInputArgs{
Instance: logic.Instance,
Source: logic.GetInstanceData(),
Action: action,
Method DirektivApplyer.copyFilesIntoRoot
has 6 return statements (exceeds 4 allowed). Open
func (o *DirektivApplyer) copyFilesIntoRoot(ctx context.Context) error {
paths, err := o.parser.ListFiles()
if err != nil {
return err
}
Method instanceMemory.flushUpdates
has 6 return statements (exceeds 4 allowed). Open
func (im *instanceMemory) flushUpdates(ctx context.Context) error {
data, err := json.Marshal(im.updateArgs)
if err != nil {
panic(err)
}
Method engine.EventsInvoke
has 6 return statements (exceeds 4 allowed). Open
func (engine *engine) EventsInvoke(tctx context.Context, workflowID uuid.UUID, events ...*cloudevents.Event) {
ctx := context.Background()
tx, err := engine.flow.beginSQLTx(ctx)
if err != nil {
Method ACLPlugin.Execute
has 6 return statements (exceeds 4 allowed). Open
func (acl *ACLPlugin) Execute(w http.ResponseWriter, r *http.Request) *http.Request {
c := gateway.ExtractContextActiveConsumer(r)
if c == nil {
gateway.WriteInternalError(r, w, nil, "missing consumer")
return nil
Function getVariableMetaFromFlow
has 6 return statements (exceeds 4 allowed). Open
func getVariableMetaFromFlow(ctx context.Context, flowToken string, flowAddr string, ir *functionRequest, scope, key string) (variable, int, error) {
var varResp *variablesResponse
var err error
var typ string
statusCode := http.StatusOK
Method JSInboundPlugin.Execute
has 6 return statements (exceeds 4 allowed). Open
func (js *JSInboundPlugin) Execute(w http.ResponseWriter, r *http.Request) *http.Request {
var (
err error
b []byte
)
Method instanceDataQuery.PopMessage
has 6 return statements (exceeds 4 allowed). Open
func (q *instanceDataQuery) PopMessage(ctx context.Context) (*instancestore.InstanceMessageData, error) {
columns := []string{fieldInstanceMessageID, fieldInstanceMessageInstanceID, fieldInstanceMessageCreatedAt, fieldInstanceMessagePayload}
query := fmt.Sprintf(`SELECT %s FROM %s WHERE %s = ? ORDER BY %s ASC LIMIT 1`, strings.Join(columns, ", "), messagesTable, fieldInstanceMessageInstanceID, fieldInstanceMessageCreatedAt)
msg := &instancestore.InstanceMessageData{}
Method actionLogic.processActionResults
has 6 return statements (exceeds 4 allowed). Open
func (logic *actionLogic) processActionResults(ctx context.Context, children []*ChildInfo, results *actionResultPayload) (*Transition, error) {
var err error
sd := children[0]
Method GenerateEventState.Validate
has 6 return statements (exceeds 4 allowed). Open
func (o *GenerateEventState) Validate() error {
if err := o.commonValidate(); err != nil {
return err
}
Function writeDataStoreError
has 6 return statements (exceeds 4 allowed). Open
func writeDataStoreError(w http.ResponseWriter, err error) {
if errors.Is(err, datastore.ErrNotFound) {
writeError(w, &Error{
Code: "resource_not_found",
Message: "requested resource is not found",
Method knativeClient.createService
has 6 return statements (exceeds 4 allowed). Open
func (c *knativeClient) createService(sv *core.ServiceFileData) error {
if sv.Image == "" {
return errors.New("image field is empty or not set")
}
Method sqlEventListenerStore.GetByID
has 6 return statements (exceeds 4 allowed). Open
func (s *sqlEventListenerStore) GetByID(ctx context.Context, id uuid.UUID) (*datastore.EventListener, error) {
q := "SELECT id, namespace_id, namespace, created_at, updated_at, received_events, trigger_type, events_lifespan, event_types, trigger_info, metadata, event_context_filters FROM event_listeners WHERE id = $1 ;"
var l gormEventListener
tx := s.db.WithContext(ctx).Raw(q, id).First(&l)
if tx.Error != nil {