CPD Results

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

Duplications

FileLine
org/starobjects/tested/fitnesse/internal/fixtures/perform/checkthat/action/ArgumentSetNotValid.java17
org/starobjects/tested/fitnesse/internal/fixtures/perform/checkthat/action/ArgumentSetValid.java17
        super("is valid for", "is valid", "valid");
    }

    // TODO: a lot of duplication with InvokeAction; simplify somehow?
    public NakedObject that(final PerformContext performContext) {

        final NakedObject onAdapter = performContext.getOnAdapter();
        final NakedObjectMember nakedObjectMember = performContext
                .getNakedObjectMember();
        final CellBinding usingMemberBinding = performContext
                .getOnMemberBinding();
        final Parse[] argumentCells = performContext.getArgumentCells();

        final Parse onMemberCell = usingMemberBinding.getCurrentCell();

        final NakedObjectAction nakedObjectAction = (NakedObjectAction) nakedObjectMember;
        final int parameterCount = nakedObjectAction.getParameterCount();
        final boolean isContributedOneArgAction = nakedObjectAction
                .isContributed()
                && parameterCount == 1;

        if (isContributedOneArgAction) {
            return null;
        }

        if (argumentCells.length != parameterCount) {
            getOwner().throwException(onMemberCell,
                    "(action requires " + parameterCount + " arguments");
        }

        // lookup arguments
        final NakedObject[] proposedArguments = NakedObjectUtils.getAdapters(
                getOwner(), onAdapter, nakedObjectAction, argumentCells);

        // validate arguments
        final Consent argSetValid = nakedObjectAction
                .isProposedArgumentSetValid(onAdapter, proposedArguments);
        if (argSetValid.isVetoed()) {

FileLine
org/starobjects/tested/fitnesse/internal/fixtures/AliasItemsInList.java93
org/starobjects/tested/fitnesse/internal/fixtures/CheckList.java142
            found(adapter);
            return;
        }

        FitnesseUtil.exception(this, titleBinding.getCurrentCell(),
                "(not found)");
    }

    private boolean titleMatches(final NakedObject adapter) {
        final String adapterTitle = adapter.titleString();
        final String requiredTitle = titleBinding.getCurrentCell().text();
        return StringUtil.nullSafeEquals(adapterTitle, requiredTitle);
    }

    private boolean typeMatches(final NakedObject adapter) {
        if (!typeBinding.isFound()) {
            return true;
        }

        final NakedObjectSpecification spec = adapter.getSpecification();
        final String requiredTypeName = typeBinding.getCurrentCell().text();
        final String specFullName = spec.getFullName();
        if (specFullName.equals(requiredTypeName)) {
            return true;
        }

        final String simpleSpecName = StringUtil.simpleName(specFullName);
        final String simpleRequiredType = StringUtil
                .simpleName(requiredTypeName);
        return simpleSpecName.equalsIgnoreCase(simpleRequiredType);
    }

FileLine
org/starobjects/tested/fitnesse/internal/fixtures/perform/GetActionParameterChoices.java16
org/starobjects/tested/fitnesse/internal/fixtures/perform/GetActionParameterDefault.java15
        super("get action parameter default", Type.ACTION, NumParameters.ONE,
                mode);
    }

    @Override
    public void doHandle(final PerformContext performContext) {

        final NakedObject onAdapter = performContext.getOnAdapter();
        final NakedObjectMember nakedObjectMember = performContext
                .getNakedObjectMember();
        final Parse arg0Cell = performContext.getArg0Binding().getCurrentCell();
        int requestedParamNum = -1;
        try {
            requestedParamNum = Integer.valueOf(arg0Cell.text());
        } catch (final NumberFormatException ex) {
            getOwner().throwException(arg0Cell, ex.getMessage());
        }

        final NakedObjectAction noa = (NakedObjectAction) nakedObjectMember;
        final int parameterCount = noa.getParameterCount();
        if (requestedParamNum < 0 || requestedParamNum > parameterCount - 1) {
            getOwner().throwException(arg0Cell,
                    "(must be between 0 and " + (parameterCount - 1) + ")");
        }

        final NakedObject[] defaults = noa.getDefaults(onAdapter);