Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/go-cross.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Go Matrix
on: [push, pull_request]

jobs:

cross:
name: Go
runs-on: ${{ matrix.os }}
env:
CGO_ENABLED: 0

strategy:
matrix:
go-version: [ oldstable, stable ]
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
# https://github.com/marketplace/actions/checkout
- name: Checkout code
uses: actions/checkout@v4

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Test
run: go test -v -cover ./...

- name: Build
run: go build -v -ldflags "-s -w" -trimpath
43 changes: 43 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Main

on:
push:
branches:
- main
pull_request:

jobs:

main:
name: Main Process
runs-on: ubuntu-latest
env:
GO_VERSION: stable
GOLANGCI_LINT_VERSION: v1.57.0
CGO_ENABLED: 0

steps:
# https://github.com/marketplace/actions/checkout
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

# https://github.com/marketplace/actions/setup-go-environment
- name: Set up Go ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Check and get dependencies
run: |
go mod download
go mod tidy
git diff --exit-code go.mod

# https://golangci-lint.run/usage/install#other-ci
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}

- name: Make
run: make
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
/dupl
4 changes: 0 additions & 4 deletions .travis.yml

This file was deleted.

15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.PHONY: clean check test build

default: clean check test build

clean:
rm -rf dist/ cover.out

test: clean
go test -v -cover ./...

check:
golangci-lint run

build:
go build -ldflags "-s -w" -trimpath
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# dupl [![Build Status](https://travis-ci.org/mibk/dupl.png)](https://travis-ci.org/mibk/dupl)
# dupl

**dupl** is a tool written in Go for finding code clones. So far it can find clones only
in the Go source files. The method uses suffix tree for serialized ASTs. It ignores values
of AST nodes. It just operates with their types (e.g. `if a == 13 {}` and `if x == 100 {}` are
considered the same provided it exceeds the minimal token sequence size).

Due to the used method dupl can report so called "false positives" on the output. These are
Due to the used method dupl can report so-called "false positives" on the output. These are
the ones we do not consider clones (whether they are too small, or the values of the matched
tokens are completely different).

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/mibk/dupl

go 1.14
go 1.21
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -80,7 +79,7 @@ func main() {
} else if *plumbing {
newPrinter = printer.NewPlumbing
}
p := newPrinter(os.Stdout, ioutil.ReadFile)
p := newPrinter(os.Stdout, os.ReadFile)
if err := printDupls(p, duplChan); err != nil {
log.Fatal(err)
}
Expand Down