The following issues were found

platforms/ios/run_tests.py
47 issues
Assigning result of a function call, where the function returns None
Error

Line: 59 Column: 9

                      return args

    def makeCMakeCmd(self):
        toolchain = self.getToolchain()
        cmakecmd = self.getCMakeArgs() + \
            (["-DCMAKE_TOOLCHAIN_FILE=%s" % toolchain] if toolchain is not None else []) + \
            ["-DCMAKE_INSTALL_NAME_TOOL=install_name_tool"]
        cmakecmd.append(self.tests_dir)
        return cmakecmd

            

Reported by Pylint.

Unused import shutil
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError

IPHONEOS_DEPLOYMENT_TARGET='9.0'  # default, can be changed via command line options or environment variable

def execute(cmd, cwd = None):

            

Reported by Pylint.

Unused import multiprocessing
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError

IPHONEOS_DEPLOYMENT_TARGET='9.0'  # default, can be changed via command line options or environment variable

def execute(cmd, cwd = None):

            

Reported by Pylint.

Unused import glob
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError

IPHONEOS_DEPLOYMENT_TARGET='9.0'  # default, can be changed via command line options or environment variable

def execute(cmd, cwd = None):

            

Reported by Pylint.

Unused import re
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError

IPHONEOS_DEPLOYMENT_TARGET='9.0'  # default, can be changed via command line options or environment variable

def execute(cmd, cwd = None):

            

Reported by Pylint.

Unused import string
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError

IPHONEOS_DEPLOYMENT_TARGET='9.0'  # default, can be changed via command line options or environment variable

def execute(cmd, cwd = None):

            

Reported by Pylint.

Unused CalledProcessError imported from subprocess
Error

Line: 8 Column: 1

              
from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError

IPHONEOS_DEPLOYMENT_TARGET='9.0'  # default, can be changed via command line options or environment variable

def execute(cmd, cwd = None):
    print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)

            

Reported by Pylint.

Unused check_output imported from subprocess
Error

Line: 8 Column: 1

              
from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback, multiprocessing
from subprocess import check_call, check_output, CalledProcessError

IPHONEOS_DEPLOYMENT_TARGET='9.0'  # default, can be changed via command line options or environment variable

def execute(cmd, cwd = None):
    print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)

            

Reported by Pylint.

Redefining name 'arch' from outer scope (line 109)
Error

Line: 20 Column: 89

                      raise Exception("Child returned:", retcode)

class TestRunner:
    def __init__(self, script_dir, tests_dir, build_dir, framework_dir, framework_name, arch, target, platform):
        self.script_dir = script_dir
        self.tests_dir = tests_dir
        self.build_dir = build_dir
        self.framework_dir = framework_dir
        self.framework_name = framework_name

            

Reported by Pylint.

Redefining name 'target' from outer scope (line 110)
Error

Line: 20 Column: 95

                      raise Exception("Child returned:", retcode)

class TestRunner:
    def __init__(self, script_dir, tests_dir, build_dir, framework_dir, framework_name, arch, target, platform):
        self.script_dir = script_dir
        self.tests_dir = tests_dir
        self.build_dir = build_dir
        self.framework_dir = framework_dir
        self.framework_name = framework_name

            

Reported by Pylint.

platforms/ios/build_docs.py
47 issues
Unused CalledProcessError imported from subprocess
Error

Line: 8 Column: 1

              
from __future__ import print_function
import os, sys, multiprocessing, argparse, traceback
from subprocess import check_call, check_output, CalledProcessError, Popen

def execute(cmd, cwd = None, output = None):
    if not output:
        print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)
        print('Executing: ' + ' '.join(cmd))

            

Reported by Pylint.

Redefining name 'target' from outer scope (line 84)
Error

Line: 24 Column: 103

                          os.waitpid(p.pid, 0)

class DocBuilder:
    def __init__(self, script_dir, framework_dir, output_dir, framework_header, framework_name, arch, target):
        self.script_dir = script_dir
        self.framework_dir = framework_dir
        self.output_dir = output_dir
        self.framework_header = framework_header
        self.framework_name = framework_name

            

Reported by Pylint.

Redefining name 'script_dir' from outer scope (line 75)
Error

