The following issues were found

samples/java/opencv_version.java
7 issues
System.out.println is used
Design

Line: 11

              
    if ((1==args.length) && (0==args[0].compareTo("--build"))) {

        System.out.println(Core.getBuildInformation());
    } else
    if ((1==args.length) && (0==args[0].compareTo("--help"))) {

        System.out.println("\t--build\n\t\tprint complete build info");
        System.out.println("\t--help\n\t\tprint this help");

            

Reported by PMD.

System.out.println is used
Design

Line: 15

                  } else
    if ((1==args.length) && (0==args[0].compareTo("--help"))) {

        System.out.println("\t--build\n\t\tprint complete build info");
        System.out.println("\t--help\n\t\tprint this help");
    } else {

        System.out.println("Welcome to OpenCV " + Core.VERSION);
    }

            

Reported by PMD.

System.out.println is used
Design

Line: 16

                  if ((1==args.length) && (0==args[0].compareTo("--help"))) {

        System.out.println("\t--build\n\t\tprint complete build info");
        System.out.println("\t--help\n\t\tprint this help");
    } else {

        System.out.println("Welcome to OpenCV " + Core.VERSION);
    }
  }

            

Reported by PMD.

System.out.println is used
Design

Line: 19

                      System.out.println("\t--help\n\t\tprint this help");
    } else {

        System.out.println("Welcome to OpenCV " + Core.VERSION);
    }
  }

}

            

Reported by PMD.

All methods are static. Consider using a utility class instead. Alternatively, you could add a private constructor or make the class abstract to silence this warning.
Design

Line: 3

              import org.opencv.core.Core;

class opencv_version {

  static { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }

  public static void main(String[] args) {

    if ((1==args.length) && (0==args[0].compareTo("--build"))) {

            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 9

              
  public static void main(String[] args) {

    if ((1==args.length) && (0==args[0].compareTo("--build"))) {

        System.out.println(Core.getBuildInformation());
    } else
    if ((1==args.length) && (0==args[0].compareTo("--help"))) {


            

Reported by PMD.

Position literals first in String comparisons
Design

Line: 13

              
        System.out.println(Core.getBuildInformation());
    } else
    if ((1==args.length) && (0==args[0].compareTo("--help"))) {

        System.out.println("\t--build\n\t\tprint complete build info");
        System.out.println("\t--help\n\t\tprint this help");
    } else {


            

Reported by PMD.

samples/python/inpaint.py
7 issues
Unable to import 'cv2'
Error

Line: 22 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

from common import Sketcher

def main():
    import sys

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 30 Column: 5

                  import sys
    try:
        fn = sys.argv[1]
    except:
        fn = 'fruits.jpg'

    img = cv.imread(cv.samples.findFile(fn))
    if img is None:
        print('Failed to load image file:', fn)

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 26 Column: 1

              
from common import Sketcher

def main():
    import sys
    try:
        fn = sys.argv[1]
    except:
        fn = 'fruits.jpg'

            

Reported by Pylint.

Import outside toplevel (sys)
Error

Line: 27 Column: 5

              from common import Sketcher

def main():
    import sys
    try:
        fn = sys.argv[1]
    except:
        fn = 'fruits.jpg'


            

Reported by Pylint.

Variable name "fn" doesn't conform to snake_case naming style
Error

Line: 29 Column: 9

              def main():
    import sys
    try:
        fn = sys.argv[1]
    except:
        fn = 'fruits.jpg'

    img = cv.imread(cv.samples.findFile(fn))
    if img is None:

            

Reported by Pylint.

Variable name "fn" doesn't conform to snake_case naming style
Error

Line: 31 Column: 9

                  try:
        fn = sys.argv[1]
    except:
        fn = 'fruits.jpg'

    img = cv.imread(cv.samples.findFile(fn))
    if img is None:
        print('Failed to load image file:', fn)
        sys.exit(1)

            

Reported by Pylint.

Variable name "ch" doesn't conform to snake_case naming style
Error

Line: 43 Column: 9

                  sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255))

    while True:
        ch = cv.waitKey()
        if ch == 27:
            break
        if ch == ord(' '):
            res = cv.inpaint(img_mark, mark, 3, cv.INPAINT_TELEA)
            cv.imshow('inpaint', res)

            

Reported by Pylint.

samples/dnn/dnn_model_runner/dnn_conversion/pytorch/classification/py_to_py_resnet50_onnx.py
7 issues
Unable to import 'torch'
Error

Line: 3 Column: 1

              import os

import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):

            

Reported by Pylint.

Unable to import 'torch.onnx'
Error

Line: 4 Column: 1

              import os

import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):

            

Reported by Pylint.

Unable to import 'torch.autograd'
Error

Line: 5 Column: 1

              
import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):
    # define the directory for further converted model save

            

