universe/planet.go
Method Planet.ImportMoons
has 81 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *Planet) ImportMoons() error {
var moons = make(Moons, 0, len(p.Moons))
var err error
for moonID, moon := range p.Moons {
moon.moonID = moonID
Method SolarSystem.ImportPlanet
has 78 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *SolarSystem) ImportPlanet(planetID int64, planet Planet) error {
var err error
planet.name, err = getItemNameByID(planetID)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("Error fetching planet name for planet %d, solar system %s",
Method SolarSystem.ImportPlanet
has 10 return statements (exceeds 4 allowed). Open
Open
func (s *SolarSystem) ImportPlanet(planetID int64, planet Planet) error {
var err error
planet.name, err = getItemNameByID(planetID)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("Error fetching planet name for planet %d, solar system %s",
Method Planet.ImportMoons
has 8 return statements (exceeds 4 allowed). Open
Open
func (p *Planet) ImportMoons() error {
var moons = make(Moons, 0, len(p.Moons))
var err error
for moonID, moon := range p.Moons {
moon.moonID = moonID
Method Planet.ImportBelts
has 5 return statements (exceeds 4 allowed). Open
Open
func (p *Planet) ImportBelts() error {
var err error
var belts = make(AsteroidBelts, 0, len(p.AsteroidBelts))
for beltID, belt := range p.AsteroidBelts {
belt.planet = p
Method Planet.ImportMoons
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func (p *Planet) ImportMoons() error {
var moons = make(Moons, 0, len(p.Moons))
var err error
for moonID, moon := range p.Moons {
moon.moonID = moonID
- 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
XXX found Open
Open
index+1, // XXX need to fix orbit index
- Exclude checks
exported method SolarSystem.ImportPlanet should have comment or be unexported Open
Open
func (s *SolarSystem) ImportPlanet(planetID int64, planet Planet) error {
- Exclude checks
exported method Planet.ImportBelts should have comment or be unexported Open
Open
func (p *Planet) ImportBelts() error {
- Exclude checks
exported type AsteroidBelt should have comment or be unexported Open
Open
type AsteroidBelt struct {
- Exclude checks
exported type Planet should have comment or be unexported Open
Open
type Planet struct {
- Exclude checks
exported type AsteroidBelts should have comment or be unexported Open
Open
type AsteroidBelts []AsteroidBelt
- Exclude checks
exported method Planet.ImportMoons should have comment or be unexported Open
Open
func (p *Planet) ImportMoons() error {
- Exclude checks
exported method SolarSystem.ImportPlanets should have comment or be unexported Open
Open
func (s *SolarSystem) ImportPlanets() error {
- Exclude checks