Giter VIP home page Giter VIP logo

Comments (5)

vitalyisaev2 avatar vitalyisaev2 commented on July 27, 2024 1

This feature is really essential. Without it I just have to disable the whole linter, because 1 is often used in cycles.

from go-mnd.

tommy-muehle avatar tommy-muehle commented on July 27, 2024 1

@vitalyisaev2
I'll release it today. :) But can you please provide an example for the case you mentioned? Maybe I can exclude it by default.

from go-mnd.

tommy-muehle avatar tommy-muehle commented on July 27, 2024 1

@bishtawi
It's implemented. Please checkout the new version v1.2.0 :)

from go-mnd.

tommy-muehle avatar tommy-muehle commented on July 27, 2024

Hi @bishtawi,

currently that's not possible. But that would be a nice addition. I'll implement it soon.

from go-mnd.

vitalyisaev2 avatar vitalyisaev2 commented on July 27, 2024

@tommy-muehle thanks for the quick implementation of this feature!

Regarding to the cases where 1 should not be considered as a magic number, please have a look at these snippets.

Custom for loop:

        // custom for loop
	for i, itemID := range ring {
		next := i + 1
		start := int(itemID)%ring.totalItems - 1

		if start < 0 {
			start += step
		}

                // ...

Branching based on int value evaluation:

    func computeResult(value int) ([][]int, error) {
	if subsets == 0 {
		return nil, fmt.Errorf("invalid value: 0")
	}

	if subsets == 1 {
		return [][]int{{255}}, nil
	}

       // more complicated logic for other cases

To be honest, I have no idea which name should I use for a variable or constant that will be equal to 1 in order to make it non-magic number :)

from go-mnd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.