Showing 107 of 107 total issues
Method Watcher.tryWatch
has 72 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (w *Watcher) tryWatch(restarted bool) error {
currentLvl := -1
for lvl, p := range w.hierarchy {
err := w.fswatcher.Add(p)
if err == nil {
Function main
has 17 return statements (exceeds 4 allowed). Open
func main() {
material.Load(home("Github/material-design-icons"))
mdi.Load(home("Github/MaterialDesign-Webfont"))
typicons.Load(home("Github/typicons.font"))
fontawesome.Load(home("Github/Font-Awesome"))
Function batteryInfo
has 62 lines of code (exceeds 50 allowed). Consider refactoring. Open
func batteryInfo(name string) Info {
batteryPath := fmt.Sprintf("/sys/class/power_supply/%s/uevent", name)
l.Fine("Reading from %s", batteryPath)
f, err := fs.Open(batteryPath)
if err != nil {
Function fetch
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func fetch(srv *calendar.Service, conf config) ([]Event, error) {
timeMin := timing.Now()
timeMax := timeMin.Add(conf.lookahead)
req := srv.Events.List(conf.calendarID)
Function Run
has 58 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Run(modules ...bar.Module) error {
// Oauth configs are setup by modules when they're created.
// Now that all modules are created, the oauth system knows about all providers.
// So if the 'setup-oauth' arg was given, enter interactive setup instead.
// (InteractiveSetup calls os.Exit, so the rest of the bar will not run).
Function allBatteriesInfo
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func allBatteriesInfo() Info {
dir, err := fs.Open("/sys/class/power_supply")
if err != nil {
l.Log("No batteries: %s", err)
return Info{Status: Disconnected}
Function main
has 12 return statements (exceeds 4 allowed). Open
func main() {
colors.LoadFromMap(map[string]string{
"good": "#0f0",
"bad": "#f00",
"degraded": "#ff0",
Method SegmentGroup.Segments
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (g *SegmentGroup) Segments() []*bar.Segment {
var segments []*bar.Segment
for _, o := range g.outputs {
for _, s := range o.Segments() {
segments = append(segments, s.Clone())
Method write_capi_file
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def write_capi_file(library, package, pkg_config, header_filename, c_functions)
aliases = Set.new(
c_functions.flat_map { |fn| [fn.type] + fn.args.map(&:type) }
).map(&:aliases).reduce(&:merge)
Similar blocks of code found in 2 locations. Consider refactoring. Open
func getVolumeSource(client *proto.Client, deviceName string) (vol volume.Volume, err error) {
repl := proto.GetSourceInfoReply{}
err = client.Request(&proto.GetSourceInfo{SourceIndex: proto.Undefined, SourceName: deviceName}, &repl)
if err != nil {
return
- 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 130.
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 2 locations. Consider refactoring. Open
func getVolumeSink(client *proto.Client, deviceName string) (vol volume.Volume, err error) {
repl := proto.GetSinkInfoReply{}
err = client.Request(&proto.GetSinkInfo{SinkIndex: proto.Undefined, SinkName: deviceName}, &repl)
if err != nil {
return
- 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 130.
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
Method alsaModule.Worker
has 9 return statements (exceeds 4 allowed). Open
func (m *alsaModule) Worker(s *value.ErrorValue) {
// Structs for querying ALSA.
var handle *ctyp_snd_mixer_t
var sid *ctyp_snd_mixer_selem_id_t
// Shortcut for error handling
Function fetch
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func fetch(srv *calendar.Service, conf config) ([]Event, error) {
timeMin := timing.Now()
timeMax := timeMin.Add(conf.lookahead)
req := srv.Events.List(conf.calendarID)
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
func whereami() (lat float64, lng float64, err error) {
resp, err := http.Get("https://freegeoip.app/json/")
if err != nil {
return 0, 0, 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 121.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
func whereami() (lat float64, lng float64, err error) {
resp, err := http.Get("https://freegeoip.app/json/")
if err != nil {
return 0, 0, 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 121.
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 equalMarkup
has 8 return statements (exceeds 4 allowed). Open
func equalMarkup(a, b *html.Node) bool {
if a == nil && b == nil {
return true
}
if a == nil || b == nil {
Function Load
has 8 return statements (exceeds 4 allowed). Open
func Load(repoPath string) error {
f, err := fs.Open(filepath.Join(repoPath, "scss/_variables.scss"))
if err != nil {
return err
}
Method write_capi_file
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def write_capi_file(library, package, pkg_config, header_filename, c_functions)
aliases = Set.new(
c_functions.flat_map { |fn| [fn.type] + fn.args.map(&:type) }
).map(&:aliases).reduce(&:merge)
- 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
Method Watcher.tryWatch
has 7 return statements (exceeds 4 allowed). Open
func (w *Watcher) tryWatch(restarted bool) error {
currentLvl := -1
for lvl, p := range w.hierarchy {
err := w.fswatcher.Add(p)
if err == nil {
Avoid deeply nested control flow statements. Open
if !os.IsNotExist(err) {
l.Log("%s: %v", l.ID(w), err)
return err
}