Showing 853 of 853 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
for _, tc := range []struct{ token string }{
{""},
{"foo"},
// tokens with two parts will be handled by the HMAC strategy
{"foo.bar.baz"},
- 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 108.
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 makeOAuth2Request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func makeOAuth2Request(t *testing.T, reg driver.Registry, hc *http.Client, oc *client.Client, values url.Values) (gjson.Result, *http.Response) {
Function ValidateCsrfSession
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func ValidateCsrfSession(r *http.Request, conf x.CookieConfigProvider, store sessions.Store, name, expectedCSRF string, f *flow.Flow) error {
Method DefaultStrategy.requestConsent
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
ctx context.Context,
w http.ResponseWriter,
r *http.Request,
ar fosite.AuthorizeRequester,
f *flow.Flow,
Method DefaultStrategy.verifyAuthentication
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
ctx context.Context,
w http.ResponseWriter,
r *http.Request,
req fosite.AuthorizeRequester,
verifier string,
Function newRegistryDefault
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func newRegistryDefault(t testing.TB, url string, c *config.DefaultProvider, migrate bool, ctxer contextx.Contextualizer) driver.Registry {
Function cleanupRun
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func cleanupRun(ctx context.Context, notAfter time.Time, limit int, batchSize int, routines ...cleanupRoutine) error {
Function testRegistry
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func testRegistry(t *testing.T, ctx context.Context, k string, t1 driver.Registry, t2 driver.Registry) {
Function NewOAuth2LoginRequest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func NewOAuth2LoginRequest(challenge string, client OAuth2Client, requestUrl string, skip bool, subject string) *OAuth2LoginRequest {
Function UpdateClientTokenLifespans
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func UpdateClientTokenLifespans(t *testing.T, conf *oauth2.Config, clientID string, lifespans client.Lifespans, adminTS *httptest.Server) {
Function assertCreateVerifiableCredential
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func assertCreateVerifiableCredential(t *testing.T, reg driver.Registry, nonce string, accessToken *oauth2.Token, alg jose.SignatureAlgorithm) {
Method MockOAuth2Provider.IntrospectToken
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (m *MockOAuth2Provider) IntrospectToken(arg0 context.Context, arg1 string, arg2 fosite.TokenType, arg3 fosite.Session, arg4 ...string) (fosite.TokenType, fosite.AccessRequester, error) {
Method Persister.createSession
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (p *Persister) createSession(ctx context.Context, signature string, requester fosite.Requester, table tableName, expiresAt time.Time) error {
Function doTestRollback
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func doTestRollback(m InternalRegistry, t *testing.T,
createFn func(context.Context, string, fosite.Requester) error,
getFn func(context.Context, string, fosite.Session) (fosite.Requester, error),
revokeFn func(context.Context, string) error,
Function TestHelperManagerKeySet
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func TestHelperManagerKeySet(m Manager, algo string, keys *jose.JSONWebKeySet, suffix string, parallel bool) func(t *testing.T) {
Function createAccessTokenSession
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func createAccessTokenSession(subject, client string, token string, expiresAt time.Time, fs x.FositeStorer, scopes fosite.Arguments) {
Method Persister.sqlSchemaFromRequest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func (p *Persister) sqlSchemaFromRequest(ctx context.Context, signature string, r fosite.Requester, table tableName, expiresAt time.Time) (*OAuth2RequestSQL, error) {
Function doTestCommit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func doTestCommit(m InternalRegistry, t *testing.T,
createFn func(context.Context, string, fosite.Requester) error,
getFn func(context.Context, string, fosite.Session) (fosite.Requester, error),
revokeFn func(context.Context, string) error,
Function executeHookAndUpdateSession
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func executeHookAndUpdateSession(ctx context.Context, reg x.HTTPClientProvider, hookConfig *config.HookConfig, reqBodyBytes []byte, session *Session) error {
Method DefaultStrategy.ObfuscateSubjectIdentifier
has 5 return statements (exceeds 4 allowed). Open
func (s *DefaultStrategy) ObfuscateSubjectIdentifier(ctx context.Context, cl fosite.Client, subject, forcedIdentifier string) (string, error) {
if c, ok := cl.(*client.Client); ok && c.SubjectType == "pairwise" {
algorithm, ok := s.r.SubjectIdentifierAlgorithm(ctx)[c.SubjectType]
if !ok {
return "", errorsx.WithStack(fosite.ErrInvalidRequest.WithHintf(`Subject Identifier Algorithm '%s' was requested by OAuth 2.0 Client '%s' but is not configured.`, c.SubjectType, c.GetID()))