jscpd - copy/paste report

Dashboard

Total Files

7

Total Lines of Code

151

Number of Clones

3

Duplicated Lines

49 (32.45%)

Formats with Duplications

Format Files Lines Clones Duplicated Lines Duplicated Tokens
docker 2 30 1 13 (43.33%) 94 (39.66%)
elixir 2 40 1 17 (42.50%) 116 (46.77%)
makefile 2 42 1 19 (45.24%) 104 (45.22%)
markdown 1 39 0 0 (0.00%) 0 (0.00%)
Total 7 151 3 49 (32.45%) 314 (26.79%)

docker

services/api/Dockerfile (Line 1:1 - Line 13:9), services/worker/Dockerfile (Line 1:1 - Line 13:9)
services/api/Dockerfile
# syntax=docker/dockerfile:1.7
FROM node:22-alpine AS deps
WORKDIR /srv/app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts

FROM node:22-alpine AS runtime
ENV NODE_ENV=production
WORKDIR /srv/app
RUN addgroup -S app && adduser -S app -G app
COPY --from=deps /srv/app/node_modules ./node_modules
COPY dist/* ./dist/
USER app
services/worker/Dockerfile
# syntax=docker/dockerfile:1.7
FROM node:22-alpine AS deps
WORKDIR /srv/app
COPY package.json package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts

FROM node:22-alpine AS runtime
ENV NODE_ENV=production
WORKDIR /srv/app
RUN addgroup -S app && adduser -S app -G app
COPY --from=deps /srv/app/node_modules ./node_modules
COPY dist/* ./dist/
USER app

elixir

lib/shop/invoice_totals.ex (Line 4:3 - Line 20:4), lib/shop/refund_totals.ex (Line 4:3 - Line 20:4)
lib/shop/invoice_totals.ex
  def total(lines, opts \\ []) do
    currency = Keyword.get(opts, :currency, "EUR")

    lines
    |> Enum.reject(&(&1.quantity == 0))
    |> Enum.map(fn line -> line.unit_price * line.quantity end)
    |> Enum.sum()
    |> round_to_cents()
    |> then(&{currency, &1})
  end

  defp round_to_cents(amount) when is_float(amount) do
    Float.round(amount, 2)
  end

  defp round_to_cents(amount), do: amount
end
lib/shop/refund_totals.ex
  def total(lines, opts \\ []) do
    currency = Keyword.get(opts, :currency, "EUR")

    lines
    |> Enum.reject(&(&1.quantity == 0))
    |> Enum.map(fn line -> line.unit_price * line.quantity end)
    |> Enum.sum()
    |> round_to_cents()
    |> then(&{currency, &1})
  end

  defp round_to_cents(amount) when is_float(amount) do
    Float.round(amount, 2)
  end

  defp round_to_cents(amount), do: amount
end

makefile

services/api/Makefile (Line 3:1 - Line 21:22), services/worker/Makefile (Line 3:1 - Line 21:22)
services/api/Makefile
IMAGE := registry.example.com/shop/$(SERVICE)
VERSION ?= $(shell git describe --tags --always --dirty)

.PHONY: build push test lint clean

build:
	docker build --pull -t $(IMAGE):$(VERSION) .

push: build
	docker push $(IMAGE):$(VERSION)

test:
	npm test -- --reporter=dot

lint:
	npx eslint src --max-warnings=0

clean:
	rm -rf dist coverage
services/worker/Makefile
IMAGE := registry.example.com/shop/$(SERVICE)
VERSION ?= $(shell git describe --tags --always --dirty)

.PHONY: build push test lint clean

build:
	docker build --pull -t $(IMAGE):$(VERSION) .

push: build
	docker push $(IMAGE):$(VERSION)

test:
	npm test -- --reporter=dot

lint:
	npx eslint src --max-warnings=0

clean:
	rm -rf dist coverage