Reported by Pylint.

Unable to import 'torchvision'
Error

Line: 6 Column: 1

              import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):
    # define the directory for further converted model save
    onnx_model_path = "models"

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os

import torch
import torch.onnx
from torch.autograd import Variable
from torchvision import models


def get_pytorch_onnx_model(original_model):

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 9 Column: 1

              from torchvision import models


def get_pytorch_onnx_model(original_model):
    # define the directory for further converted model save
    onnx_model_path = "models"
    # define the name of further converted model
    onnx_model_name = "resnet50.onnx"


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 40 Column: 1

                  return full_model_path


def main():
    # initialize PyTorch ResNet-50 model
    original_model = models.resnet50(pretrained=True)

    # get the path to the converted into ONNX PyTorch model
    full_model_path = get_pytorch_onnx_model(original_model)

            

Reported by Pylint.

modules/calib3d/misc/java/test/StereoBMTest.java
7 issues
JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 7

              
public class StereoBMTest extends OpenCVTestCase {

    public void testComputeMatMatMat() {
        fail("Not yet implemented");
    }

    public void testComputeMatMatMatInt() {
        fail("Not yet implemented");

            

Reported by PMD.

The String literal 'Not yet implemented' appears 6 times in this file; the first occurrence is on line 8
Error

Line: 8

              public class StereoBMTest extends OpenCVTestCase {

    public void testComputeMatMatMat() {
        fail("Not yet implemented");
    }

    public void testComputeMatMatMatInt() {
        fail("Not yet implemented");
    }

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 11

                      fail("Not yet implemented");
    }

    public void testComputeMatMatMatInt() {
        fail("Not yet implemented");
    }

    public void testStereoBM() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 15

                      fail("Not yet implemented");
    }

    public void testStereoBM() {
        fail("Not yet implemented");
    }

    public void testStereoBMInt() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 19

                      fail("Not yet implemented");
    }

    public void testStereoBMInt() {
        fail("Not yet implemented");
    }

    public void testStereoBMIntInt() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 23

                      fail("Not yet implemented");
    }

    public void testStereoBMIntInt() {
        fail("Not yet implemented");
    }

    public void testStereoBMIntIntInt() {
        fail("Not yet implemented");

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 27

                      fail("Not yet implemented");
    }

    public void testStereoBMIntIntInt() {
        fail("Not yet implemented");
    }

}

            

Reported by PMD.

platforms/android/ndk-16.config.py
7 issues
Undefined variable 'ABI'
Error

