Showing 61 of 61 total issues
Similar blocks of code found in 6 locations. Consider refactoring. Open
func assetsDockerfileGo() (*asset, error) {
bytes, err := assetsDockerfileGoBytes()
if err != nil {
return nil, err
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 112.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 6 locations. Consider refactoring. Open
func assetsEntrypointGo() (*asset, error) {
bytes, err := assetsEntrypointGoBytes()
if err != nil {
return nil, err
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 112.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function NewDisplay
has 6 return statements (exceeds 4 allowed). Open
func NewDisplay(ctx context.Context, title string, maxSection int) (display *Display, nctx context.Context, err error) {
g, err := gocui.NewGui(gocui.OutputNormal)
if err != nil {
return
Function archiveContext
has 6 return statements (exceeds 4 allowed). Open
func archiveContext(ctx context.Context, root string, writer io.Writer) (err error) {
// Create a buffered writer.
bufWriter := bufio.NewWriter(writer)
defer bufWriter.Flush()
Function Dockerfile
has 6 return statements (exceeds 4 allowed). Open
func Dockerfile(travis *Travis, opt *DockerfileOpt, archive string) (res []byte, err error) {
var data []byte
// Loading the base template.
Function RestoreAsset
has 6 return statements (exceeds 4 allowed). Open
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
Function parseMatrixPython
has 5 return statements (exceeds 4 allowed). Open
func parseMatrixPython(v interface{}) (version string, c TestCase, err error) {
m, ok := v.(map[interface{}]interface{})
if !ok {
err = fmt.Errorf("Given item is broken.")
Function Entrypoint
has 5 return statements (exceeds 4 allowed). Open
func Entrypoint(travis *Travis) (res []byte, err error) {
var (
data []byte
temp *template.Template
Function Build
has 5 return statements (exceeds 4 allowed). Open
func Build(ctx context.Context, dir, tag, version string, noCache bool, output io.Writer) (err error) {
// Create a docker client.
cli, err := client.NewEnvClient()
if err != nil {
Method Display.Layout
has 5 return statements (exceeds 4 allowed). Open
func (d *Display) Layout(g *gocui.Gui) error {
if d.closed {
return fmt.Errorf("Display has been closed already")
}
Function TestPythonArgumentSetWithFullDescriptions
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func TestPythonArgumentSetWithFullDescriptions(t *testing.T) {
travis, err := storeAndLoadTravis(&Travis{
Language: "python",
Python: []string{"2.7", "3.5"},
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function TestGoArgumentSetWithFullDescriptions
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func TestGoArgumentSetWithFullDescriptions(t *testing.T) {
travis, err := storeAndLoadTravis(&Travis{
Language: "go",
Go: []string{"1.6", "1.7"},
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Your code does not pass gofmt in 4 places. Go fmt your code! Open
// Code generated by go-bindata.
- Exclude checks
error strings should not be capitalized or end with punctuation or a newline Open
err = fmt.Errorf("Given item is broken.")
- Exclude checks
error strings should not be capitalized or end with punctuation or a newline Open
fmt.Errorf("%v\n%v\n%v\n", msg, err.Error(), sec.String()))
- Exclude checks
error strings should not be capitalized or end with punctuation or a newline Open
err = fmt.Errorf("Given item is broken.")
- Exclude checks
error strings should not be capitalized or end with punctuation or a newline Open
err = fmt.Errorf("Env of the given item is broken.")
- Exclude checks
error strings should not be capitalized or end with punctuation or a newline Open
err = fmt.Errorf("Env of the given item is broken.")
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
//
- Exclude checks
Your code does not pass gofmt in 1 place. Go fmt your code! Open
//
- Exclude checks