Bnei-Baruch/mdb

View on GitHub
importer/kmedia/custom.go

Summary

Maintainability
C
1 day
Test Coverage

Function getImportSettings has 160 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func getImportSettings(idx int) *ImportSettings {
    i := idx
    if idx > 395 {
        i--
    }
Severity: Major
Found in importer/kmedia/custom.go - About 5 hrs to fix

    Function getImportSettings has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
    Open

    func getImportSettings(idx int) *ImportSettings {
        i := idx
        if idx > 395 {
            i--
        }
    Severity: Minor
    Found in importer/kmedia/custom.go - About 1 hr 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 importNewCUBySettings has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func importNewCUBySettings(exec boil.Executor, settings *ImportSettings) error {
        cu, err := models.ContentUnits(qm.Where("(properties->>'kmedia_id')::int = ?", settings.KmCNID)).One(mdb)
        if err != nil {
            if err != sql.ErrNoRows {
                return errors.Wrapf(err, "Lookup content_unit kmedia_id=%d", settings.KmCNID)
    Severity: Minor
    Found in importer/kmedia/custom.go - About 1 hr to fix

      Function importNewCUBySettings has 8 return statements (exceeds 4 allowed).
      Open

      func importNewCUBySettings(exec boil.Executor, settings *ImportSettings) error {
          cu, err := models.ContentUnits(qm.Where("(properties->>'kmedia_id')::int = ?", settings.KmCNID)).One(mdb)
          if err != nil {
              if err != sql.ErrNoRows {
                  return errors.Wrapf(err, "Lookup content_unit kmedia_id=%d", settings.KmCNID)
      Severity: Major
      Found in importer/kmedia/custom.go - About 50 mins to fix

        Function importNewCUBySettings has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        Open

        func importNewCUBySettings(exec boil.Executor, settings *ImportSettings) error {
            cu, err := models.ContentUnits(qm.Where("(properties->>'kmedia_id')::int = ?", settings.KmCNID)).One(mdb)
            if err != nil {
                if err != sql.ErrNoRows {
                    return errors.Wrapf(err, "Lookup content_unit kmedia_id=%d", settings.KmCNID)
        Severity: Minor
        Found in importer/kmedia/custom.go - About 45 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

        There are no issues that match your filters.

        Category
        Status