evalphobia/face-detect-annotator

View on GitHub

Showing 6 of 6 total issues

Function annotateImage has 60 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func annotateImage(path string, targets ...string) error {
    file, err := os.Open(path)
    if err != nil {
        return err
    }
Severity: Minor
Found in command_annotator.go - About 1 hr to fix

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

    func makeTensorFromFile(imgPath string) (*tf.Tensor, error) {
        f, err := os.Open(imgPath)
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in engine/tensorflow/face_detector_tensorflow.go - About 50 mins to fix

      Function drawString has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      func drawString(img *image.RGBA, p image.Point, c color.Color, f font.Face, s string) {
      Severity: Minor
      Found in command_annotator.go - About 35 mins to fix

        Method AzureVisionFaceDetector.Detect has 5 return statements (exceeds 4 allowed).
        Open

        func (d AzureVisionFaceDetector) Detect(imgPath string) (engine.FaceResult, error) {
            emptyResult := engine.FaceResult{}
            imgWidth, imgHeight, err := engine.GetImageSize(imgPath)
            if err != nil {
                return emptyResult, err
        Severity: Major
        Found in engine/azure/face_detector_azure_vision.go - About 35 mins to fix

          Function annotateImage has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
          Open

          func annotateImage(path string, targets ...string) error {
              file, err := os.Open(path)
              if err != nil {
                  return err
              }
          Severity: Minor
          Found in command_annotator.go - About 35 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

          Method TensorFlowFaceDetector.Init has 5 return statements (exceeds 4 allowed).
          Open

          func (d *TensorFlowFaceDetector) Init(conf engine.Config) error {
              c, ok := conf.(Config)
              if !ok {
                  return errors.New("Incompatible config type for TensorFlowFaceDetector")
              }
          Severity: Major
          Found in engine/tensorflow/face_detector_tensorflow.go - About 35 mins to fix
            Severity
            Category
            Status
            Source
            Language