howood/imagereductor

View on GitHub

Showing 18 of 18 total issues

imageCreator has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

type imageCreator struct {
    object          *entity.ImageObject
    option          *entity.ImageObjectOption
    exifOrientation int
    ctx             context.Context
Severity: Minor
Found in application/actor/imageoperator.go - About 2 hrs to fix

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

        case (im.option.Width != 0 && im.option.Height == 0),
            (im.option.Width != 0 && im.option.Height != 0 && float64(im.object.OriginY)/float64(im.object.OriginX) <= float64(im.option.Height)/float64(im.option.Width)):
            im.calcResizeFitOptionWidth(im.object.OriginX, im.object.OriginY)
    Severity: Major
    Found in application/actor/imageoperator.go and 1 other location - About 1 hr to fix
    application/actor/imageoperator.go on lines 323..325

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

    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

        case (im.option.Width == 0 && im.option.Height != 0),
            (im.option.Width != 0 && im.option.Height != 0 && float64(im.object.OriginY)/float64(im.object.OriginX) > float64(im.option.Height)/float64(im.option.Width)):
            im.calcResizeFitOptionHeight(im.object.OriginX, im.object.OriginY)
    Severity: Major
    Found in application/actor/imageoperator.go and 1 other location - About 1 hr to fix
    application/actor/imageoperator.go on lines 320..322

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

    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

    Method imageCreator.rotate has 51 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (im *imageCreator) rotate() error {
        originX := im.object.OriginX
        originY := im.object.OriginY
        switch im.option.Rotate {
        case ImageRotateRight:
    Severity: Minor
    Found in application/actor/imageoperator.go - About 1 hr to fix

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

              if im.exifOrientation == 8 {
                  rect := image.Rect(0, 0, im.object.OriginY, im.object.OriginX)
                  im.object.Source = im.transform(im.object.Source, rect, im.calcRotateAffine(270.0, 0, float64(im.object.OriginX)), im.getDrawer())
                  im.object.OriginX = originY
                  im.object.OriginY = originX
      Severity: Major
      Found in application/actor/imageoperator.go and 1 other location - About 1 hr to fix
      application/actor/imageoperator.go on lines 175..180

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

      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

              if im.exifOrientation == 6 {
                  rect := image.Rect(0, 0, im.object.OriginY, im.object.OriginX)
                  im.object.Source = im.transform(im.object.Source, rect, im.calcRotateAffine(90.0, 0, float64(im.object.OriginX)), im.getDrawer())
                  im.object.OriginX = originY
                  im.object.OriginY = originX
      Severity: Major
      Found in application/actor/imageoperator.go and 1 other location - About 1 hr to fix
      application/actor/imageoperator.go on lines 181..186

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

      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

          case (im.option.Width != 0 && im.option.Height == 0),
              (im.option.Width != 0 && im.option.Height != 0 && float64(cropedY)/float64(cropedX) <= float64(im.option.Height)/float64(im.option.Width)):
              im.calcResizeFitOptionWidth(cropedX, cropedY)
      Severity: Minor
      Found in application/actor/imageoperator.go and 1 other location - About 55 mins to fix
      application/actor/imageoperator.go on lines 342..344

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

      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

          case (im.option.Width == 0 && im.option.Height != 0),
              (im.option.Width != 0 && im.option.Height != 0 && float64(cropedY)/float64(cropedX) > float64(im.option.Height)/float64(im.option.Width)):
              im.calcResizeFitOptionHeight(cropedX, cropedY)
      Severity: Minor
      Found in application/actor/imageoperator.go and 1 other location - About 55 mins to fix
      application/actor/imageoperator.go on lines 339..341

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

      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

      Method ImageReductionHandler.Upload has 5 return statements (exceeds 4 allowed).
      Open

      func (irh ImageReductionHandler) Upload(c echo.Context) error {
          xRequestID := requestid.GetRequestID(c.Request())
          irh.ctx = context.WithValue(context.Background(), requestid.GetRequestIDKey(), xRequestID)
          log.Info(irh.ctx, "========= START REQUEST : "+c.Request().URL.RequestURI())
          log.Info(irh.ctx, c.Request().Method)
      Severity: Major
      Found in interfaces/handler/imagereductionhandler.go - About 35 mins to fix

        Method ImageReductionHandler.getCropParam has 5 return statements (exceeds 4 allowed).
        Open

        func (irh ImageReductionHandler) getCropParam(cropparam string, err error) ([4]int, error) {
            if err != nil {
                return [4]int{}, err
            }
            if cropparam == "" {
        Severity: Major
        Found in interfaces/handler/imagereductionhandler.go - About 35 mins to fix

          Method ImageValidator.Validate has 5 return statements (exceeds 4 allowed).
          Open

          func (val *ImageValidator) Validate(uploadfile io.Reader) error {
              imageinfo, format, err := image.DecodeConfig(uploadfile)
              log.Debug(val.ctx, fmt.Sprintf("%#v", imageinfo))
              log.Debug(val.ctx, format)
              if err != nil {
          Severity: Major
          Found in application/validator/imagevalidator.go - About 35 mins to fix

            Method ImageReductionHandler.Request has 5 return statements (exceeds 4 allowed).
            Open

            func (irh ImageReductionHandler) Request(c echo.Context) error {
                requesturi := c.Request().URL.RequestURI()
                xRequestID := requestid.GetRequestID(c.Request())
                irh.ctx = context.WithValue(context.Background(), requestid.GetRequestIDKey(), xRequestID)
                log.Info(irh.ctx, "========= START REQUEST : "+requesturi)
            Severity: Major
            Found in interfaces/handler/imagereductionhandler.go - About 35 mins to fix

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

              func Debug(ctx context.Context, msg ...interface{}) {
                  _, filename, line, _ := runtime.Caller(1)
                  file := filename + ":" + strconv.Itoa(line)
                  log.Debug(fmt.Sprintf("%v", msg[0]), metadataFields(ctx, file, msg)...)
              }
              Severity: Major
              Found in infrastructure/logger/logger.go and 5 other locations - About 30 mins to fix
              infrastructure/logger/logger.go on lines 70..74
              infrastructure/logger/logger.go on lines 77..81
              infrastructure/logger/logger.go on lines 84..88
              infrastructure/logger/logger.go on lines 91..95
              infrastructure/logger/logger.go on lines 98..102

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

              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

              func Fatal(ctx context.Context, msg ...interface{}) {
                  _, filename, line, _ := runtime.Caller(1)
                  file := filename + ":" + strconv.Itoa(line)
                  log.Fatal(fmt.Sprintf("%v", msg[0]), metadataFields(ctx, file, msg)...)
              }
              Severity: Major
              Found in infrastructure/logger/logger.go and 5 other locations - About 30 mins to fix
              infrastructure/logger/logger.go on lines 63..67
              infrastructure/logger/logger.go on lines 70..74
              infrastructure/logger/logger.go on lines 77..81
              infrastructure/logger/logger.go on lines 84..88
              infrastructure/logger/logger.go on lines 91..95

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

              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

              func Panic(ctx context.Context, msg ...interface{}) {
                  _, filename, line, _ := runtime.Caller(1)
                  file := filename + ":" + strconv.Itoa(line)
                  log.Panic(fmt.Sprintf("%v", msg[0]), metadataFields(ctx, file, msg)...)
              }
              Severity: Major
              Found in infrastructure/logger/logger.go and 5 other locations - About 30 mins to fix
              infrastructure/logger/logger.go on lines 63..67
              infrastructure/logger/logger.go on lines 70..74
              infrastructure/logger/logger.go on lines 77..81
              infrastructure/logger/logger.go on lines 84..88
              infrastructure/logger/logger.go on lines 98..102

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

              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

              func Error(ctx context.Context, msg ...interface{}) {
                  _, filename, line, _ := runtime.Caller(1)
                  file := filename + ":" + strconv.Itoa(line)
                  log.Error(fmt.Sprintf("%v", msg[0]), metadataFields(ctx, file, msg)...)
              }
              Severity: Major
              Found in infrastructure/logger/logger.go and 5 other locations - About 30 mins to fix
              infrastructure/logger/logger.go on lines 63..67
              infrastructure/logger/logger.go on lines 70..74
              infrastructure/logger/logger.go on lines 77..81
              infrastructure/logger/logger.go on lines 91..95
              infrastructure/logger/logger.go on lines 98..102

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

              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

              func Info(ctx context.Context, msg ...interface{}) {
                  _, filename, line, _ := runtime.Caller(1)
                  file := filename + ":" + strconv.Itoa(line)
                  log.Info(fmt.Sprintf("%v", msg[0]), metadataFields(ctx, file, msg)...)
              }
              Severity: Major
              Found in infrastructure/logger/logger.go and 5 other locations - About 30 mins to fix
              infrastructure/logger/logger.go on lines 63..67
              infrastructure/logger/logger.go on lines 77..81
              infrastructure/logger/logger.go on lines 84..88
              infrastructure/logger/logger.go on lines 91..95
              infrastructure/logger/logger.go on lines 98..102

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

              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

              func Warn(ctx context.Context, msg ...interface{}) {
                  _, filename, line, _ := runtime.Caller(1)
                  file := filename + ":" + strconv.Itoa(line)
                  log.Warn(fmt.Sprintf("%v", msg[0]), metadataFields(ctx, file, msg)...)
              }
              Severity: Major
              Found in infrastructure/logger/logger.go and 5 other locations - About 30 mins to fix
              infrastructure/logger/logger.go on lines 63..67
              infrastructure/logger/logger.go on lines 70..74
              infrastructure/logger/logger.go on lines 84..88
              infrastructure/logger/logger.go on lines 91..95
              infrastructure/logger/logger.go on lines 98..102

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

              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

              Severity
              Category
              Status
              Source
              Language