joegattnet/joegattnet_v3

View on GitHub

Showing 103 of 103 total issues

Function Gmaps4Rails has 59 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function Gmaps4Rails() {
      this.map = null;
      this.serviceObject = null;
      this.visibleInfoWindow = null;
      this.userLocation = null;
Severity: Major
Found in public/javascripts/gmaps4rails/gmaps4rails.base.js - About 2 hrs to fix

Method sync_down has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def sync_down(evernote_note)
    evernote_note.build_note if evernote_note.note.nil?

    self.evernote_note = evernote_note
    self.guid = evernote_note.cloud_note_identifier
Severity: Minor
Found in app/models/evernote_request.rb - About 2 hrs to fix

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 Gmaps4RailsGoogle has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function Gmaps4RailsGoogle() {
      Gmaps4RailsGoogle.__super__.constructor.apply(this, arguments);
      this.map_options = {
        disableDefaultUI: false,
        disableDoubleClickZoom: false,
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
          marker = _ref[_i];
          _results.push(this.boundsObject.extend(marker.serviceObject.latLng));
        }
Severity: Major
Found in public/javascripts/gmaps4rails/gmaps4rails.mapquest.js and 1 other location - About 1 hr to fix
public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js on lines 218..221

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 74.

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

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
        marker = _ref[_i];
        _results.push(this.boundsObject.extend(marker.serviceObject.position));
      }
Severity: Major
Found in public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js and 1 other location - About 1 hr to fix
public/javascripts/gmaps4rails/gmaps4rails.mapquest.js on lines 123..126

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 74.

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

Further Reading

Method calculate_after has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

  def self.calculate_after(current)
    return last_text if current == last_text
    alphabet = self.alphabet.split('')
    alphabet_without_space = alphabet - [' ']

Severity: Minor
Found in app/models/pantograph.rb - About 1 hr to fix

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

Consider simplifying this complex logical expression.
Open

      if ((circle.lat != null) && (circle.lng != null)) {
        newCircle = new google.maps.Circle({
          center: this.createLatLng(circle.lat, circle.lng),
          strokeColor: circle.strokeColor || this.circles_conf.strokeColor,
          strokeOpacity: circle.strokeOpacity || this.circles_conf.strokeOpacity,
Severity: Critical
Found in public/javascripts/gmaps4rails/gmaps4rails.base.js - About 1 hr to fix

Function createClusterer has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4RailsOpenlayers.prototype.createClusterer = function(markers_array) {
      var clusters, funcs, options, strategy, style;
      options = {
        pointRadius: "${radius}",
        fillColor: "#ffcc66",
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.openlayers.js - About 1 hr to fix

Method cut_image_binary has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def cut_image_binary(id, _format, aspect_x, aspect_y, width, snap, gravity, effects)
    image_record = Resource.find(id)

    file_name_template = image_record.template_location(aspect_x, aspect_y)
    file_name_out = image_record.cut_location(aspect_x, aspect_y, width, snap, gravity, effects)
Severity: Minor
Found in app/helpers/resources_helper.rb - About 1 hr to fix

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 from_omniauth has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def self.from_omniauth(auth, current_user)
    authorization = Authorization.where(provider: auth.provider, uid: auth.uid.to_s).first_or_initialize
    authorization.token = auth.credentials.token
    authorization.secret = auth.credentials.secret

Severity: Minor
Found in app/models/user.rb - About 1 hr to fix

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 show has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def show
    @tag = Tag.find_by_slug(params[:slug]) # .friendly.find is not working here
    @notes = Note.publishable.listable.blurbable.tagged_with(@tag.name)
    @word_count = @notes.sum(:word_count)
    @map = mapify(@notes.mappable)
Severity: Minor
Found in app/controllers/tags_controller.rb - About 1 hr to fix

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 createMarker has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4RailsGoogle.prototype.createMarker = function(args) {
      var defaultOptions, imageAnchorPosition, markerImage, markerLatLng, mergedOptions, shadowAnchorPosition, shadowImage;
      markerLatLng = this.createLatLng(args.Lat, args.Lng);
      if (args.marker_picture === "" && args.rich_marker === null) {
        defaultOptions = {
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js - About 1 hr to fix

Function createMarker has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4RailsOpenlayers.prototype.createMarker = function(args) {
      var marker, style_mark;
      style_mark = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
      style_mark.fillOpacity = 1;
      if (this.markersLayer === null) {
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.openlayers.js - About 1 hr to fix

Method cut_image_binary has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def cut_image_binary(id, _format, aspect_x, aspect_y, width, snap, gravity, effects)
    image_record = Resource.find(id)

    file_name_template = image_record.template_location(aspect_x, aspect_y)
    file_name_out = image_record.cut_location(aspect_x, aspect_y, width, snap, gravity, effects)
Severity: Minor
Found in app/helpers/resources_helper.rb - About 1 hr to fix

Function createServiceMarkersFromMarkers has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4Rails.prototype.createServiceMarkersFromMarkers = function() {
      var Lat, LatLng, Lng, index, marker, _len, _ref;
      _ref = this.markers;
      for (index = 0, _len = _ref.length; index < _len; index++) {
        marker = _ref[index];
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.base.js - About 1 hr to fix

Function create_polyline has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4RailsGoogle.prototype.create_polyline = function(polyline) {
      var clickable, decoded_array, element, latlng, new_poly, point, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _j, _len, _len2;
      polyline_coordinates = [];
      for (_i = 0, _len = polyline.length; _i < _len; _i++) {
        element = polyline[_i];
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.googlemaps.js - About 1 hr to fix

Function create_polyline has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4RailsOpenlayers.prototype.create_polyline = function(polyline) {
      var clickable, element, latlng, line_points, line_style, polyline_coordinates, strokeColor, strokeOpacity, strokeWeight, zIndex, _i, _len;
      if (this.polylinesLayer === null) {
        this.polylinesLayer = new OpenLayers.Layer.Vector("Polylines", null);
        this.serviceObject.addLayer(this.polylinesLayer);
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.openlayers.js - About 1 hr to fix

Function create_circle has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4Rails.prototype.create_circle = function(circle) {
      var newCircle;
      if (circle === this.circles[0]) {
        if (circle.strokeColor != null) {
          this.circles_conf.strokeColor = circle.strokeColor;
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.base.js - About 1 hr to fix

Method blurb has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def blurb(main_title, subtitle, clean_body, introduction = nil, blurb_length = NB.blurb_length.to_i, omission: NB.blurb_omission)
    headline = subtitle.blank? ? "#{ main_title }" : "<span>#{ main_title }: </span>#{ subtitle }"

    # If an introduction exists, use it
    # If the title is derived from the body, do not include it in the blurb
Severity: Minor
Found in app/helpers/blurb_helper.rb - About 1 hr to fix

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 create_direction has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Gmaps4Rails.prototype.create_direction = function() {
      var directionsDisplay, directionsService, request;
      directionsDisplay = new google.maps.DirectionsRenderer();
      directionsService = new google.maps.DirectionsService();
      directionsDisplay.setMap(this.serviceObject);
Severity: Minor
Found in public/javascripts/gmaps4rails/gmaps4rails.base.js - About 1 hr to fix
Severity
Category
Status
Source
Language