Line: 24 Column: 24

                          os.waitpid(p.pid, 0)

class DocBuilder:
    def __init__(self, script_dir, framework_dir, output_dir, framework_header, framework_name, arch, target):
        self.script_dir = script_dir
        self.framework_dir = framework_dir
        self.output_dir = output_dir
        self.framework_header = framework_header
        self.framework_name = framework_name

            

Reported by Pylint.

Redefining name 'arch' from outer scope (line 83)
Error

Line: 24 Column: 97

                          os.waitpid(p.pid, 0)

class DocBuilder:
    def __init__(self, script_dir, framework_dir, output_dir, framework_header, framework_name, arch, target):
        self.script_dir = script_dir
        self.framework_dir = framework_dir
        self.output_dir = output_dir
        self.framework_header = framework_header
        self.framework_name = framework_name

            

Reported by Pylint.

Catching too general exception Exception
Error

Line: 42 Column: 16

                  def build(self):
        try:
            self._build()
        except Exception as e:
            print("="*60, file=sys.stderr)
            print("ERROR: %s" % e, file=sys.stderr)
            print("="*60, file=sys.stderr)
            traceback.print_exc(file=sys.stderr)
            sys.exit(1)

            

Reported by Pylint.

Multiple imports on one line (os, sys, multiprocessing, argparse, traceback)
Error

