18F/micropurchase

View on GitHub

Showing 18 of 122 total issues

Class AuctionShowViewModel has 36 methods (exceeds 20 allowed). Consider refactoring.
Open

class AuctionShowViewModel
  attr_reader :auction, :current_user

  def initialize(auction:, current_user:, bid_error: nil)
    @auction = auction
Severity: Minor
Found in app/view_models/auction_show_view_model.rb - About 4 hrs to fix

File charts.js has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

(function (window) {
  var microp = window.microp;

Severity: Minor
Found in app/assets/javascripts/insights/charts.js - About 4 hrs to fix

Class WinningBidderExport has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class WinningBidderExport
  class Error < StandardError; end

  PURCHASE_CARD_AS_PAYMENT_METHOD = 'Y'.freeze
  NATIONAL_INTEREST_ACTION = 'None'.freeze
Severity: Minor
Found in app/models/winning_bidder_export.rb - About 2 hrs to fix

Class AuctionShowViewModel has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class Admin::AuctionShowViewModel < Admin::BaseViewModel
  attr_reader :auction, :current_user

  def initialize(auction:, current_user:)
    @auction = auction
Severity: Minor
Found in app/view_models/admin/auction_show_view_model.rb - About 2 hrs to fix

Function chart5 has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      chart5: function chart5 (settings) {
        c3.generate({
          bindto: '#chart5',
          axis: {
            x: {
Severity: Major
Found in app/assets/javascripts/insights/charts.js - About 2 hrs to fix

Class AuctionListItem has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class AuctionListItem
  attr_reader :auction, :current_user

  def initialize(auction:, current_user:)
    @auction = auction
Severity: Minor
Found in app/view_models/auction_list_item.rb - About 2 hrs to fix

Class BidStatusPresenterFactory has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class BidStatusPresenterFactory
  attr_reader :auction, :user, :bid_error

  def initialize(auction:, user:, bid_error: nil)
    @auction = auction
Severity: Minor
Found in app/models/bid_status_presenter_factory.rb - About 2 hrs to fix

Function chart2 has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      chart2: function chart2 (settings) {
        c3.generate({
          bindto: '#chart2',
          data: {
            xs: {
Severity: Major
Found in app/assets/javascripts/insights/charts.js - About 2 hrs to fix

Function chart4 has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      chart4: function chart4 (settings) {

        var today = new Date();
        var twoWeeksAgo = new Date(today - (1000 * 60 * 60 * 24 * 14)); // 14 days ago
        var dateExtent = [twoWeeksAgo,today];
Severity: Major
Found in app/assets/javascripts/insights/charts.js - About 2 hrs to fix

Function chart4 has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      chart4: function chart4 (auctions) {
        var settings = {};
        settings.cols = [
            ['date_community'],
            ['Bidders'],
Severity: Minor
Found in app/assets/javascripts/insights/charts.js - About 1 hr to fix

Method change has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def change
    create_table "auctions" do |t|
      t.string   "issue_url"
      t.float    "start_price"
      t.datetime "start_datetime"
Severity: Minor
Found in db/migrate/20151020231437_rebuild_the_old_schema.rb - About 1 hr to fix

Function chart2 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      chart2: function chart2 (auctions) {
        var settings = {};
        settings.cols = [['bids_dates'], ['bids'], ['means_dates'],['means']];

         _.each(auctions, function(auction){
Severity: Minor
Found in app/assets/javascripts/insights/charts.js - About 1 hr to fix

Function chart5 has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      chart5: function chart5 (auctions) {
        var settings = {};
        // set of columns for the scatterplot
        // @format [['date_#{ auction number }', '#{ date }'],['#{ auction number }', #{ number of bids }]]
        settings.cols = [];
Severity: Minor
Found in app/assets/javascripts/insights/charts.js - About 1 hr to fix

Method relative_time has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def relative_time
    time_diff = (time - Time.now).to_i
    abs_time_diff = time_diff.abs

    if abs_time_diff < 24.hours
Severity: Minor
Found in app/presenters/dc_time_presenter.rb - About 45 mins 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 available_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  def available_message
    if admin?
      AdminAuctionStatusPresenter::Available
    elsif guest?
      BidStatusPresenter::Available::Guest
Severity: Minor
Found in app/models/bid_status_presenter_factory.rb - About 35 mins 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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    if auction.unpublished?
      BidStatusPresenter::Unpublished::Guest
    elsif future?
      future_message
Severity: Minor
Found in app/models/bid_status_presenter_factory.rb - About 25 mins 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 perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def perform
    auctions.each do |auction|
      next if auction.c2_proposal_url.blank? || auction.invalid?
      budget_approved_at = find_approval_timestamp(proposal_json(auction))

Severity: Minor
Found in app/services/check_approval.rb - About 25 mins 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 bid_label has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def bid_label(user)
    bid = highlighted_bid(user)
    amount = Currency.new(bid.amount)

    if bid.is_a?(NullBid)
Severity: Minor
Found in app/presenters/bidding_status_presenter/available.rb - About 25 mins 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

Severity
Category
Status
Source
Language