CPD Results

The following document contains the results of PMD's CPD 6.21.0.

Duplications

File Line
org\djunits\generator\GenerateDJUNIT.java 457
org\djunits\generator\GenerateDJUNIT.java 639
    private static String formulasVector(final String java, final String errorType, final String prefix)
    {
        String ret = java;
        while (ret.contains("%FORMULAS%"))
        {
            int pos = ret.indexOf("%FORMULAS%");
            ret = ret.replaceFirst("%FORMULAS%", "");
            int end = ret.indexOf("%", pos);
            if (end == -1)
            {
                System.err.println("Closing % not found for %FORMULAS% in file for type " + errorType);
                return ret;
            }
            String type = ret.substring(pos, end);
            if (!formulas.containsKey(type))
            {
                System.err.println("Formulas in FORMULAS.txt does not contain entry for type " + errorType);
                return ret.substring(0, pos - 1) + ret.substring(pos + type.length() + 2, ret.length() - 1);
            }
            String fStr = "";
            ret = ret.substring(0, pos - 1) + fStr + ret.substring(pos + type.length() + 1, ret.length() - 1);
        }
        return ret;
    }

    /****************************************************************************************************************/
    /********************************************* DOUBLEVECTOR *****************************************************/
    /****************************************************************************************************************/

    /**
     * Generate all Abs + Rel classes in value.vdouble.vector.
     * @throws IOException on I/O error
     * @throws URISyntaxException when file could not be found on the file system
     */
    private static void generateDoubleVectorAbsRel() throws IOException, URISyntaxException
File Line
org\djunits\generator\GenerateStaticUNITS.java 73
org\djunits\generator\GenerateStaticUNITS.java 88
            for (Field f : c.getFields())
            {
                if (Modifier.isPublic(f.getModifiers()) && Modifier.isStatic(f.getModifiers())
                        && Modifier.isFinal(f.getModifiers()) && !f.getName().equals("SI")
                        && !f.getName().equals("STANDARD_UNITS"))
                {
                    String n = f.getName();
                    if (f.getName().contains("ELECTRONVOLT"))
                    {
                        n = cs.trim() + "_" + n;
                    }
File Line
org\djunits\generator\GenerateDJUNIT.java 826
org\djunits\generator\GenerateDJUNIT.java 863
org\djunits\generator\GenerateDJUNIT.java 904
org\djunits\generator\GenerateDJUNIT.java 941
org\djunits\generator\GenerateDJUNIT.java 982
org\djunits\generator\GenerateDJUNIT.java 1019
                .readAllBytes(Paths.get(URLResource.getResource("/resources/" + relativePath + "SISCALAR_AS.java").toURI())));

        List<String> allRelTypes = new ArrayList<>(typesRel);
        for (String[] arType : typesAbsRel)
        {
            allRelTypes.add(arType[1]);
        }

        String asMethods = "";
        for (String type : allRelTypes)
        {
            String lc = type.toLowerCase();
            asMethods += asJava.replaceAll("%Type%", type).replaceAll("%type%", lc);
        }

        File outPath = new File(absoluteRootPath + relativePath);
        outPath.mkdirs();
        PrintWriter out = new PrintWriter(absoluteRootPath + relativePath + "SIScalar.java");
File Line
org\djunits\generator\GenerateDJUNIT.java 1055
org\djunits\generator\GenerateXSD.java 309
    private static void makeAndCleanAbsolutePath() throws FileNotFoundException
    {
        URL mainURL = URLResource.getResource("/");
        String path;
        try
        {
            path = mainURL.toURI().getPath();
        }
        catch (URISyntaxException exception)
        {
            path = mainURL.getPath();
        }
        if (path.endsWith("/target/classes/"))
        {
            path = path.substring(0, path.length() - "/target/classes/".length());
        }
        path += generatedCodeRelativePath;
        if (!new File(path).exists())
        {
            new File(path).mkdirs();
        }