Line: 2 Column: 5

              ABIs = [
    ABI("2", "armeabi-v7a", "arm-linux-androideabi-4.9", cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')),
    ABI("1", "armeabi",     "arm-linux-androideabi-4.9", cmake_vars=dict(WITH_TBB='OFF')),
    ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
    ABI("5", "x86_64",      "x86_64-4.9"),
    ABI("4", "x86",         "x86-4.9"),
]

            

Reported by Pylint.

Undefined variable 'ABI'
Error

Line: 3 Column: 5

              ABIs = [
    ABI("2", "armeabi-v7a", "arm-linux-androideabi-4.9", cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')),
    ABI("1", "armeabi",     "arm-linux-androideabi-4.9", cmake_vars=dict(WITH_TBB='OFF')),
    ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
    ABI("5", "x86_64",      "x86_64-4.9"),
    ABI("4", "x86",         "x86-4.9"),
]

            

Reported by Pylint.

Undefined variable 'ABI'
Error

Line: 4 Column: 5

              ABIs = [
    ABI("2", "armeabi-v7a", "arm-linux-androideabi-4.9", cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')),
    ABI("1", "armeabi",     "arm-linux-androideabi-4.9", cmake_vars=dict(WITH_TBB='OFF')),
    ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
    ABI("5", "x86_64",      "x86_64-4.9"),
    ABI("4", "x86",         "x86-4.9"),
]

            

Reported by Pylint.

Undefined variable 'ABI'
Error

Line: 5 Column: 5

                  ABI("2", "armeabi-v7a", "arm-linux-androideabi-4.9", cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')),
    ABI("1", "armeabi",     "arm-linux-androideabi-4.9", cmake_vars=dict(WITH_TBB='OFF')),
    ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
    ABI("5", "x86_64",      "x86_64-4.9"),
    ABI("4", "x86",         "x86-4.9"),
]

            

Reported by Pylint.

Undefined variable 'ABI'
Error

Line: 6 Column: 5

                  ABI("1", "armeabi",     "arm-linux-androideabi-4.9", cmake_vars=dict(WITH_TBB='OFF')),
    ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
    ABI("5", "x86_64",      "x86_64-4.9"),
    ABI("4", "x86",         "x86-4.9"),
]

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              ABIs = [
    ABI("2", "armeabi-v7a", "arm-linux-androideabi-4.9", cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')),
    ABI("1", "armeabi",     "arm-linux-androideabi-4.9", cmake_vars=dict(WITH_TBB='OFF')),
    ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
    ABI("5", "x86_64",      "x86_64-4.9"),
    ABI("4", "x86",         "x86-4.9"),
]

            

Reported by Pylint.

Line too long (111/100)
Error

Line: 2 Column: 1

              ABIs = [
    ABI("2", "armeabi-v7a", "arm-linux-androideabi-4.9", cmake_vars=dict(ANDROID_ABI='armeabi-v7a with NEON')),
    ABI("1", "armeabi",     "arm-linux-androideabi-4.9", cmake_vars=dict(WITH_TBB='OFF')),
    ABI("3", "arm64-v8a",   "aarch64-linux-android-4.9"),
    ABI("5", "x86_64",      "x86_64-4.9"),
    ABI("4", "x86",         "x86-4.9"),
]

            

Reported by Pylint.

modules/video/misc/java/test/TrackerCreateTest.java
7 issues
JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 16

              
public class TrackerCreateTest extends OpenCVTestCase {

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }



            

Reported by PMD.

Overriding method merely calls super
Design

Line: 17

              public class TrackerCreateTest extends OpenCVTestCase {

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }


    public void testCreateTrackerGOTURN() {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 22

                  }


    public void testCreateTrackerGOTURN() {
        try {
            Tracker tracker = TrackerGOTURN.create();
            assert(tracker != null);
        } catch (CvException e) {
            // expected, model files may be missing

            

Reported by PMD.

Avoid empty catch blocks
Error

Line: 26

                      try {
            Tracker tracker = TrackerGOTURN.create();
            assert(tracker != null);
        } catch (CvException e) {
            // expected, model files may be missing
        }
    }

    public void testCreateTrackerMIL() {

            

Reported by PMD.

JUnit 4 tests that execute tests should use the @Test annotation, JUnit 5 tests should use @Test, @RepeatedTest, @TestFactory, @TestTemplate or @ParameterizedTest
Design

Line: 31

                      }
    }

    public void testCreateTrackerMIL() {
        Tracker tracker = TrackerMIL.create();
        assert(tracker != null);
        Mat mat = new Mat(100, 100, CvType.CV_8UC1);
        Rect rect = new Rect(10, 10, 30, 30);
        tracker.init(mat, rect);  // should not crash (https://github.com/opencv/opencv/issues/19915)

            

Reported by PMD.

Potential violation of Law of Demeter (object not created locally)
Design

Line: 36

                      assert(tracker != null);
        Mat mat = new Mat(100, 100, CvType.CV_8UC1);
        Rect rect = new Rect(10, 10, 30, 30);
        tracker.init(mat, rect);  // should not crash (https://github.com/opencv/opencv/issues/19915)
    }

}

            

Reported by PMD.

Avoid unused imports such as 'org.opencv.core.Core'
Design

Line: 3

              package org.opencv.test.video;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.CvException;
import org.opencv.core.Mat;
import org.opencv.core.Rect;
import org.opencv.test.OpenCVTestCase;


            

Reported by PMD.

modules/core/misc/java/src/java/core+MatOfPoint3f.java
7 issues
Overridable method 'fromArray' called during object construction
Error

Line: 35

              
    public MatOfPoint3f(Point3...a) {
        super();
        fromArray(a);
    }

    public void alloc(int elemNumber) {
        if(elemNumber>0)
            super.create(elemNumber, 1, CvType.makeType(_depth, _channels));

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '48'-'51').
Error

Line: 48

                          return;
        int num = a.length;
        alloc(num);
        float buff[] = new float[num * _channels];
        for(int i=0; i<num; i++) {
            Point3 p = a[i];
            buff[_channels*i+0] = (float) p.x;
            buff[_channels*i+1] = (float) p.y;
            buff[_channels*i+2] = (float) p.z;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '51'-'52').
Error

Line: 51

                      float buff[] = new float[num * _channels];
        for(int i=0; i<num; i++) {
            Point3 p = a[i];
            buff[_channels*i+0] = (float) p.x;
            buff[_channels*i+1] = (float) p.y;
            buff[_channels*i+2] = (float) p.z;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '52'-'53').
Error

Line: 52

                      for(int i=0; i<num; i++) {
            Point3 p = a[i];
            buff[_channels*i+0] = (float) p.x;
            buff[_channels*i+1] = (float) p.y;
            buff[_channels*i+2] = (float) p.z;
        }
        put(0, 0, buff); //TODO: check ret val!
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '53'-'51').
Error

Line: 53

                          Point3 p = a[i];
            buff[_channels*i+0] = (float) p.x;
            buff[_channels*i+1] = (float) p.y;
            buff[_channels*i+2] = (float) p.z;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

    public Point3[] toArray() {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'ap' (lines '60'-'66').
Error

Line: 60

              
    public Point3[] toArray() {
        int num = (int) total();
        Point3[] ap = new Point3[num];
        if(num == 0)
            return ap;
        float buff[] = new float[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)

            

Reported by PMD.

Found 'DD'-anomaly for variable 'ap' (lines '66'-'66').
Error

Line: 66

                      float buff[] = new float[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)
            ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
        return ap;
    }

    public void fromList(List<Point3> lp) {
        Point3 ap[] = lp.toArray(new Point3[0]);

            

Reported by PMD.

modules/core/misc/java/src/java/core+MatOfPoint3.java
7 issues
Overridable method 'fromArray' called during object construction
Error

Line: 35

              
    public MatOfPoint3(Point3...a) {
        super();
        fromArray(a);
    }

    public void alloc(int elemNumber) {
        if(elemNumber>0)
            super.create(elemNumber, 1, CvType.makeType(_depth, _channels));

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '48'-'51').
Error

Line: 48

                          return;
        int num = a.length;
        alloc(num);
        int buff[] = new int[num * _channels];
        for(int i=0; i<num; i++) {
            Point3 p = a[i];
            buff[_channels*i+0] = (int) p.x;
            buff[_channels*i+1] = (int) p.y;
            buff[_channels*i+2] = (int) p.z;

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '51'-'52').
Error

Line: 51

                      int buff[] = new int[num * _channels];
        for(int i=0; i<num; i++) {
            Point3 p = a[i];
            buff[_channels*i+0] = (int) p.x;
            buff[_channels*i+1] = (int) p.y;
            buff[_channels*i+2] = (int) p.z;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '52'-'53').
Error

Line: 52

                      for(int i=0; i<num; i++) {
            Point3 p = a[i];
            buff[_channels*i+0] = (int) p.x;
            buff[_channels*i+1] = (int) p.y;
            buff[_channels*i+2] = (int) p.z;
        }
        put(0, 0, buff); //TODO: check ret val!
    }


            

Reported by PMD.

Found 'DD'-anomaly for variable 'buff' (lines '53'-'51').
Error

Line: 53

                          Point3 p = a[i];
            buff[_channels*i+0] = (int) p.x;
            buff[_channels*i+1] = (int) p.y;
            buff[_channels*i+2] = (int) p.z;
        }
        put(0, 0, buff); //TODO: check ret val!
    }

    public Point3[] toArray() {

            

Reported by PMD.

Found 'DD'-anomaly for variable 'ap' (lines '60'-'66').
Error

Line: 60

              
    public Point3[] toArray() {
        int num = (int) total();
        Point3[] ap = new Point3[num];
        if(num == 0)
            return ap;
        int buff[] = new int[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)

            

Reported by PMD.

Found 'DD'-anomaly for variable 'ap' (lines '66'-'66').
Error

Line: 66

                      int buff[] = new int[num * _channels];
        get(0, 0, buff); //TODO: check ret val!
        for(int i=0; i<num; i++)
            ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
        return ap;
    }

    public void fromList(List<Point3> lp) {
        Point3 ap[] = lp.toArray(new Point3[0]);

            

Reported by PMD.

modules/python/test/test_async.py
7 issues
Unable to import 'cv2'
Error

Line: 5 Column: 1

              from __future__ import print_function

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class AsyncTest(NewOpenCVTests):


            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
from __future__ import print_function

import numpy as np
import cv2 as cv

from tests_common import NewOpenCVTests

class AsyncTest(NewOpenCVTests):

            

Reported by Pylint.

Missing class docstring
Error

Line: 9 Column: 1

              
from tests_common import NewOpenCVTests

class AsyncTest(NewOpenCVTests):

    def test_async_simple(self):
        m = np.array([[1,2],[3,4],[5,6]])
        async_result = cv.utils.testAsyncArray(m)
        self.assertTrue(async_result.valid())

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 11 Column: 5

              
class AsyncTest(NewOpenCVTests):

    def test_async_simple(self):
        m = np.array([[1,2],[3,4],[5,6]])
        async_result = cv.utils.testAsyncArray(m)
        self.assertTrue(async_result.valid())
        ret, result = async_result.get(timeoutNs=10**6)  # 1ms
        self.assertTrue(ret)

            

Reported by Pylint.

Variable name "m" doesn't conform to snake_case naming style
Error

Line: 12 Column: 9

              class AsyncTest(NewOpenCVTests):

    def test_async_simple(self):
        m = np.array([[1,2],[3,4],[5,6]])
        async_result = cv.utils.testAsyncArray(m)
        self.assertTrue(async_result.valid())
        ret, result = async_result.get(timeoutNs=10**6)  # 1ms
        self.assertTrue(ret)
        self.assertFalse(async_result.valid())

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 21 Column: 5

                      self.assertEqual(cv.norm(m, result, cv.NORM_INF), 0)


    def test_async_exception(self):
        async_result = cv.utils.testAsyncException()
        self.assertTrue(async_result.valid())
        try:
            _ret, _result = async_result.get(timeoutNs=10**6)  # 1ms
            self.fail("Exception expected")

            

Reported by Pylint.

Variable name "e" doesn't conform to snake_case naming style
Error

Line: 27 Column: 9

                      try:
            _ret, _result = async_result.get(timeoutNs=10**6)  # 1ms
            self.fail("Exception expected")
        except cv.error as e:
            self.assertEqual(cv.Error.StsOk, e.code)



if __name__ == '__main__':

            

Reported by Pylint.

modules/ml/misc/python/test/test_knearest.py
7 issues
Unable to import 'cv2'
Error

Line: 2 Column: 1

              #!/usr/bin/env python
import cv2 as cv

from tests_common import NewOpenCVTests

class knearest_test(NewOpenCVTests):
    def test_load(self):
        k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
        self.assertFalse(k_nearest.empty())

            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 4 Column: 1

              #!/usr/bin/env python
import cv2 as cv

from tests_common import NewOpenCVTests

class knearest_test(NewOpenCVTests):
    def test_load(self):
        k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
        self.assertFalse(k_nearest.empty())

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python
import cv2 as cv

from tests_common import NewOpenCVTests

class knearest_test(NewOpenCVTests):
    def test_load(self):
        k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
        self.assertFalse(k_nearest.empty())

            

Reported by Pylint.

Too few public methods (1/2)
Error

Line: 6 Column: 1

              
from tests_common import NewOpenCVTests

class knearest_test(NewOpenCVTests):
    def test_load(self):
        k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
        self.assertFalse(k_nearest.empty())
        self.assertTrue(k_nearest.isTrained())


            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              
from tests_common import NewOpenCVTests

class knearest_test(NewOpenCVTests):
    def test_load(self):
        k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
        self.assertFalse(k_nearest.empty())
        self.assertTrue(k_nearest.isTrained())


            

Reported by Pylint.

Class name "knearest_test" doesn't conform to PascalCase naming style
Error

Line: 6 Column: 1

              
from tests_common import NewOpenCVTests

class knearest_test(NewOpenCVTests):
    def test_load(self):
        k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
        self.assertFalse(k_nearest.empty())
        self.assertTrue(k_nearest.isTrained())


            

Reported by Pylint.

Missing function or method docstring
Error

Line: 7 Column: 5

              from tests_common import NewOpenCVTests

class knearest_test(NewOpenCVTests):
    def test_load(self):
        k_nearest = cv.ml.KNearest_load(self.find_file("ml/opencv_ml_knn.xml"))
        self.assertFalse(k_nearest.empty())
        self.assertTrue(k_nearest.isTrained())

if __name__ == '__main__':

            

Reported by Pylint.