codeanalyzer/src/main/java/nl/obren/sokrates/sourcecode/lang/lua/LuaHeuristicUnitsExtractor.java [62:135]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void updateUnit(String line) {
        unitBody.append(line).append("\n");
        if (!line.trim().isEmpty()) {
            cleanedUnitBody.append(line).append("\n");
            loc += 1;
        }
    }

    private void endUnit(int lineIndex) {
        unit.setBody(unitBody.toString());
        unit.setCleanedBody(cleanedUnitBody.toString());
        unit.setLinesOfCode(loc);
        unit.setEndLine(lineIndex);

        updateParamsAndMcCabeIndex(unitBody.toString());
        unit = null;
        unitBody = null;
        cleanedUnitBody = null;
    }

    private void initUnit(List<UnitInfo> units, String line, int lineIndex) {
        String trimmedLine = line.trim();
        unit = new UnitInfo();
        units.add(unit);
        unit.setStartLine(lineIndex);

        unit.setSourceFile(sourceFile);

        prefix = "";
        int i = 0;
        while (line.charAt(i++) == ' ') {
            prefix += ' ';
        }

        unitBody = new StringBuilder();
        unitBody.append(line).append("\n");

        cleanedUnitBody = new StringBuilder();
        cleanedUnitBody.append(line).append("\n");

        unit.setShortName(trimmedLine.replaceAll("[(].*", "()"));
        loc = 1;
    }

    private CommentsAndEmptyLinesCleaner getCommentsAndEmptyLinesCleanerExtraString() {
        CommentsAndEmptyLinesCleaner cleaner = analyzer.getCommentsAndEmptyLinesCleaner();
        cleaner.getCodeBlockParsers().forEach(codeBlockParser -> codeBlockParser.setRemoveWhenCleaning(true));
        return cleaner;
    }

    private void updateParamsAndMcCabeIndex(String body) {
        CommentsAndEmptyLinesCleaner cleaner = getCommentsAndEmptyLinesCleanerExtraString();
        String content = cleaner.cleanKeepEmptyLines(body);

        String bodyForSearch = " " + content.replace("\n", " ");
        bodyForSearch = bodyForSearch.replace("(", " (");
        bodyForSearch = bodyForSearch.replace("{", " {");

        int startOfParamsSearchIndex = body.indexOf("(");
        int endOfParamsSearchIndex = body.indexOf(")", startOfParamsSearchIndex + 1);
        if (unit.getShortName().contains("(")) {
            unit.setShortName(unit.getShortName().substring(0, unit.getShortName().indexOf("(")).trim() + "()");
        }
        if (startOfParamsSearchIndex > 0 && endOfParamsSearchIndex > 0 && endOfParamsSearchIndex > startOfParamsSearchIndex) {
            String trimedParams = body.substring(startOfParamsSearchIndex + 1, endOfParamsSearchIndex).trim();
            if (!trimedParams.isEmpty()) {
                String[] params = trimedParams.split("\\,");
                unit.setNumberOfParameters(params.length);
            }
        }

        int mcCabeIndex = 1;
        mcCabeIndex += StringUtils.countMatches(bodyForSearch, " if ");
        mcCabeIndex += StringUtils.countMatches(bodyForSearch, " elseif ");
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



codeanalyzer/src/main/java/nl/obren/sokrates/sourcecode/lang/julia/JuliaHeuristicUnitsExtractor.java [60:133]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    private void updateUnit(String line) {
        unitBody.append(line).append("\n");
        if (!line.trim().isEmpty()) {
            cleanedUnitBody.append(line).append("\n");
            loc += 1;
        }
    }

    private void endUnit(int lineIndex) {
        unit.setBody(unitBody.toString());
        unit.setCleanedBody(cleanedUnitBody.toString());
        unit.setLinesOfCode(loc);
        unit.setEndLine(lineIndex);

        updateParamsAndMcCabeIndex(unitBody.toString());
        unit = null;
        unitBody = null;
        cleanedUnitBody = null;
    }

    private void initUnit(List<UnitInfo> units, String line, int lineIndex) {
        String trimmedLine = line.trim();
        unit = new UnitInfo();
        units.add(unit);
        unit.setStartLine(lineIndex);

        unit.setSourceFile(sourceFile);

        prefix = "";
        int i = 0;
        while (line.charAt(i++) == ' ') {
            prefix += ' ';
        }

        unitBody = new StringBuilder();
        unitBody.append(line).append("\n");

        cleanedUnitBody = new StringBuilder();
        cleanedUnitBody.append(line).append("\n");

        unit.setShortName(trimmedLine.replaceAll("[(].*", "()"));
        loc = 1;
    }

    private CommentsAndEmptyLinesCleaner getCommentsAndEmptyLinesCleanerExtraString() {
        CommentsAndEmptyLinesCleaner cleaner = analyzer.getCommentsAndEmptyLinesCleaner();
        cleaner.getCodeBlockParsers().forEach(codeBlockParser -> codeBlockParser.setRemoveWhenCleaning(true));
        return cleaner;
    }

    private void updateParamsAndMcCabeIndex(String body) {
        CommentsAndEmptyLinesCleaner cleaner = getCommentsAndEmptyLinesCleanerExtraString();
        String content = cleaner.cleanKeepEmptyLines(body);

        String bodyForSearch = " " + content.replace("\n", " ");
        bodyForSearch = bodyForSearch.replace("(", " (");
        bodyForSearch = bodyForSearch.replace("{", " {");

        int startOfParamsSearchIndex = body.indexOf("(");
        int endOfParamsSearchIndex = body.indexOf(")", startOfParamsSearchIndex + 1);
        if (unit.getShortName().contains("(")) {
            unit.setShortName(unit.getShortName().substring(0, unit.getShortName().indexOf("(")).trim() + "()");
        }
        if (startOfParamsSearchIndex > 0 && endOfParamsSearchIndex > 0 && endOfParamsSearchIndex > startOfParamsSearchIndex) {
            String trimedParams = body.substring(startOfParamsSearchIndex + 1, endOfParamsSearchIndex).trim();
            if (!trimedParams.isEmpty()) {
                String[] params = trimedParams.split("\\,");
                unit.setNumberOfParameters(params.length);
            }
        }

        int mcCabeIndex = 1;
        mcCabeIndex += StringUtils.countMatches(bodyForSearch, " if ");
        mcCabeIndex += StringUtils.countMatches(bodyForSearch, " elseif ");
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