Line: 7 Column: 1

              """

from __future__ import print_function
import os, sys, multiprocessing, argparse, traceback
from subprocess import check_call, check_output, CalledProcessError, Popen

def execute(cmd, cwd = None, output = None):
    if not output:
        print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)

            

Reported by Pylint.

Consider possible security implications associated with check_call module.
Security blacklist

Line: 8
Suggestion: https://bandit.readthedocs.io/en/latest/blacklists/blacklist_imports.html#b404-import-subprocess

              
from __future__ import print_function
import os, sys, multiprocessing, argparse, traceback
from subprocess import check_call, check_output, CalledProcessError, Popen

def execute(cmd, cwd = None, output = None):
    if not output:
        print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)
        print('Executing: ' + ' '.join(cmd))

            

Reported by Bandit.

Missing function or method docstring
Error

Line: 10 Column: 1

              import os, sys, multiprocessing, argparse, traceback
from subprocess import check_call, check_output, CalledProcessError, Popen

def execute(cmd, cwd = None, output = None):
    if not output:
        print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)
        print('Executing: ' + ' '.join(cmd))
        retcode = check_call(cmd, cwd = cwd)
        if retcode != 0:

            

Reported by Pylint.

subprocess call - check for execution of untrusted input.
Security injection

Line: 14
Suggestion: https://bandit.readthedocs.io/en/latest/plugins/b603_subprocess_without_shell_equals_true.html

                  if not output:
        print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)
        print('Executing: ' + ' '.join(cmd))
        retcode = check_call(cmd, cwd = cwd)
        if retcode != 0:
            raise Exception("Child returned:", retcode)
    else:
        with open(output, "a") as f:
            f.flush()

            

Reported by Bandit.

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

Line: 18 Column: 35

                      if retcode != 0:
            raise Exception("Child returned:", retcode)
    else:
        with open(output, "a") as f:
            f.flush()
            p = Popen(cmd, cwd = cwd, stdout = f)
            os.waitpid(p.pid, 0)

class DocBuilder:

            

Reported by Pylint.

samples/java/tutorial_code/features2D/feature_homography/SURFFLANNMatchingHomographyDemo.java
46 issues
System.err.println is used
Design

Line: 30

                      Mat imgObject = Imgcodecs.imread(filenameObject, Imgcodecs.IMREAD_GRAYSCALE);
        Mat imgScene = Imgcodecs.imread(filenameScene, Imgcodecs.IMREAD_GRAYSCALE);
        if (imgObject.empty() || imgScene.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
        double hessianThreshold = 400;

            

Reported by PMD.

The method 'run(String)' has a NCSS line count of 64.
Design

Line: 24

              import org.opencv.xfeatures2d.SURF;

class SURFFLANNMatchingHomography {
    public void run(String[] args) {
        String filenameObject = args.length > 1 ? args[0] : "../data/box.png";
        String filenameScene = args.length > 1 ? args[1] : "../data/box_in_scene.png";
        Mat imgObject = Imgcodecs.imread(filenameObject, Imgcodecs.IMREAD_GRAYSCALE);
        Mat imgScene = Imgcodecs.imread(filenameScene, Imgcodecs.IMREAD_GRAYSCALE);
        if (imgObject.empty() || imgScene.empty()) {

            

Reported by PMD.

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

Line: 29

                      String filenameScene = args.length > 1 ? args[1] : "../data/box_in_scene.png";
        Mat imgObject = Imgcodecs.imread(filenameObject, Imgcodecs.IMREAD_GRAYSCALE);
        Mat imgScene = Imgcodecs.imread(filenameScene, Imgcodecs.IMREAD_GRAYSCALE);
        if (imgObject.empty() || imgScene.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors

            

Reported by PMD.

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

Line: 29

                      String filenameScene = args.length > 1 ? args[1] : "../data/box_in_scene.png";
        Mat imgObject = Imgcodecs.imread(filenameObject, Imgcodecs.IMREAD_GRAYSCALE);
        Mat imgScene = Imgcodecs.imread(filenameScene, Imgcodecs.IMREAD_GRAYSCALE);
        if (imgObject.empty() || imgScene.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors

            

Reported by PMD.

System.exit() should not be used in J2EE/JEE apps
Error

Line: 31

                      Mat imgScene = Imgcodecs.imread(filenameScene, Imgcodecs.IMREAD_GRAYSCALE);
        if (imgObject.empty() || imgScene.empty()) {
            System.err.println("Cannot read images!");
            System.exit(0);
        }

        //-- Step 1: Detect the keypoints using SURF Detector, compute the descriptors
        double hessianThreshold = 400;
        int nOctaves = 4, nOctaveLayers = 3;

            

Reported by PMD.

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

Line: 48

                      // Since SURF is a floating-point descriptor NORM_L2 is used
        DescriptorMatcher matcher = DescriptorMatcher.create(DescriptorMatcher.FLANNBASED);
        List<MatOfDMatch> knnMatches = new ArrayList<>();
        matcher.knnMatch(descriptorsObject, descriptorsScene, knnMatches, 2);

        //-- Filter matches using the Lowe's ratio test
        float ratioThresh = 0.75f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {

            

Reported by PMD.

This for loop can be replaced by a foreach loop
Design

Line: 53

                      //-- Filter matches using the Lowe's ratio test
        float ratioThresh = 0.75f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 54

                      float ratioThresh = 0.75f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }
            }

            

Reported by PMD.

Avoid using Literals in Conditional Statements
Error

Line: 54

                      float ratioThresh = 0.75f;
        List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }
            }

            

Reported by PMD.

Potential violation of Law of Demeter (method chain calls)
Design

Line: 55

                      List<DMatch> listOfGoodMatches = new ArrayList<>();
        for (int i = 0; i < knnMatches.size(); i++) {
            if (knnMatches.get(i).rows() > 1) {
                DMatch[] matches = knnMatches.get(i).toArray();
                if (matches[0].distance < ratioThresh * matches[1].distance) {
                    listOfGoodMatches.add(matches[0]);
                }
            }
        }

            

Reported by PMD.

samples/python/plane_tracker.py
46 issues
Unable to import 'cv2'
Error

Line: 33 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv

# built-in modules
from collections import namedtuple

# local modules

            

Reported by Pylint.

Attempting to unpack a non-sequence defined at line 188 of numpy.core.numerictypes
Error

Line: 117 Column: 13

                          target = self.targets[imgIdx]
            p0 = [target.keypoints[m.trainIdx].pt for m in matches]
            p1 = [self.frame_points[m.queryIdx].pt for m in matches]
            p0, p1 = np.float32((p0, p1))
            H, status = cv.findHomography(p0, p1, cv.RANSAC, 3.0)
            status = status.ravel() != 0
            if status.sum() < MIN_MATCH_COUNT:
                continue
            p0, p1 = p0[status], p1[status]

            

Reported by Pylint.

Too many positional arguments for method call
Error

Line: 126 Column: 44

              
            x0, y0, x1, y1 = target.rect
            quad = np.float32([[x0, y0], [x1, y0], [x1, y1], [x0, y1]])
            quad = cv.perspectiveTransform(quad.reshape(1, -1, 2), H).reshape(-1, 2)

            track = TrackedTarget(target=target, p0=p0, p1=p1, H=H, quad=quad)
            tracked.append(track)
        tracked.sort(key = lambda t: len(t.p0), reverse=True)
        return tracked

            

Reported by Pylint.

Reimport 'sys' (imported line 26)
Error

Line: 184 Column: 5

              if __name__ == '__main__':
    print(__doc__)

    import sys
    try:
        video_src = sys.argv[1]
    except:
        video_src = 0
    App(video_src).run()

            

Reported by Pylint.

No exception type(s) specified
Error

Line: 187 Column: 5

                  import sys
    try:
        video_src = sys.argv[1]
    except:
        video_src = 0
    App(video_src).run()

            

Reported by Pylint.

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

Line: 30 Column: 5

              PY3 = sys.version_info[0] == 3

if PY3:
    xrange = range

import numpy as np
import cv2 as cv

# built-in modules

            

Reported by Pylint.

Import "import numpy as np" should be placed at the top of the module
Error

Line: 32 Column: 1

              if PY3:
    xrange = range

import numpy as np
import cv2 as cv

# built-in modules
from collections import namedtuple


            

Reported by Pylint.

Import "import cv2 as cv" should be placed at the top of the module
Error

Line: 33 Column: 1

                  xrange = range

import numpy as np
import cv2 as cv

# built-in modules
from collections import namedtuple

# local modules

            

Reported by Pylint.

standard import "from collections import namedtuple" should be placed before "import numpy as np"
Error

Line: 36 Column: 1

              import cv2 as cv

# built-in modules
from collections import namedtuple

# local modules
import video
import common
from video import presets

            

Reported by Pylint.

Import "from collections import namedtuple" should be placed at the top of the module
Error

Line: 36 Column: 1

              import cv2 as cv

# built-in modules
from collections import namedtuple

# local modules
import video
import common
from video import presets

            

Reported by Pylint.

modules/gapi/misc/python/test/test_gapi_core.py
45 issues
Unable to import 'cv2'
Error

Line: 4 Column: 1

              #!/usr/bin/env python

import numpy as np
import cv2 as cv
import os
import sys
import unittest

from tests_common import NewOpenCVTests

            

Reported by Pylint.

Unable to import 'tests_common'
Error

Line: 9 Column: 1

              import sys
import unittest

from tests_common import NewOpenCVTests


try:

    if sys.version_info[:2] < (3, 0):

            

Reported by Pylint.

Method has no argument
Error

Line: 205 Column: 9

                      def setUp(self):
            self.skipTest('Skip tests: ' + message)

        def test_skip():
            pass

    pass



            

Reported by Pylint.

TODO: Extend to use any type and size here
Error

Line: 29 Column: 3

                  class gapi_core_test(NewOpenCVTests):

        def test_add(self):
            # TODO: Extend to use any type and size here
            sz = (720, 1280)
            in1 = np.full(sz, 100)
            in2 = np.full(sz, 50)

            # OpenCV

            

Reported by Pylint.

Redefining name 'e' from outer scope (line 197)
Error

Line: 107 Column: 21

                          for pkg_name, pkg in pkgs:
                actual = comp.apply(cv.gin(in_mat), args=cv.gapi.compile_args(pkg))
                # Comparison
                for e, a in zip(expected, actual):
                    self.assertEqual(0.0, cv.norm(e, a, cv.NORM_INF),
                                     'Failed on ' + pkg_name + ' backend')
                    self.assertEqual(e.dtype, a.dtype, 'Failed on ' + pkg_name + ' backend')



            

Reported by Pylint.

Unnecessary pass statement
Error

Line: 208 Column: 5

                      def test_skip():
            pass

    pass


if __name__ == '__main__':
    NewOpenCVTests.bootstrap()

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              #!/usr/bin/env python

import numpy as np
import cv2 as cv
import os
import sys
import unittest

from tests_common import NewOpenCVTests

            

Reported by Pylint.

standard import "import os" should be placed before "import numpy as np"
Error

Line: 5 Column: 1

              
import numpy as np
import cv2 as cv
import os
import sys
import unittest

from tests_common import NewOpenCVTests


            

Reported by Pylint.

standard import "import sys" should be placed before "import numpy as np"
Error

Line: 6 Column: 1

              import numpy as np
import cv2 as cv
import os
import sys
import unittest

from tests_common import NewOpenCVTests



            

Reported by Pylint.

standard import "import unittest" should be placed before "import numpy as np"
Error

Line: 7 Column: 1

              import cv2 as cv
import os
import sys
import unittest

from tests_common import NewOpenCVTests


try:

            

Reported by Pylint.

modules/python/test/test_filestorage_io.py
45 issues
Unable to import 'cv2'
Error

Line: 8 Column: 1

              import json
import tempfile
import os
import cv2 as cv
import numpy as np
from tests_common import NewOpenCVTests

class MyData:
    def __init__(self):

            

Reported by Pylint.

Missing class docstring
Error

Line: 12 Column: 1

              import numpy as np
from tests_common import NewOpenCVTests

class MyData:
    def __init__(self):
        self.A = 97
        self.X = np.pi
        self.name = 'mydata1234'


            

Reported by Pylint.

Attribute name "A" doesn't conform to snake_case naming style
Error

Line: 14 Column: 9

              
class MyData:
    def __init__(self):
        self.A = 97
        self.X = np.pi
        self.name = 'mydata1234'

    def write(self, fs, name):
        fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)

            

Reported by Pylint.

Attribute name "X" doesn't conform to snake_case naming style
Error

Line: 15 Column: 9

              class MyData:
    def __init__(self):
        self.A = 97
        self.X = np.pi
        self.name = 'mydata1234'

    def write(self, fs, name):
        fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)
        fs.write('A', self.A)

            

Reported by Pylint.

Argument name "fs" doesn't conform to snake_case naming style
Error

Line: 18 Column: 5

                      self.X = np.pi
        self.name = 'mydata1234'

    def write(self, fs, name):
        fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)
        fs.write('A', self.A)
        fs.write('X', self.X)
        fs.write('name', self.name)
        fs.endWriteStruct()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 18 Column: 5

                      self.X = np.pi
        self.name = 'mydata1234'

    def write(self, fs, name):
        fs.startWriteStruct(name, cv.FileNode_MAP|cv.FileNode_FLOW)
        fs.write('A', self.A)
        fs.write('X', self.X)
        fs.write('name', self.name)
        fs.endWriteStruct()

            

Reported by Pylint.

Missing function or method docstring
Error

Line: 25 Column: 5

                      fs.write('name', self.name)
        fs.endWriteStruct()

    def read(self, node):
        if (not node.empty()):
            self.A = int(node.getNode('A').real())
            self.X = node.getNode('X').real()
            self.name = node.getNode('name').string()
        else:

            

Reported by Pylint.

Unnecessary parens after 'if' keyword
Error

Line: 26 Column: 1

                      fs.endWriteStruct()

    def read(self, node):
        if (not node.empty()):
            self.A = int(node.getNode('A').real())
            self.X = node.getNode('X').real()
            self.name = node.getNode('name').string()
        else:
            self.A = self.X = 0

            

Reported by Pylint.

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

Line: 34 Column: 1

                          self.A = self.X = 0
            self.name = ''

class filestorage_io_test(NewOpenCVTests):
    strings_data = ['image1.jpg', 'Awesomeness', '../data/baboon.jpg']
    R0 = np.eye(3,3)
    T0 = np.zeros((3,1))

    def write_data(self, fname):

            

Reported by Pylint.

Missing class docstring
Error

Line: 34 Column: 1

                          self.A = self.X = 0
            self.name = ''

class filestorage_io_test(NewOpenCVTests):
    strings_data = ['image1.jpg', 'Awesomeness', '../data/baboon.jpg']
    R0 = np.eye(3,3)
    T0 = np.zeros((3,1))

    def write_data(self, fname):

            

Reported by Pylint.

modules/features2d/misc/java/test/BruteForceHammingLUTDescriptorMatcherTest.java
45 issues
This class has too many methods, consider refactoring it.
Design

Line: 20

              import org.opencv.imgproc.Imgproc;
import org.opencv.features2d.Feature2D;

public class BruteForceHammingLUTDescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 22

              
public class BruteForceHammingLUTDescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(4, 4, CvType.CV_8U, new Scalar(0)) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 23

              public class BruteForceHammingLUTDescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(4, 4, CvType.CV_8U, new Scalar(0)) {
            {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 24

              
    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(4, 4, CvType.CV_8U, new Scalar(0)) {
            {
                put(0, 0, 1, 1, 1, 1, 1, 1, 1, 1);

            

Reported by PMD.

Double-brace initialization should be avoided
Design

Line: 28

              
    private Mat getMaskImg() {
        return new Mat(4, 4, CvType.CV_8U, new Scalar(0)) {
            {
                put(0, 0, 1, 1, 1, 1, 1, 1, 1, 1);
            }
        };
    }


            

Reported by PMD.

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

Line: 51

                      Feature2D detector = FastFeatureDetector.create();
        Feature2D extractor = createClassInstance(XFEATURES2D+"BriefDescriptorExtractor", DEFAULT_FACTORY, null, null);

        detector.detect(img, keypoints);
        extractor.compute(img, keypoints, descriptors);

        return descriptors;
    }


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 67

                      return img;
    }

    protected void setUp() throws Exception {
        super.setUp();
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMINGLUT);
        matSize = 100;

        truth = new DMatch[] {

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 67

                      return img;
    }

    protected void setUp() throws Exception {
        super.setUp();
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_HAMMINGLUT);
        matSize = 100;

        truth = new DMatch[] {

            

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: 79

                              new DMatch(3, 3, 0, 53) };
    }

    public void testAdd() {
        matcher.add(Arrays.asList(new Mat()));
        assertFalse(matcher.empty());
    }

    public void testClear() {

            

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: 84

                      assertFalse(matcher.empty());
    }

    public void testClear() {
        matcher.add(Arrays.asList(new Mat()));

        matcher.clear();

        assertTrue(matcher.empty());

            

Reported by PMD.

modules/imgproc/misc/java/src/java/imgproc+Moments.java
45 issues
Overridable method 'completeState' called during object construction
Error

Line: 55

                      this.m21 = m21;
        this.m12 = m12;
        this.m03 = m03;
        this.completeState();
    }

    public Moments() {
        this(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    }

            

Reported by PMD.

Overridable method 'set' called during object construction
Error

Line: 63

                  }

    public Moments(double[] vals) {
        set(vals);
    }

    public void set(double[] vals) {
        if (vals != null) {
            m00 = vals.length > 0 ? vals[0] : 0;

            

Reported by PMD.

This class has a bunch of public methods and attributes
Design

Line: 1

              package org.opencv.imgproc;

//javadoc:Moments
public class Moments {

    public double m00;
    public double m10;
    public double m01;
    public double m20;

            

Reported by PMD.

Possible God Class (WMC=66, ATFD=10, TCC=4.235%)
Design

Line: 4

              package org.opencv.imgproc;

//javadoc:Moments
public class Moments {

    public double m00;
    public double m10;
    public double m01;
    public double m20;

            

Reported by PMD.

The class 'Moments' has a Modified Cyclomatic Complexity of 1 (Highest = 12).
Design

Line: 4

              package org.opencv.imgproc;

//javadoc:Moments
public class Moments {

    public double m00;
    public double m10;
    public double m01;
    public double m20;

            

Reported by PMD.

The class 'Moments' has a Standard Cyclomatic Complexity of 1 (Highest = 12).
Design

Line: 4

              package org.opencv.imgproc;

//javadoc:Moments
public class Moments {

    public double m00;
    public double m10;
    public double m01;
    public double m20;

            

Reported by PMD.

Too many fields
Design

Line: 4

              package org.opencv.imgproc;

//javadoc:Moments
public class Moments {

    public double m00;
    public double m10;
    public double m01;
    public double m20;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 6

              //javadoc:Moments
public class Moments {

    public double m00;
    public double m10;
    public double m01;
    public double m20;
    public double m11;
    public double m02;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 7

              public class Moments {

    public double m00;
    public double m10;
    public double m01;
    public double m20;
    public double m11;
    public double m02;
    public double m30;

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 8

              
    public double m00;
    public double m10;
    public double m01;
    public double m20;
    public double m11;
    public double m02;
    public double m30;
    public double m21;

            

Reported by PMD.

modules/features2d/misc/java/test/BruteForceL1DescriptorMatcherTest.java
44 issues
This class has too many methods, consider refactoring it.
Design

Line: 20

              import org.opencv.imgproc.Imgproc;
import org.opencv.features2d.Feature2D;

public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 22

              
public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 23

              public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {
            {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 24

              
    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {
            {
                put(0, 0, 1, 1, 1, 1);

            

Reported by PMD.

Double-brace initialization should be avoided
Design

Line: 28

              
    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {
            {
                put(0, 0, 1, 1, 1, 1);
            }
        };
    }


            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 82

                      return cross;
    }

    protected void setUp() throws Exception {
        super.setUp();
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_L1);
        matSize = 100;

        truth = new DMatch[] {

            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 82

                      return cross;
    }

    protected void setUp() throws Exception {
        super.setUp();
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_L1);
        matSize = 100;

        truth = new DMatch[] {

            

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: 96

                              };
    }

    public void testAdd() {
        matcher.add(Arrays.asList(new Mat()));
        assertFalse(matcher.empty());
    }

    public void testClear() {

            

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

                      assertFalse(matcher.empty());
    }

    public void testClear() {
        matcher.add(Arrays.asList(new Mat()));

        matcher.clear();

        assertTrue(matcher.empty());

            

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: 109

                      assertTrue(matcher.empty());
    }

    public void testClone() {
        Mat train = new Mat(1, 1, CvType.CV_8U, new Scalar(123));
        Mat truth = train.clone();
        matcher.add(Arrays.asList(train));

        DescriptorMatcher cloned = matcher.clone();

            

Reported by PMD.

modules/features2d/misc/java/test/BruteForceSL2DescriptorMatcherTest.java
44 issues
This class has too many methods, consider refactoring it.
Design

Line: 20

              import org.opencv.imgproc.Imgproc;
import org.opencv.features2d.Feature2D;

public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;


            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 22

              
public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 23

              public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {

    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {
            {

            

Reported by PMD.

Found non-transient, non-static member. Please mark as transient or provide accessors.
Error

Line: 24

              
    DescriptorMatcher matcher;
    int matSize;
    DMatch[] truth;

    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {
            {
                put(0, 0, 1, 1, 1, 1);

            

Reported by PMD.

Double-brace initialization should be avoided
Design

Line: 28

              
    private Mat getMaskImg() {
        return new Mat(5, 2, CvType.CV_8U, new Scalar(0)) {
            {
                put(0, 0, 1, 1, 1, 1);
            }
        };
    }


            

Reported by PMD.

JUnit 4 tests that set up tests should use the @Before annotation, JUnit5 tests should use @BeforeEach or @BeforeAll
Design

Line: 87

                      return cross;
    }

    protected void setUp() throws Exception {
        super.setUp();
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_SL2);
        matSize = 100;

        truth = new DMatch[] {

            

Reported by PMD.

A method/constructor should not explicitly throw java.lang.Exception
Design

Line: 87

                      return cross;
    }

    protected void setUp() throws Exception {
        super.setUp();
        matcher = DescriptorMatcher.create(DescriptorMatcher.BRUTEFORCE_SL2);
        matSize = 100;

        truth = new DMatch[] {

            

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

                              };
    }

    public void testAdd() {
        matcher.add(Arrays.asList(new Mat()));
        assertFalse(matcher.empty());
    }

    public void testClear() {

            

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: 106

                      assertFalse(matcher.empty());
    }

    public void testClear() {
        matcher.add(Arrays.asList(new Mat()));

        matcher.clear();

        assertTrue(matcher.empty());

            

Reported by PMD.

Unit tests should not contain more than 1 assert(s).
Design

Line: 114

                      assertTrue(matcher.empty());
    }

    public void testClone() {
        Mat train = new Mat(1, 1, CvType.CV_8U, new Scalar(123));
        Mat truth = train.clone();
        matcher.add(Arrays.asList(train));

        DescriptorMatcher cloned = matcher.clone();

            

Reported by PMD.