topfreegames/khan

View on GitHub

Showing 425 of 425 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

            It("Should fail if clan does not exist", func() {
                config := viper.New()
                api.SetRetrieveClanHandlerConfigurationDefaults(config)
                clanData, err := GetClanDetails(testDb, fixtures.GetEncryptionKey(), "fake-game-id", &Clan{PublicID: "fake-public-id"}, 1, NewDefaultGetClanDetailsOptions(config))
                Expect(clanData).To(BeNil())
Severity: Major
Found in models/clan_test.go and 1 other location - About 1 hr to fix
models/clan_test.go on lines 1116..1123

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 131.

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

Further Reading

Similar blocks of code found in 6 locations. Consider refactoring.
Open

        It("Should fail with 400 if pendingApplicationsOrder is not a valid order string", func() {
            _, clan, _, _, _, err := fixtures.GetClanWithMemberships(testDb, 0, 0, 0, 0, "", "")
            Expect(err).NotTo(HaveOccurred())

            status, body := Get(app, GetGameRoute(clan.GameID, fmt.Sprintf("/clans/%s?pendingApplicationsOrder=xablau", clan.PublicID)))
Severity: Major
Found in api/clan_test.go and 5 other locations - About 1 hr to fix
api/clan_test.go on lines 687..695
api/clan_test.go on lines 697..705
api/clan_test.go on lines 707..715
api/clan_test.go on lines 717..725
api/clan_test.go on lines 737..745

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 131.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (k *Khan) UpdateClan(ctx context.Context, clan *ClanPayload) (*Result, error) {
    route := k.buildUpdateClanURL(clan.PublicID)
    body, err := k.sendTo(ctx, "PUT", route, clan)
    if err != nil {
        return nil, err
Severity: Major
Found in lib/lib.go and 1 other location - About 1 hr to fix
lib/lib.go on lines 407..421

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 131.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func GetMembershipByClanAndPlayerPublicID(db DB, gameID, clanPublicID, playerPublicID string) (*Membership, error) {
    var memberships []*Membership
    query := `
    SELECT
        m.*
Severity: Major
Found in models/membership.go and 1 other location - About 1 hr to fix
models/membership.go on lines 70..90

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 131.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func GetValidMembershipByClanAndPlayerPublicID(db DB, gameID, clanPublicID, playerPublicID string) (*Membership, error) {
    var memberships []*Membership
    query := `
    SELECT
        m.*
Severity: Major
Found in models/membership.go and 1 other location - About 1 hr to fix
models/membership.go on lines 93..111

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 131.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (k *Khan) ApplyForMembership(
    ctx context.Context,
    payload *ApplicationPayload,
) (*ClanApplyResult, error) {
    route := k.buildApplyForMembershipURL(payload.ClanID)
Severity: Major
Found in lib/lib.go and 1 other location - About 1 hr to fix
lib/lib.go on lines 335..345

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 131.

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

Further Reading

Function inviteMember has 10 return statements (exceeds 4 allowed).
Open

func inviteMember(db DB, encryptionKey []byte, game *Game, membership *Membership, level string, clan *Clan, playerID int64, requestorPublicID, message string, previousMembership bool) (*Membership, error) {
    reqMembership, _ := GetValidMembershipByClanAndPlayerPublicID(db, game.PublicID, clan.PublicID, requestorPublicID)
    if reqMembership == nil {
        requestor, err := GetPlayerByPublicID(db, encryptionKey, game.PublicID, requestorPublicID)
        if err != nil {
Severity: Major
Found in models/membership.go - About 1 hr to fix

    Function applyForMembership has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func applyForMembership(db DB, game *Game, membership *Membership, level string, clan *Clan, playerID int64, requestorPublicID, message string, previousMembership bool) (*Membership, error) {
    Severity: Major
    Found in models/membership.go - About 1 hr to fix

      Function dispatchMembershipHook has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func dispatchMembershipHook(app *App, db models.DB, hookType int, gameID string, clan *models.Clan, player *models.Player, requestor *models.Player, message, membershipLevel string) error {
      Severity: Major
      Found in api/membership_helpers.go - About 1 hr to fix

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

        func (m *MockKhanInterface) LeaveClan(arg0 context.Context, arg1 string) (*lib.LeaveClanResult, error) {
            m.ctrl.T.Helper()
            ret := m.ctrl.Call(m, "LeaveClan", arg0, arg1)
            ret0, _ := ret[0].(*lib.LeaveClanResult)
            ret1, _ := ret[1].(error)
        Severity: Major
        Found in lib/mocks/khan.go and 4 other locations - About 1 hr to fix
        lib/mocks/khan.go on lines 173..179
        lib/mocks/khan.go on lines 188..194
        lib/mocks/khan.go on lines 218..224
        lib/mocks/khan.go on lines 233..239

        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 129.

        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

        Further Reading

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

        func (m *MockKhanInterface) RetrievePlayer(arg0 context.Context, arg1 string) (*lib.Player, error) {
            m.ctrl.T.Helper()
            ret := m.ctrl.Call(m, "RetrievePlayer", arg0, arg1)
            ret0, _ := ret[0].(*lib.Player)
            ret1, _ := ret[1].(error)
        Severity: Major
        Found in lib/mocks/khan.go and 4 other locations - About 1 hr to fix
        lib/mocks/khan.go on lines 143..149
        lib/mocks/khan.go on lines 173..179
        lib/mocks/khan.go on lines 188..194
        lib/mocks/khan.go on lines 233..239

        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 129.

        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

        Further Reading

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

        func (m *MockKhanInterface) RetrieveClan(arg0 context.Context, arg1 string) (*lib.Clan, error) {
            m.ctrl.T.Helper()
            ret := m.ctrl.Call(m, "RetrieveClan", arg0, arg1)
            ret0, _ := ret[0].(*lib.Clan)
            ret1, _ := ret[1].(error)
        Severity: Major
        Found in lib/mocks/khan.go and 4 other locations - About 1 hr to fix
        lib/mocks/khan.go on lines 143..149
        lib/mocks/khan.go on lines 188..194
        lib/mocks/khan.go on lines 218..224
        lib/mocks/khan.go on lines 233..239

        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 129.

        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

        Further Reading

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

        func (m *MockKhanInterface) RetrieveClanSummary(arg0 context.Context, arg1 string) (*lib.ClanSummary, error) {
            m.ctrl.T.Helper()
            ret := m.ctrl.Call(m, "RetrieveClanSummary", arg0, arg1)
            ret0, _ := ret[0].(*lib.ClanSummary)
            ret1, _ := ret[1].(error)
        Severity: Major
        Found in lib/mocks/khan.go and 4 other locations - About 1 hr to fix
        lib/mocks/khan.go on lines 143..149
        lib/mocks/khan.go on lines 173..179
        lib/mocks/khan.go on lines 218..224
        lib/mocks/khan.go on lines 233..239

        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 129.

        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

        Further Reading

        Similar blocks of code found in 5 locations. Consider refactoring.
        Open

        func (m *MockKhanInterface) SearchClans(arg0 context.Context, arg1 string) (*lib.SearchClansResult, error) {
            m.ctrl.T.Helper()
            ret := m.ctrl.Call(m, "SearchClans", arg0, arg1)
            ret0, _ := ret[0].(*lib.SearchClansResult)
            ret1, _ := ret[1].(error)
        Severity: Major
        Found in lib/mocks/khan.go and 4 other locations - About 1 hr to fix
        lib/mocks/khan.go on lines 143..149
        lib/mocks/khan.go on lines 173..179
        lib/mocks/khan.go on lines 188..194
        lib/mocks/khan.go on lines 218..224

        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 129.

        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

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        func (c *Clan) IndexClanIntoElasticSearch() error {
            es := es.GetConfiguredClient()
            // TODO: fix it, boomforce is hardcoded for now
            if es != nil && c.GameID == "boomforce" {
                workers.Enqueue(queues.KhanESQueue, "Add", map[string]interface{}{
        Severity: Major
        Found in models/clan.go and 2 other locations - About 1 hr to fix
        models/clan.go on lines 256..268
        models/clan.go on lines 271..283

        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 128.

        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

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        func (c *Clan) DeleteClanFromElasticSearch() error {
            es := es.GetConfiguredClient()
            // TODO: fix it, boomforce is hardcoded for now
            if es != nil && c.GameID == "boomforce" {
                workers.Enqueue(queues.KhanESQueue, "Add", map[string]interface{}{
        Severity: Major
        Found in models/clan.go and 2 other locations - About 1 hr to fix
        models/clan.go on lines 185..197
        models/clan.go on lines 256..268

        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 128.

        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

        Further Reading

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        func (c *Clan) UpdateClanIntoElasticSearch() error {
            es := es.GetConfiguredClient()
            // TODO: fix it, boomforce is hardcoded for now
            if es != nil && c.GameID == "boomforce" {
                workers.Enqueue(queues.KhanESQueue, "Add", map[string]interface{}{
        Severity: Major
        Found in models/clan.go and 2 other locations - About 1 hr to fix
        models/clan.go on lines 185..197
        models/clan.go on lines 271..283

        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 128.

        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

        Further Reading

        Function validateMembership has 9 return statements (exceeds 4 allowed).
        Open

        func validateMembership(db DB, encryptionKey []byte, game *Game, membership *Membership, clan *Clan, playerPublicID, requestorPublicID string) (int64, bool, error) {
            playerID := int64(-1)
            previousMembership := false
            if membership != nil {
                previousMembership = true
        Severity: Major
        Found in models/membership.go - About 55 mins to fix

          Function easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi1 has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func easyjsonA8a797f8DecodeGithubComTopfreegamesKhanApi1(in *jlexer.Lexer, out *UpdatePlayerPayload) {
              isTopLevel := in.IsStart()
              if in.IsNull() {
                  if isTopLevel {
                      in.Consumed()
          Severity: Minor
          Found in api/payload_easyjson.go - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function getPlayerMembershipDetails has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func getPlayerMembershipDetails(db DB, encryptionKey []byte, gameID, publicID string) (map[string]interface{}, error) {
              player, err := GetPlayerByPublicID(db, encryptionKey, gameID, publicID)
              if err != nil {
                  return nil, err
              }
          Severity: Minor
          Found in models/player.go - About 55 mins to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Severity
          Category
          Status
          Source
          Language