abir18/sample_suggestion_acceptance huggingface dataset:
Original:  return err
Modified:      return il.session.Close()
Suggestion accepted: True
Original:                return fmt.Errorf("%w", ErrEmptyEndPoints)
Modified:           return ErrEmptyEndPoints
Suggestion accepted: False
Original:        ErrEmptyUserName = errors.New("etcd username cannot be nil or empty")
Modified:       //ErrEmptyEndpoints occurs when the endpoints in the config is empty.   ErrEmptyEndpoints = errors.New("length of etcd endpoints must be greater than 0")     // ErrEmptyUsername occurs when the username is empty.  ErrEmptyUsername = errors.New("etcd username cannot be nil or empty")
Suggestion accepted: False
Original: package etcd
Modified: /* * Copyright 2021 The Yorkie Authors. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package etcd
Suggestion accepted: True
Original:          unauthorizedTTLSec := 1 * time.Second
Modified:           unauthorizedTTL := 1 * time.Second
Suggestion accepted: True
Original:          authorizedTTLSec := 1 * time.Second
Modified:             authorizedTTL := 1 * time.Second
Suggestion accepted: True
Original:                        unauthorizedTTL, ttlParseErr := time.ParseDuration(be.Config.AuthWebhookCacheUnauthTTL)
Modified:                        unauthorizedTTL := be.Config.ParseAuthWebhookCacheUnauthTTL()
Suggestion accepted: False
Original: )
Modified:      "testing"     "github.com/stretchr/testify/assert"  "github.com/yorkie-team/yorkie/yorkie/backend/db/mongo"       )
Suggestion accepted: False
Original:  }
Modified:       if err := c.Backend.Validate(); err != nil {            return err      }       if err := c.RPC.Validate(); err != nil {                return err      }
Suggestion accepted: True
Original:  // ...
Modified:  // TODO(umi0410): Other validations will be here later. // ...
Suggestion accepted: True
Original:                 operations, err := ToOperations(c.Operations())
Modified:               pbOperations, err := ToOperations(c.Operations())
Suggestion accepted: True
Original:         }
Modified:      if c.Port < 1 || 65535 < c.Port {               return fmt.Errorf("must be between 1 and 65535, given %d : %w", c.Port, ErrInvalidPortNumber) }
Suggestion accepted: False
Original:                 }
Modified:              if _, err = os.Stat(c.CertFile); err != nil {                   return fmt.Errorf("%w: %s", ErrInvalidCertFile, c.CertFile)           }
Suggestion accepted: False
Original:          expect error
Modified:            expected error
Suggestion accepted: True
Original:         ErrWrongPort = errors.New("wrong port number for RPC server")
Modified:       ErrInvalidRPCPort = errors.New("invalid port number for RPC server")
Suggestion accepted: True
Original:         ErrInvalidKeyFile = errors.New("no such key file for RPC server")
Modified:   // ErrInvalidCertFile occurs when the certificate file is invalid.      ErrInvalidCertFile = errors.New("invalid cert file for RPC server")   // ErrInvalidKeyFile occurs when the key file is invalid.       ErrInvalidKeyFile = errors.New("invalid key file for RPC server")
Suggestion accepted: True
Original:          }
Modified:              if _, err := os.Stat(c.CertFile); err != nil {                  return fmt.Errorf("%s: %w", c.CertFile, ErrInvalidCertFile)           }
Suggestion accepted: True
Original:  }
Modified:              if _, err := os.Stat(c.KeyFile); err != nil {                   return fmt.Errorf("%s: %w", c.KeyFile, ErrInvalidKeyFile)             }       }
Suggestion accepted: True
Original: // Validate validates port number and checks if files exists
Modified: // Validate validates the port number and the files for certification.
Suggestion accepted: True
Original: func fromSetIndex(pbInc *api.Operation_SetIndex) (*operation.SetIndex, error) {
Modified: func fromSetIndex(pbSet *api.Operation_SetIndex) (*operation.SetIndex, error) {
Suggestion accepted: False
Original:         AuthorizationWebhookMaxWaitInterval uint64
Modified:     // AuthorizationWebhookMaxRetries is the max count      // that retries the authorization webhook.      AuthorizationWebhookMaxRetries uint64  `json:"AuthorizationWebhookMaxRetries"`        // AuthorizationWebhookMaxWaitIntervalSec is the max interval   // that waits before retrying the authorization webhook.        AuthorizationWebhookMaxWaitIntervalSec uint64 `json:"AuthorizationWebhookMaxWaitIntervalSec"`
Suggestion accepted: False
Original:          c2.Sync(ctx)
Modified:           syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}})
Suggestion accepted: True
Original:          }))
Modified:            syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}})
Suggestion accepted: True
Original:                         root.GetArray("k2").MoveBefore(prev.CreatedAt(), elem.CreatedAt())
Modified:          syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}})
Suggestion accepted: True
Modified:                syncClientsThenAssertEqual(t, []clientAndDocPair{{c1, d1}, {c2, d2}})
Suggestion accepted: True
Original: func toSetByIndex(SetByIndex *operation.SetByIndex) (*api.Operation_SetByIndex_, error) {
Modified: func toSetByIndex(setByIndex *operation.SetByIndex) (*api.Operation_SetByIndex_, error) {
Suggestion accepted: True
Original:                 assert.NoError(t, json.NewDecoder(r.Body).Decode(&req))
Modified:               req, err := types.NewAuthWebhookRequest(r.Body)         assert.NoError(t, err)
Suggestion accepted: True
Original:                                                 }
Modified:                                              switch wr.Type {                                                case client.PeersChanged:                                                       peers := wr.PeersMapByDoc[d1.Key().BSONKey()]                                                   responsePairs = append(responsePairs, watchResponsePair{                                                                Type:  wr.Type,                                                         peers: peers,                                                   })                                              case client.DocumentsChanged:                                                   assert.NoError(t, c1.Sync(ctx, wr.Keys...))                                             }
Suggestion accepted: False
Original:                                          }
Modified:                                              if info, ok := attachment.peers[cli.ID.String()]; ok {                                                  cli.MetadataInfo.Update(info)                                           }
Suggestion accepted: True
Original: const lruExpireCacheSize = 5000
Modified: const authWebhookCacheSize = 5000
Suggestion accepted: True
Original:                lruCache.Add("request1", "response1", time.Second*5)
Modified:              lruCache.Add("request1", "response1", 5*time.Second)
Suggestion accepted: False
Original:                 assert.Equal(t, reqCnt, 2)
Modified:            assert.Equal(t, 2, reqCnt)
Suggestion accepted: True
Original:                assert.Equal(t, reqCnt, 2)
Modified:            var authorizedTTLSec uint64 = 1         conf := helper.TestConfig(server.URL)           conf.Backend.AuthorizationWebhookCacheAuthorizedTTLSec = authorizedTTLSec               agent, err := yorkie.New(conf)          assert.NoError(t, err)          assert.NoError(t, agent.Start())                defer func() { assert.NoError(t, agent.Shutdown(true)) }()              ctx := context.Background()             cli, err := client.Dial(agent.RPCAddr(), client.Option{Token: "token"})               assert.NoError(t, err)          defer func() { assert.NoError(t, cli.Close()) }()               err = cli.Activate(ctx)         assert.NoError(t, err)          doc := document.New(helper.Collection, t.Name())                err = cli.Attach(ctx, doc)              assert.NoError(t, err)          // 01. multiple requests to update the document.                for i := 0; i < 3; i++ {                        assert.NoError(t, doc.Update(func(root *proxy.ObjectProxy) error {                              root.SetNewObject("k1")                               return nil                      }))                     assert.NoError(t, cli.Sync(ctx))                }               assert.Equal(t, 1, reqCnt)              // 02. multiple requests to update the document after eviction by ttl.          time.Sleep(time.Duration(authorizedTTLSec) * time.Second)               for i := 0; i < 3; i++ {                        doc.Update(func(root *proxy.ObjectProxy) error {                                root.SetNewObject("k1")                               return nil                      })                      cli.Sync(ctx)           }               assert.Equal(t, 2, reqCnt)
Suggestion accepted: False
Original: // Methods returns a list of methods being used.
Modified: // AuthMethods returns a slice of methods that can be used for authorization.
Suggestion accepted: True
Modified:               var res types.AuthWebhookResponse               res.Allowed = true              if retries < recoveryCnt-1 {                    w.WriteHeader(http.StatusServiceUnavailable)                    retries++               } else {                        retries = 0             }                               _, err = res.Write(w)           assert.NoError(t, err)
Suggestion accepted: False
Original:                 retries++
Modified:      var retries uint64      for retries < config.AuthorizationWebhookMaxRetries {           waitBeforeRetry := waitInterval(retries, config.AuthorizationWebhookMaxWaitIntervalSec)         select {                case <-ctx.Done():                      return ctx.Err()                case <-time.After(waitBeforeRetry):             }               statusCode, err := webhookFn()          if !shouldRetry(statusCode) {                   return err              }               retries++       }               return ErrWaitTimeout
Suggestion accepted: False
Original: func waitInterval(retries uint64, maxWaitInterval uint64) time.Duration {
Modified: func waitInterval(retries uint64, maxWaitInterval time.Duration) time.Duration {
Suggestion accepted: False
Original:                 statusCode == http.StatusServiceUnavailable
Modified:     return statusCode == http.StatusInternalServerError ||          statusCode == http.StatusGatewayTimeout ||              statusCode == http.StatusTooManyRequests
Suggestion accepted: False
Original:                          }
Modified:                              if resp.Err == io.EOF {                                 assert.Fail(t, resp.Err.Error())                                        return                          }
Suggestion accepted: True
Original: }
Modified: func IsMethod(method string) bool {  for _, m := range Methods() {           if method == string(m) {                        return true             }       }       return false}
Suggestion accepted: False
Original: def switch_map(
Modified: def switch_map_indexed(
Suggestion accepted: True
Original:                assert.Equal(t, codes.Unauthenticated, status.Convert(err).Code())
Modified:            assert.Equal(t, codes.PermissionDenied, status.Convert(err).Code())
Suggestion accepted: False
Original:         authorizationWebhookMethods map[types.Method]bool
Modified:      AuthorizationWebhookURL string `json:"AuthorizationWebhookURL"`       AuthorizationWebhookMethods []string{} `json:"AuthorizationWebhookMethods"`
Suggestion accepted: False
Original: // SetRemovedAt sets the remove time of this element.
Modified: // SetRemovedAt sets the removal time of this element.
Suggestion accepted: True
Original:         return n.elem.CreatedAt()
Modified:       return n.CreatedAt()
Suggestion accepted: False
Original:          }
Modified:               if err := info.conn.Close(); err != nil {                       log.Logger.Error(err)                   return err              }
Suggestion accepted: True
Original:        grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
Modified:       grpcrecovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
Suggestion accepted: False
Original:  clusterClinetMapMu *gosync.RWMutex
Modified:      clusterClientMapMu *gosync.RWMutex
Suggestion accepted: True
Original: }
Modified: const (       agentsPath     = "/agents"    putAgentPeriod = 5 * time.Second        agentValueTTL  = 7 * time.Second)
Suggestion accepted: True
Original:        gotime "time"
Modified:       "math"        "testing"     gotime "time"         "github.com/stretchr/testify/assert"  "github.com/yorkie-team/yorkie/pkg/document/json"     "github.com/yorkie-team/yorkie/pkg/document/time"
Suggestion accepted: False
Original: // Input to the CreateERL function
Modified: // CreateERLInput is used as input to the CreateERL function.
Suggestion accepted: True
Original:                 yorkie.DefaultMongoConnectionURI,
Modified:             yorkie.DefaultMongoYorkieDatabase,
Suggestion accepted: True
Original:                         //if config file is given, command-line argumentes will be overwritten
Modified:                        // If config file is given, command-line arguments will be overwritten.
Suggestion accepted: True
Original:                 "config path",
Modified:              "Config path",
Suggestion accepted: True
Original:                 "metrics port",
Modified:             "Metrics port",
Suggestion accepted: True
Original:                 "MongoDB's connection URI",
Modified:                 "Yorkie's database name in MongoDB",
Suggestion accepted: True
Original:  for idx := 0; grapheme.Next(); idx++ {
Modified:  for grapheme.Next() {
Suggestion accepted: True
Original: // Value returns the value.
Modified: // Value returns the value of Primitive.
Suggestion accepted: True
Original:         elem, err := toJSONElement(obj)
Modified:       pbElem, err := toJSONElement(obj)
Suggestion accepted: True
Original:                 return nil, fmt.Errorf("%s: %w decode size: %d", str, ErrInvalidHexString, len(decoded))
Modified:            return nil, fmt.Errorf("decoded length %d: %w", len(decoded), ErrInvalidHexString)
Suggestion accepted: True
Original:        t.Run("ActorID test ", func(t *testing.T) {
Modified: func TestActorID(t *testing.T) {        t.Run("get ActorID from hex test", func(t *testing.T) {               actorID := time.ActorID{}               _, err := rand.Read(actorID[:])         assert.NoError(t, err)          expectedID := actorID.String()          actualID, err := time.ActorIDFromHex(expectedID)                assert.NoError(t, err)          assert.Equal(t, expectedID, actualID.String())  })      t.Run("get ActorID from hex on invalid hexadecimal string test", func(t *testing.T) {         testID := "testID"            _, err := time.ActorIDFromHex(testID)           assert.ErrorIs(t, err, time.ErrInvalidHexString)        })      t.Run("get ActorID from hex on invalid decoded length test", func(t *testing.T) {             bytes := make([]byte, 5)                _, err := rand.Read(bytes)              assert.NoError(t, err)          invalidID := hex.EncodeToString(bytes[:])               _, err = time.ActorIDFromHex(invalidID)         assert.ErrorIs(t, err, time.ErrInvalidHexString)        })}
Suggestion accepted: False
Original:         rhtNodes, err := toRHTNodes(obj.RHTNodes())
Modified:   pbRHTNodes, err := toRHTNodes(obj.RHTNodes())
Suggestion accepted: True
Original:         rgaNodes, err := toRGANodes(arr.RGANodes())
Modified:   pbRGANodes, err := toRGANodes(arr.RGANodes())
Suggestion accepted: True
Original:         valueType, err := toValueType(primitive.ValueType())
Modified:  pbValueType, err := toValueType(primitive.ValueType())
Suggestion accepted: True
Original:         counterType, err := toCounterType(counter.ValueType())
Modified:        pbCounterType, err := toCounterType(counter.ValueType())
Suggestion accepted: True
Original:                 elem, err := toJSONElement(rhtNode.Element())
Modified:                 pbElem, err := toJSONElement(rhtNode.Element())
Suggestion accepted: True
Original:                 elem, err := toJSONElement(rgaNode.Element())
Modified:                 pbElem, err := toJSONElement(rgaNode.Element())
Suggestion accepted: True
Original:         changes, err := toChanges(pack.Changes)
Modified:       pbChanges, err := toChanges(pack.Changes)
Suggestion accepted: True
Original:         elem, err := toJSONElementSimple(set.Value())
Modified:         pbElem, err := toJSONElementSimple(set.Value())
Suggestion accepted: True
Original:         elem, err := toJSONElementSimple(add.Value())
Modified:         pbElem, err := toJSONElementSimple(add.Value())
Suggestion accepted: True
Original:        changePack, err := converter.ToChangePack(doc.CreateChangePack())
Modified:     pbChangePack, err := converter.ToChangePack(doc.CreateChangePack())
Suggestion accepted: False
Original:                 return 0, fmt.Errorf("%v: %w", eventType, ErrUnsupportedEventType)
Modified:          return 0, fmt.Errorf("%s: %w", eventType, ErrUnsupportedEventType)
Suggestion accepted: True
Original:         }
Modified:      // Item to replace      lastIdx := (*pq.queue).Len() - 1        lastItem := (*pq.queue)[lastIdx]        *pq.queue = (*pq.queue)[:lastIdx]       if pq.queue.Len() == 0 || lastIdx == idx {              return  }       lastItem.index = idx    (*pq.queue)[idx] = lastItem     heap.Fix(pq.queue, idx)
Suggestion accepted: False
Original:  pq := pq.NewPriorityQueue()
Modified:     queue := pq.NewPriorityQueue()
Suggestion accepted: True
Original:          tmp := []int{}
Modified:          var tmp []int
Suggestion accepted: True
Original:         if (*pq.queue).Len() == 0 || idx == (*pq.queue).Len() {
Modified:         if pq.queue.Len() == 0 || idx == pq.queue.Len() {
Suggestion accepted: False
Original:         heap.Fix(pq.queue, idx)
Modified:       heap.Remove(pq.queue, idx)
Suggestion accepted: True
Modified:        idx := -1       for i, item := range *pq.queue {                if item.value == value {                        idx = i                 break           }       }
Suggestion accepted: True
Original:                  removedNodeMap[key] = node
Modified:                      removedNodeMap[node.id.key()] = node
Suggestion accepted: True
Original:        time2 "github.com/yorkie-team/yorkie/pkg/document/time"
Modified:     gotime "time" ...     "github.com/yorkie-team/yorkie/pkg/document/time"
Suggestion accepted: False
Original:         "github.com/yorkie-team/yorkie/testhelper"
Modified:  "testing"     "github.com/stretchr/testify/assert"  "github.com/yorkie-team/yorkie/pkg/document/json"     "github.com/yorkie-team/yorkie/pkg/document/time"     "github.com/yorkie-team/yorkie/testhelper"
Suggestion accepted: True
Original:          }
Modified:              assert.NoError(t, err)
Suggestion accepted: True
Original: class Category(str, Enum):
Modified: class WallpaperCategoryType(str, Enum):
Suggestion accepted: True
Original:             f"v1/wallpaper/category/{CATEGORY[category]}/wallpaper",
Modified:             "v1/wallpaper/category/{category}/wallpaper",
Suggestion accepted: True
Original:     - ***MaxNovelId*** `max_novel_id` = `None`
Modified:     - ***Optional[int]*** `max_novel_id` = `None`
Suggestion accepted: True
Original:     response = client.get("novel_new", params={"max_novel_id": "16002726"})
Modified:     response = client.get("novel_new", params={"max_novel_id": 16002726})
Suggestion accepted: False
Original: // Returns the newly created ERL
Modified: // CreateERL returns a new ERL.
Suggestion accepted: True
Original:      * Failure to adhere to this will result in runtime exceptions.
Modified:      * Register an injector for a particular type predicate.      *     * <p>The predicate should only     * return true if the injected type is assignable to the tested type. This predicate overload     * is provided in addition to {@link #registerInjector(Class, ParameterInjector)} to allow     * for exact, non-exact, or custom predicates, however is still bound by the aforementioned constraint.     * Failure to adhere to this will result in runtime exceptions.</p>
Suggestion accepted: False
Original:      * <p>When {@code exactType} is {@code flase}, a value may be returned
Modified:      * <p>When {@code exactType} is {@code false}, a value may be returned
Suggestion accepted: False
Original:      * if it's type is assignable to {@code type}. Otherwise the type must pass
Modified:      * if its type is assignable to {@code type}. Otherwise the type must pass
Suggestion accepted: False
Original:     private CommandCompletionProcessor<C> commandCompletitionProcessor = new FilteringCommandCompletionProcessor<>();
Modified:     private CommandCompletionProcessor<C> commandCompletionProcessor = new FilteringCommandCompletionProcessor<>();
Suggestion accepted: True
Original:             if (Audience.class.isAssignableFrom(Player.class)) { //If we use native adventure
Modified:             if (Audience.class.isAssignableFrom(Player.class)) { // If we use native adventure
Suggestion accepted: True
Original:             } else { //We have a shaded adventure, using method handles to get needed methods without shading
Modified:             } else { // We have a shaded adventure, using method handles to get needed methods without shading
Suggestion accepted: True
Original:  * @param <C> Command sender type
Modified:  * Processor that formats command completions. * * @param <C> Command sender type * @since 1.9.0
Suggestion accepted: False
Original:      * before being returned.
Modified:      * Get command suggestions for the "next" argument that would yield a correctly parsing command input.      *     * <p>The command completions provided by the command argument parsers will be filtered using      * the {@link CommandCompletionProcessor} before being returned.</p>
Suggestion accepted: False
Original:      * Register an injector for a particular type or any of it's assignable supertypes
Modified:      * Register an injector for a particular type or any of it's assignable supertypes.
Suggestion accepted: False
Original:      * Register an injector for a particular type predicate
Modified:      * Register an injector for a particular type predicate.
Suggestion accepted: False
Original:      * Get a value if it exists, else compute and store the value by the supplier and return it
Modified:      * Get a value if it exists, else compute and store the value returned by the function and return it.
Suggestion accepted: True
Original:          * It can have some conflicts when integrating with other command systems like brigadier.
Modified:          * It can have some conflicts when integrating with other command systems like Brigadier,         * and code inspecting the command tree may need to be adjusted.
Suggestion accepted: True
Original:          * When enabled, optional flag arguments are appended between each command node.
Modified:          * Allows parsing flags at any position by appending flag argument nodes between each command node.
Suggestion accepted: False
Original:      * @param defaultSupplier Supplier of default value
Modified:      * @param defaultFunction Default value function
Suggestion accepted: True
Original:      * @param key             Argument key
Modified:      * @param key             Cloud key
Suggestion accepted: True
Original:      * @param <T>             Argument type
Modified:      * @param <T>             Value type
Suggestion accepted: True
Original:      * @return Argument, or supplied default value
Modified:      * @return present or computed value
Suggestion accepted: True
Original:             final @NonNull Function<CloudKey<T>, T> defaultSupplier
Modified:             final @NonNull Function<CloudKey<T>, T> defaultFunction
Suggestion accepted: True